Article View: linux.kernel.netdev
Article #9170Re: [PATCH v2 net] nfc: llcp: use disable_work_sync and timer_shutdown_sync in local_cleanup
From: Simon Horman
Date: Sat, 31 Oct 2026 17:53
Date: Sat, 31 Oct 2026 17:53
49 lines
10160 bytes
10160 bytes
On Thu, Oct 29, 2026 at 04:24:19PM +0000, Tristan Madani wrote:
> From: Tristan Madani <tristan@talencesecurity.com>
>
> local_cleanup() tears down timers and work items before
> local_release_work() frees the nfc_llcp_local structure. The current
> code has two ordering problems:
>
> 1) timer_delete_sync() does not prevent timer callbacks from re-arming
> the timer via mod_timer(). nfc_llcp_tx_work() unconditionally
> re-arms link_timer, and nfc_llcp_sdreq_timeout_work() conditionally
> re-arms sdreq_timer. A work callback that runs during
> cancel_work_sync() and calls mod_timer() causes the timer to fire
> after the structure is freed.
>
> 2) cancel_work_sync() does not prevent work items from being
> re-queued. nfc_llcp_rx_work() queues tx_work via
> schedule_work(), and the timer callbacks queue their associated
> work items. Since tx_work is cancelled before rx_work, a
> running rx_work instance can re-queue tx_work after its
> cancel_work_sync() has returned. The re-queued tx_work then
> runs on the freed structure.
>
> Switch the timers to timer_shutdown_sync() which rejects subsequent
> mod_timer() calls. Switch the work items to disable_work_sync()
> which rejects subsequent schedule_work() calls.
>
> Reorder the teardown sequence so that both timers are shut down
> first (their callbacks queue work items), rx_work is disabled
> before tx_work (rx_work queues tx_work), and data structures are
> freed only after all asynchronous callbacks are quiesced.
>
> Fixes: d646960f7986 ("NFC: Initial LLCP support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
> ---
> v2:
> - Switch work items from cancel_work_sync() to disable_work_sync()
> to prevent re-queuing after cancellation, as identified by the
> automated review and confirmed by Simon Horman
> - Reorder teardown: shut down both timers first (their callbacks
> queue work items), then disable rx_work before tx_work (rx_work
> queues tx_work), then disable remaining work items
> - Move data structure cleanup (skb_queue_purge, kfree_skb) after
> all asynchronous callbacks are quiesced
Thanks for the updates.
Reviewed-by: Simon Horman <horms@kernel.org>
Technical Details
Message-ID:
<20261031175359.GT257209@horms.kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-354116-linux-kernel-netdev=dewy.ruReferences:
<20261029162419.2420980-1-tristmd@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-354116-linux-kernel-netdev=dewy.ru From: horms@kernel.org (Simon Horman) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH v2 net] nfc: llcp: use disable_work_sync and timer_shutdown_sync in local_cleanup Date: Sat, 31 Oct 2026 17:53:59 +0000 Organization: Usenet Network Message-ID: <20261031175359.GT257209@horms.kernel.org> References: <20261029162419.2420980-1-tristmd@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="2515678"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:+pmzRDVFc32SIBztBxYBfk2facE= sha256:CvFIi6VR5ehH9ca5fap3HKmJfTniWpPFM9uU1tCgYwA= sha1:f8HiEb2xQ91hrP5jl8xZ3H3vdDo= sha256:o3nViMlp1ZlClZqL6zT+ivGqrd6H2WDciM/uNO91pHc= Content-Disposition: inline List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id D2855125CB5; Sat, 31 Oct 2026 20:55:02 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jTNszRZzlK1Y; Sat, 31 Oct 2026 20:55:00 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-354116-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id A7236125CB6; Sat, 31 Oct 2026 20:54:50 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id A75F3268F1; Sat, 31 Oct 2026 17:54:27 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1793469267; b=Mywzsakdm3e1NCDigcF6UP4cqC90I6zST1McfMHNQhn+ar66Qb+MH+1YYEtg4+A2h2HZ FLCcLobTDc3NPe6xqSXnZoWVCw+2XL5F290IhLkTlWSd0NS2QIZHTKy2DQVXKH85TJOsi SOxGKBcRLRubVjiAkn2XfA5KSzpL+EYZjGHU9DnCvQkeg11tRM4ZfFsTLsbSLHgg5VZeX UKTdsKlfNtc2ymtkGbACFXtzsofMprox4iIr2mo18DkA8e4dRG29JdQFX0KJh/fyFXXFV AJsFUEZR7jVSIkffJIb2Jr32dSYw9hm/MACbW5LvFLl/rlMhGXrg3Nr1dmTcZt92Vbw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793469267; h=X-Original-To:Received:Received:DKIM-Signature:Date:From:To:Cc: Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=/MwNJYTzhevleVLT0wB4o/dVQzk0Vd5QdLxqWEpD0FQ=; b=L04zGwdXbaKGzdSE8p/WDmCAQ2qBUk+s487iydfr4g5GjhhhJyOlPX2Pu/IqgSblEVZb Cq4HvCzduvnap2dMi5hvihjXidhcf2+lNQW7FVMlg1RpXrPp8Nd5CdKSmBhuv+vRt41g6 PVW4zHMs0D1Ff2oJms5VB0Yqz7rz33li+YrL6mU2qQMWg/lCNcCbmDuk3W57QdGkApDX+ QZNwT7VXcCBvaxJUa6xfCfdkpKtCeF+8yU1Yf5YQ9eRM1+lHTAgICDZ53wMzoZZ8ouAWt dl41EGah/2cQ83zvgqbP34oPr2abUrRPZLE4LqTG4mIEkDFF/KCKoOONfDBgdDdSpsw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=kTCFNsmG; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6897C606A31C; Sat, 31 Oct 2026 17:54:27 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=kTCFNsmG X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793469244; b=kEAECIpqxqsBmW2pOW4V4NOeLpXshBf/IIDw6MLMmPlR/B6ahgRGLggLQ8jQxOpvkRk8 478CXItMVutktO9enJ6Ax7TQgacL7h6YwexNebVJ091z6xFeBMRj0jUfal4SZ+3bqVHKN 3dVKfMwJVOm/k3WFYUk8MIqEltW9eaQ4xdLgAWL7s2r9HXaIhbfg+ZMOBtEWxixRCqS7s BqROWjB31xZfOfJhPRSxFV+HR3iFs/JBKiT/fysPmwkKxzomIB4EIehRd2zSB4241NHx/ cjFnewuuwyv/gU7cW//db7/Tfpp/Im+7IOGIAsak7uA8rhiOoNkEy97hxK2TZeDF9oQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793469244; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=/MwNJYTzhevleVLT0wB4o/dVQzk0Vd5QdLxqWEpD0FQ=; b=TGQz558JAF0AykvsM0JBOaygPyZ0bGlv9sZf9fYkoWMhtj/MFWtbrPSR+k2WaH2pmlOR MDmlcggPyxe23brVNmSkXDpk8ic/JNSHDjvt0hB7EOF6oLq/yN2DQ5SXo1LFWj0ALwc8j wNHKXVkYzduRrBnQLYtENqpjs79DWhUqWdC8X0IGr0wct8iZMNby7FjrtzjZ+Hx6arC1z /ITJevEQentgAz9D0kQPUErUk+F46M+AJZ/xCZGt9e392R1CtBZ9eRWH4dkAG2ftDa4Dh ubEfUCKLJVeNSArzzCC87J1NwnNLH8z1MYrJsD3KjZ/p7EbuU7z+1NrbpDrnllRa1lA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=kTCFNsmG; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1540D606A31A; Sat, 31 Oct 2026 17:54:03 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 594DB1F000C1; Sat, 31 Oct 2026 17:54:01 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793469243; bh=/MwNJYTzhevleVLT0wB4o/dVQzk0Vd5QdLxqWEpD0FQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=kTCFNsmGcTJfyOV1keEj1/p0CdrFp2vaz+QLyJrN5JCQVApzXwW2K3eOn1LFIPLKt eox3mYq5wnO/o1+BUQ/N6UDTQ2RBbkteTpg0UMFwyS++Lc1xr3ZoHLcoV1lz/m/qV1 0cTyQWCDJfoGDFMVwJ/NvMZOdHsFLAX0yfQPnARVrnFPlVZ3YjqbzgUQFQIYbnXO4w VDCuMuUX2BWe8Mlav84GNSKYeoZGh0g0MvICYdxirCX+jsqv5p2paC5UuDvyikBjqP xjngLZl2Ep2eGBRYY810aGFUm0fFFYZ+eEaikyNY6JtfcBrPNlSopJNv7eqU1z3rfO PeWW7LSZVo7JQ== X-Cc: David Heidelberg <david@ixit.cz>, "David S . Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, "John W . Linville" <linville@tuxdriver.com>, Samuel Ortiz <sameo@linux.intel.com>, oe-linux-nfc@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Tristan Madani <tristan@talencesecurity.com> X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-In-Reply-To: <20261029162419.2420980-1-tristmd@gmail.com>