From patchwork Wed Nov 13 16:18:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Massimiliano Pellizzer X-Patchwork-Id: 2010891 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XpT4P2clZz1y09 for ; Thu, 14 Nov 2024 03:19:01 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1tBG4y-0005wP-MG; Wed, 13 Nov 2024 16:18:52 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1tBG4u-0005lW-30 for kernel-team@lists.ubuntu.com; Wed, 13 Nov 2024 16:18:48 +0000 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id A56AE3F2A9 for ; Wed, 13 Nov 2024 16:18:47 +0000 (UTC) Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a9a2ae49a32so602193766b.3 for ; Wed, 13 Nov 2024 08:18:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731514727; x=1732119527; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=edJwYqQLyt1cvfEF6e0X1E5MZQPbGWoViQorp/qyk2M=; b=ne7KP/7QYQvVpT+FVKG4j6YHFKLOQxLV94qrW7zqJ0R85omezAc3z04EyGbm0ze103 ciJEaNmf2L5FTdL12qVr6Ml2ZgzURJcF9xMVE3ID0RSdTN4TWOneAwjjA+ILfBqDBPlf SqbMVOnpf5kLA7LHzneMG1F1Bh1OJ1UG6EdpwU30DnbcQD0H0spqATWOmcsqZQfPbvgu Z9LTfVnAbz8NJdAqSgLGyVTsVxZePE3p7XsnJraW/BsaktT81k+0v2Rkp5MgsOVLRifb tFIK3ybQjaycPyvx67wnXd/j3Dac4WdIL2p7iv5RZKfGGonmSOGju43ubPIf1LSZdOdw KIqA== X-Gm-Message-State: AOJu0Yxx3qsICYvKOueR4ObKi7225272yDQNqLpGxzJvbN5wAYUPpNmo DctmlaTGvXzYJthjvTKB5Zx9vTiQlTuRnU/lMBjoWThqZmYGNzkiPgg6261IdCXnxmi07hO4buw IcUTzo6QdxSiLHPBMQDsFc1KEKVUSKErJpkDxsyYX+kEO16nPqderUdiOywhK0zmhynPIqAGF9G X7DCIyqv22BA== X-Received: by 2002:a17:907:3ea4:b0:a9a:4621:b1d8 with SMTP id a640c23a62f3a-aa1f8041c43mr298188966b.8.1731514727000; Wed, 13 Nov 2024 08:18:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IGhXQSOKw1c0RS6c8RUS6fTRSiUslVrMmxm29dYdd3BcPJAs3Juy2fGtvA4kbvxs8z7waYnAA== X-Received: by 2002:a17:907:3ea4:b0:a9a:4621:b1d8 with SMTP id a640c23a62f3a-aa1f8041c43mr298186666b.8.1731514726563; Wed, 13 Nov 2024 08:18:46 -0800 (PST) Received: from framework-canonical.station (net-93-66-99-107.cust.vodafonedsl.it. [93.66.99.107]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9ee0e2e92esm889484466b.182.2024.11.13.08.18.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Nov 2024 08:18:46 -0800 (PST) From: Massimiliano Pellizzer To: kernel-team@lists.ubuntu.com Subject: [SRU][J][PATCH 1/1] ax25: fix use-after-free bugs caused by ax25_ds_del_timer Date: Wed, 13 Nov 2024 17:18:29 +0100 Message-ID: <20241113161829.57414-11-massimiliano.pellizzer@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241113161829.57414-1-massimiliano.pellizzer@canonical.com> References: <20241113161829.57414-1-massimiliano.pellizzer@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Duoming Zhou When the ax25 device is detaching, the ax25_dev_device_down() calls ax25_ds_del_timer() to cleanup the slave_timer. When the timer handler is running, the ax25_ds_del_timer() that calls del_timer() in it will return directly. As a result, the use-after-free bugs could happen, one of the scenarios is shown below: (Thread 1) | (Thread 2) | ax25_ds_timeout() ax25_dev_device_down() | ax25_ds_del_timer() | del_timer() | ax25_dev_put() //FREE | | ax25_dev-> //USE In order to mitigate bugs, when the device is detaching, use timer_shutdown_sync() to stop the timer. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Duoming Zhou Reviewed-by: Simon Horman Link: https://lore.kernel.org/r/20240329015023.9223-1-duoming@zju.edu.cn Signed-off-by: Jakub Kicinski (cherry picked from commit fd819ad3ecf6f3c232a06b27423ce9ed8c20da89) CVE-2024-35887 Signed-off-by: Massimiliano Pellizzer --- net/ax25/ax25_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ax25/ax25_dev.c b/net/ax25/ax25_dev.c index 4842f63821c8..fe730fad1c38 100644 --- a/net/ax25/ax25_dev.c +++ b/net/ax25/ax25_dev.c @@ -103,7 +103,7 @@ void ax25_dev_device_down(struct net_device *dev) spin_lock_bh(&ax25_dev_lock); #ifdef CONFIG_AX25_DAMA_SLAVE - ax25_ds_del_timer(ax25_dev); + timer_shutdown_sync(&ax25_dev->dama.slave_timer); #endif /*