Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp861284lqz; Sun, 31 Mar 2024 02:32:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVo9Dj97Uj+Tlv0W1qoGE8W+cc3n5GmJGeztp0NPhF2V0prOWYdaKRlty/GhIr5mNWHa94RiN3cX5bSGD2ePfDL2PuJ8obfCo9zSqBJ4Q== X-Google-Smtp-Source: AGHT+IFcb+v1INRV32W3XjMtVscpgLV4RFg3B8UWaMbuS4StttOnXWT/b/FY/gzoAusUzfioZ/++ X-Received: by 2002:a05:620a:5652:b0:78a:728c:7b2c with SMTP id vw18-20020a05620a565200b0078a728c7b2cmr6610106qkn.51.1711877575250; Sun, 31 Mar 2024 02:32:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711877575; cv=pass; d=google.com; s=arc-20160816; b=WOeoby5UvkGooE1xY2TlQPQhvDNrwNFJa5ueOLP8mv1NH6WZJH/RngggmovBNzlDqD n6ftGPznInZG5c+fF4Nd47UHysjX5zC6U5eYVAgM1M82JG5uJ8UpqVMpC9Ybn1zWOONE wg+Iy0ZgPzwbnG4lH2MAO+j4/bh9ECowtx57UkNYgg5VN6Jy2orVJ4XLPtW/DxpW0JmI Wef0xsv+BdQ42O9UGb//zBZM/LL2KGTwCxonSKmBBUAvvEvb31Uoy2rhfET8/5LN01tN U6T3ITx4dG2IhxtkPZAnI5t0zyDwGmguAL92G8oRBJOJTaLvG8YrTH5EalTY6gbqMWZO r9ow== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=r0lVJaJiPKz8z25xBu38f7/S3pMne/onWt5BAIr95Z0=; fh=PtQf8r+KEhi/v/eMXrcguQABfAVNZ59Yikqf6g0TRgQ=; b=oH95Qc35yisyy+laUekGRl7rwRKxHjtlPTtLut6hm3z/uuUqygFVNs9kK/dWFz6Rlo ALLSFTQbUxOFDZW9sGbFHiEB2QbpF+FA6GdwjUaxHxuSaT6dH7CUpnuF4979QRzcwm22 Iv60nOOTzr7SVIa/ceYc96QxXmRDTsmOJxDJA/yB7ltnvbsgjk452yxAcLngYlCHIOkn 2CmbwVBhP8KEnVfWWkrX/0YeT9JQiMnKwJuqEQhfc2tuGs9bxJsivpOb/OSYGGyY7+gm 5a2ykRP3rZ7ywPSSbWFVyEpdzLw9fgz4jsZIjPVXc7ed96vnSi2+t6ieRWxE6Za/60uJ NuYg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OKMhz6eg; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-126026-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-126026-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y27-20020a05620a0e1b00b0078bdcc548f8si1436155qkm.642.2024.03.31.02.32.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Mar 2024 02:32:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-126026-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OKMhz6eg; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-126026-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-126026-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id F26F41C211D0 for ; Sun, 31 Mar 2024 09:32:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B54987603F; Sun, 31 Mar 2024 09:32:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OKMhz6eg" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D20CE74BF4; Sun, 31 Mar 2024 09:32:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711877566; cv=none; b=PDELnuOyk1aGrWuDrKaUBZSNkkt15Oot7rdTedEhkqDdAw41WoZ3X4lKF/VfJEDBkGh7os550N49MaciZgFudAlDiEddnM9lSBDtK7hcc8EfWE0YP12UyVxdvnGryNL+ddxya9CUJ7lgfBAK36gy0xrxlzmUpCOzy5SBC9x78Ak= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711877566; c=relaxed/simple; bh=2enq6wAu/O4AeWARd094N9k1k7dNI3QZzRGN2sj1ta0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=iMBqUpSPL2c+ocO5Q1uU3DDGRCXRw0H7M8/bLQLf69J4O02PvlThpDikIyk/7Zk6xSJaCdgac5T6/NG4e/4f83h3eQRquEcJzQvwCH0Hdz2jWdpqsk24w5CWJrfOg257mUq8qYSR02KYz8qpVDWh2gnDLcXZX6QsnJlED/R2iSc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OKMhz6eg; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96306C433F1; Sun, 31 Mar 2024 09:32:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711877565; bh=2enq6wAu/O4AeWARd094N9k1k7dNI3QZzRGN2sj1ta0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OKMhz6egBE+acFXIafQ3P8FTGcVhCEiKujymKP5WRIQ/QVNQdarAqzCq3QyhN9CDI pUvnjDtj7IvbTg0LkSWDOjZJXFfDLmQS8uFLurOZBAu9Vv1LnGMSDMIENbw+BD2P3z 7n9S/VxH5Dr+ELusP98pq1MLLX8cWo0r625SMZ/rMRlqaN4ZHBwE83rVkttIW34oMz 6rYjyS0cq+R76PXJwHYi/VrALQJfojUR8K3OCE9LXgrR1Fb49PriNAYETy+FfJ9VjC pK12pYKT6BvZy3YuyTU0/+V9jhxDyJmlZQKrAzrz3Eph+rdEw2ClNN1Cy7Wii/vtST f1y/oZDtaeC3g== Date: Sun, 31 Mar 2024 10:32:41 +0100 From: Simon Horman To: Duoming Zhou Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hams@vger.kernel.org, pabeni@redhat.com, kuba@kernel.org, edumazet@google.com, davem@davemloft.net, jreuter@yaina.de Subject: Re: [PATCH net v2] ax25: fix use-after-free bugs caused by ax25_ds_del_timer Message-ID: <20240331093241.GB26556@kernel.org> References: <20240329015023.9223-1-duoming@zju.edu.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240329015023.9223-1-duoming@zju.edu.cn> On Fri, Mar 29, 2024 at 09:50:23AM +0800, Duoming Zhou wrote: > 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 > --- > Changes in v2: > - Call timer_shutdown_sync() in ax25_dev_device_down(). Thanks, as per my review of v1, I do think this is a correct approach to addressing a valid concern. But I would also value another set of eyes on the problem. Reviewed-by: Simon Horman > 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 c5462486dbc..282ec581c07 100644 > --- a/net/ax25/ax25_dev.c > +++ b/net/ax25/ax25_dev.c > @@ -105,7 +105,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 > > /* > -- > 2.17.1 >