mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Tristan Madani <tristmd@gmail.com>
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>
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	[thread overview]
Message-ID: <20261031175359.GT257209@horms.kernel.org> (raw)
In-Reply-To: <20261029162419.2420980-1-tristmd@gmail.com>

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>


      parent reply	other threads:[~2026-10-31 17:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29 16:24 Tristan Madani
2026-10-29 16:28 ` netdev-bot+sinfo
2026-10-29 18:07   ` Tristan Madani
2026-10-31 17:53 ` Simon Horman [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261031175359.GT257209@horms.kernel.org \
    --to=horms@kernel.org \
    --cc=davem@davemloft.net \
    --cc=david@ixit.cz \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=netdev@vger.kernel.org \
    --cc=oe-linux-nfc@lists.linux.dev \
    --cc=pabeni@redhat.com \
    --cc=sameo@linux.intel.com \
    --cc=stable@vger.kernel.org \
    --cc=tristan@talencesecurity.com \
    --cc=tristmd@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®