Article View: linux.kernel.netdev
Article #8634[PATCH v2 net] nfc: llcp: use disable_work_sync and timer_shutdown_sync in local_cleanup
From: Tristan Madani
Date: Thu, 29 Oct 2026 16:24
Date: Thu, 29 Oct 2026 16:24
75 lines
13878 bytes
13878 bytes
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
net/nfc/llcp_core.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/net/nfc/llcp_core.c b/net/nfc/llcp_core.c
index 74bf817007cf2..984e7088288f0 100644
--- a/net/nfc/llcp_core.c
+++ b/net/nfc/llcp_core.c
@@ -173,15 +173,15 @@ static struct nfc_llcp_local *nfc_llcp_local_get(struct nfc_llcp_local *local)
static void local_cleanup(struct nfc_llcp_local *local)
{
nfc_llcp_socket_release(local, false, ENXIO);
- timer_delete_sync(&local->link_timer);
+ timer_shutdown_sync(&local->link_timer);
+ timer_shutdown_sync(&local->sdreq_timer);
+ disable_work_sync(&local->rx_work);
+ disable_work_sync(&local->tx_work);
+ disable_work_sync(&local->timeout_work);
+ disable_work_sync(&local->sdreq_timeout_work);
skb_queue_purge(&local->tx_queue);
- cancel_work_sync(&local->tx_work);
- cancel_work_sync(&local->rx_work);
- cancel_work_sync(&local->timeout_work);
kfree_skb(local->rx_pending);
local->rx_pending = NULL;
- timer_delete_sync(&local->sdreq_timer);
- cancel_work_sync(&local->sdreq_timeout_work);
nfc_llcp_free_sdp_tlv_list(&local->pending_sdreqs);
}
--
2.47.3
Technical Details
Message-ID:
<20261029162419.2420980-1-tristmd@gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-353379-linux-kernel-netdev=dewy.ruShow 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-353379-linux-kernel-netdev=dewy.ru
From: tristmd@gmail.com (Tristan Madani)
Newsgroups: linux.kernel.netdev
Subject: [PATCH v2 net] nfc: llcp: use disable_work_sync and timer_shutdown_sync in local_cleanup
Date: Thu, 29 Oct 2026 16:24:19 +0000
Organization: Usenet Network
Message-ID: <20261029162419.2420980-1-tristmd@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="2047675"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:JTkQD5RikKYV24YCjTzjNcfs5l4= sha256:NhTXlBWv0v+q1Vbps50CVF9CWaD5SDbOVbvmCU6rsd8=
sha1:c2NWGSDuXjohjFn+H+EbIewhkz0= sha256:JAKiuAFTudK0tGMmJci5iTAumdhDGqXn9wEuxibcFlg=
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 374B4125C6B; Thu, 29 Oct 2026 19:31:02 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: 0.51
X-Spam-Status: No, score=0.51 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_SBL_CSS=3.558,
SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=no autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
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 lWbNfFtjfLxQ;
Thu, 29 Oct 2026 19:30:56 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-353379-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id 6E18A125C65; Thu, 29 Oct 2026 19:30:48 +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 53BC334838; Thu, 29 Oct 2026 16:24:31 +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=1793291068;
b=LeNJV2cyOmQ9ENUxNXNv4tGoP9J/WZMA06/JV9U+QjnjxN2SwX1vYea3wuRKnthxWcpV
yVauRfhrgXY1A9PjI2FB/Gxf39GFyLb4rBXotZWYhxQGaL5HOV6FLN+mEP3WrepRuHWeu
7jl7jrS1hPEaW0ylXFqXXNxNejE10CE2BWt8RLhmclsCdEQycnl0nDNAsp8o5GfH9Uw0c
BtqZy+VsIK9P0/OKr26B50sE2AUKwri+hJuzXVHzwau9lLTBfrhofaKFzRV3bwhSfTgUW
YnHJhAdwPaTBWBweXqTJAruLit7VS5mtglncXGT4/xTACcS+ufH0gt9Qo/HcT3wXgYQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793291068;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:Date:Message-ID:
X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Transfer-Encoding;
bh=oNt+k5hd6gK3JHgbJpiRSUaj/zK/QDMMxaVigJ+IVv8=;
b=UOCxBtz1xQbNNFlRBpmuF36JcuO+sEsCXCi9F4HOaiZHuc6B36/KijExoHXVk0Z2eoXP
nxQRacf9TAm+l6GkUlyx2BMz6hdTwBCBWvTFXGWkrkD6hGXNUcNZycvtnCLI3xikeeFir
0EXJIzfeRNINQHAJJ2a9Mr3KBR38E6oqGisP0OHkIZ+QKGXRBbbb/ZBWGdxPmF+B5D2jK
3wbpHxQGXHPuG6+ylIJt4bGis5sc3wpF5chIp4qpU5MMKm8uhPg6F63Uy1Yl/VBdEf4MQ
cJIAE2xtD5ttKYS8yuo8npGjrAuxNrbKehirM7YfsTjBdJqzTH97XoRWmBNaInUknSA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=EGgcrtXQ;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
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 E7415606A331;
Thu, 29 Oct 2026 16:24:27 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=EGgcrtXQ
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.45
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1793291067;
b=BHgXISQuirQQcub5oN7afeE40RWD+bBjb9eQSKArwT8UvOvGvH4Z+fwByRL2lVedcC09
4aZJbW8tyugDkykyEKBizeIklSgthyxcpLw8fAIxiQzbX0bAgwFSuaH5fPFbl0cNxAOV/
aMLWWPK2G2XNfeDpqmvH6H5grZE//hznu2f/HhYry5W7+PFTATirKFQihLEVqoRhAr3fS
AHz4X3nZtI6hH7RRX4t6Z7pAuzqPiM2WHFgQ0aqvo9GBvPpb2pN1zYOVYFEFaEysKlQMn
JWDUIagWWTqMCcB9yaS2idvmFkeFL4ZRR0X6qons8kqBZ6jr7dLDpui/khFiCVlSt2g==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793291067;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version:
Content-Transfer-Encoding;
bh=oNt+k5hd6gK3JHgbJpiRSUaj/zK/QDMMxaVigJ+IVv8=;
b=D+WHhie4sWKGA4xa41ZQmTdUynI7UgaAkAbFU5HLu3CXXAip5eoUB33FBgJw53P+4n0b
zgdmjrvbC9SSpHAmg4zaPrM1FuXy4u4WsNUWaE+QgBG7TPvXoD57O/NATzwSA+eqs5qyo
GTELjqzQcXImYHhGCNCZ59CtIoeb35N2vUvn5ZsWuU4UZixvRoN7jiHM+uwYx7q46of8N
mdM2i60QuwHr1MdTlfa/UoSfcJ69Lcnr1iX8BYfgcdpqm5tXUiAV4mbSRd4zFauF4KVIU
fOeFUCYsLGGRU+J1yrtNYTuHOX4ic8NbnvAxy9ZM0/VwgOufLpe6O4c39QjbbTUi14Q==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=EGgcrtXQ;
arc=none smtp.remote-ip=209.85.221.45
X-Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 43D22606A31D
for <netdev@vger.kernel.org>; Thu, 29 Oct 2026 16:24:26 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 43D22606A31D
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-48e20edd106so1859389f8f.1
for <netdev@vger.kernel.org>; Thu, 29 Oct 2026 09:24:26 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1793291064; x=1793895864; darn=vger.kernel.org;
h=content-transfer-encoding:mime-version:message-id:date:subject:cc
:to:from:from:to:cc:subject:date:message-id:reply-to:content-type;
bh=oNt+k5hd6gK3JHgbJpiRSUaj/zK/QDMMxaVigJ+IVv8=;
b=EGgcrtXQdOXQe8Wg0+y8mCFeBHdwKIWFWLS/tzXhFxzxnqxJrzHwwWiZtPoBhrGyJ5
MJMiCdAOXmfo0PFLF8Gw6XXBHnFLiZx1RPVgWgOIayKgr5ex+ji6RJACXHIRA2UMfkUp
K94IctlgigFoTiFGSgNvWkZJwURBoPJ8ZOAXPv7ziW7TPFNd0rY8zBP8/sFl6i6HaLu9
TGAUU8LJZhRX+gcJnKV2J+GUnwrH/f8+XehiIAOGPRgYE/VmO2/uvWCsMyyDFz5kHlf/
kwp16+H7ZDGxYyLza2o5TJWPDlOpw3LGog5MqLTr0MGnczBNMJQ1jAlV2E+vyAkVSNmj
avbA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1793291064; x=1793895864;
h=content-transfer-encoding:mime-version:message-id:date:subject:cc
:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=oNt+k5hd6gK3JHgbJpiRSUaj/zK/QDMMxaVigJ+IVv8=;
b=KKp7m2Hq87HGLVQowj1zpjBmczBS3eaMSBQq89sXe/szCZO4FWyc9GgakRQcLE5qcT
HhUrSH76ZcMPO3WCrgzH9DcMS8/LDYYMKGrVA7in4zuJDZTaB5zZ70JApZxWgqPjPFeb
YNX3gw/09upIwAzRbeEDWYKWirYH3R7Sa+/wxC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acd0b85a97d-48e5d5b4a5emr14665720f8f.51.1793291064450;
Thu, 29 Oct 2026 09:24:24 -0700 (PDT)
X-Received: from debian.. ([2001:41d0:303:db6b::])
by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e6dfaa4ccsm135494f8f.39.2026.10.29.09.24.20
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Thu, 29 Oct 2026 09:24:21 -0700 (PDT)
X-Cc: Simon Horman <horms@kernel.org>,
"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-Mailer: git-send-email 2.47.3
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