Article View: linux.kernel.netdev
Article #26183[PATCH net] nfc: llcp: fix work and timer teardown order in local_cleanup()
From: bin luo
Date: Thu, 03 Dec 2026 07:15
Date: Thu, 03 Dec 2026 07:15
77 lines
14945 bytes
14945 bytes
From: Bin Luo (University of Electronic Science and Technology of
China) <luob87709@gmail.com>
In net/nfc/llcp_core.c, the LLCP worker and timer dependency chains are:
1. rx_work -> schedules tx_work -> arms link_timer ->
schedules timeout_work
2. sdreq_timer <-> sdreq_timeout_work (mutually re-arming when
pending_sdreqs is non-empty)
However, local_cleanup() currently deletes link_timer before cancelling
tx_work, purges tx_queue before cancelling tx_work (which can put an
skb back via skb_queue_head() when !llcp_sock->remote_ready), and
cancels tx_work before cancelling rx_work. Likewise, it calls
timer_delete_sync(&local->sdreq_timer) before cancelling
sdreq_timeout_work, which can re-arm sdreq_timer via mod_timer().
As a result, an in-flight rx_work can re-queue tx_work after
cancel_work_sync(&local->tx_work), tx_work can re-arm link_timer after
timer_delete_sync(&local->link_timer) or leave a re-queued skb in
tx_queue, and sdreq_timeout_work can re-arm sdreq_timer after
timer_delete_sync(&local->sdreq_timer), leaving active works, timers,
or leaked skbs on struct nfc_llcp_local when local_release_work() frees
it.
Tear down the work items and timers in producer-to-consumer order using
disable_work_sync() and timer_shutdown_sync(), which permanently
prevent re-queuing and re-arming once local_cleanup() begins, and purge
tx_queue after tx_work is disabled.
Discovered by static analysis and AI-assisted code review; not triggered
standalone without delay injection, and regression-tested in QEMU KVM
(KASAN, LOCKDEP, DEBUG_OBJECTS_TIMERS, DEBUG_OBJECTS_WORK) across 200
nfcsim module load/unload cycles with active LLCP links and against
tools/testing/selftests/nci/nci_dev (8/8 passed).
Fixes: c7aa12252f51 ("NFC: Take a reference on the LLCP local pointer
when creating a socket")
Fixes: 40213fa8513c ("NFC: llcp: Add cleanup support for unreplied SNL
requests")
Cc: stable@vger.kernel.org
Signed-off-by: Bin Luo (University of Electronic Science and
Technology of China) <luob87709@gmail.com>
---
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 74bf817..32530a2 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);
+ disable_work_sync(&local->rx_work);
+ disable_work_sync(&local->tx_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);
+ timer_shutdown_sync(&local->link_timer);
+ disable_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);
+ timer_shutdown_sync(&local->sdreq_timer);
+ disable_work_sync(&local->sdreq_timeout_work);
nfc_llcp_free_sdp_tlv_list(&local->pending_sdreqs);
}
--
2.43.0
Technical Details
Message-ID:
<CALa7h7GjO7+8TZsf+RjPy=7joRUWZZw-ybnLxKRcWq09LnMpeA@mail.gmail.com>Path:
mbox-mo1.pugleaf.net!news-lon.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376362-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376362-linux-kernel-netdev=dewy.ru
From: luob87709@gmail.com (bin luo)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net] nfc: llcp: fix work and timer teardown order in local_cleanup()
Date: Wed, 2 Dec 2026 23:15:18 -0800
Organization: Usenet Network
Message-ID: <CALa7h7GjO7+8TZsf+RjPy=7joRUWZZw-ybnLxKRcWq09LnMpeA@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Info: usenet.network;
logging-data="2402466"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:HoIeMefRzYs+DAckPR4icuQJ8Uw= sha256:l8o9dcBy12m2DVWGWl2jbaDnhTGzFQh5FzZdqIYnF64=
sha1:LSdIcNfNrEPDfsRiKQWOVfZHxhE= sha256:u+wRCigGwBFmuKHBHp3yqowY7o06FGqJbNos8brO1mI=
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 8869211785C; Thu, 3 Dec 2026 10:15:36 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 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.249,
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=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 z0gt8zElSWIG;
Thu, 3 Dec 2026 10:15:33 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-376362-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 6F576117859; Thu, 3 Dec 2026 10:15:25 +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 0CA6429D32; Thu, 3 Dec 2026 07:15:22 +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=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1796282121;
b=wSFex/QX3POhdDORR2Bvjaa4WJYiGZOIH7+a15c3Ynok7LN66u4k0hUMWFT9pDpQyS+5
U5UXl1Hhm/ebqhacTckNqzQyJeVeXo2ZqE1g1xr685dN5DPLKQYz6Kh5VQClqeDO1X0Vf
JXhhy6Tjc488r9Ui6XOG8EpJqoq1Tzpc/Am96P/UFmRe8P/EtMB/qJtXbPqA7osp7GFyv
UWCPcbRqYPZtDZ3OxMPkyeHJY10+dIKhYvbCSX80c2afJiVujjZCkesECeW45KSMqaseU
q5pvK01MkC8y1TIzQsuOhFuz1ZkOM2g60C9oyrCkuaHmU9uQ/m1Km0zAvIeGo/zjnLQ==
X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796282121;
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:X-Mailing-List:List-Id:List-Post:
List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
MIME-Version:From:Date:X-Gm-Features:Message-ID:Subject:To:Cc:
Content-Type;
bh=4c7Mr/cx8vB8LFC0nU8jPl4Rta6IB3wnTp825IBHo+E=;
b=QDJV/8WxZM8NrQEKqmsJyHT6ijfmsVmj714DjApRvTGECWg3IEl+uYm59S3tdopYuihf
Gp5MHOwgfb8N3UrzftMeB42MM7n/sSMaz00Cpvh1btx0qsIglBQACrttc+sp3E0fj8nUW
znbpf3a5tgeAC2agfOiAx3e+gKedy76IzUwzo8rklQMVpwLcP/0+BB3Jzu0QTpk+gdsJp
43h/sTjgHJH6B56v4Ws4f8Fl/VVmxYWL0TUbk6p4fwvLbF42qk1ZRh++A2KtDdIc3Xfvg
lYnHoksCE+oL7uhZtTkKGsWnsDtt8G6KokItw96WVl4e0q5SxJWcDQq8XThNJ+NOJxQ==
X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=L+9YznAa;
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 8840F606A683;
Thu, 3 Dec 2026 07:15:21 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=L+9YznAa
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=209.85.208.178
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1796282120;
b=J/rgLa6J9xUviKWmPQZ8JuWf48DzjPyL7eEiWSQlc4Uu/iKklBC54kZJhuSuev1O1fM6
eILRJ8JDZKCDCbA6WVCxe3Dt812hHUXzvsD2hDTSsfKXi9bw3YMEMHzubC783LoRoJwcv
mZz6rR7Qai9J5RTxQMEUx4qt8sUGIKOgWbbCU2ZsKRJ2e0jFkEsRajaqX/RV3d7Uncp00
v3mjNJ5KNAPHqgbdnKi/7QLajR0iooVc/V4GbhvkJ9OdbKEYjpTLuI7tOKGUElg+IsxMs
ruL+VGolJLE8FDYuJX3/vl0cmz+93y2q5yh9OG3/wCX/9czF9Z7LYQ7U/dZpWQoCiLg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796282120;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
MIME-Version:From:Date:X-Gm-Features:Message-ID:Subject:To:Cc:
Content-Type;
bh=4c7Mr/cx8vB8LFC0nU8jPl4Rta6IB3wnTp825IBHo+E=;
b=vEx2T92FWOKapWueq1e8qgM+zDnsRzYRQtuM/hfdJwnCesyAglnNxIxx2AIQlowgkvjp
0za0UE2VttZOAT0i5Db1LQLrnaU6RY0Lm2iw9hh2IM0yvhuuD/dbt8DmReS4ANcQQmswp
lzTsmiWJhjedVEO+guu91/tl/GRbCfBblT9eWfv50AoDEvoBwZ69xldgDZMI2rx1dzENy
k+zvESkK9o/u8aECROtbt88v2C/AQLE5/MqIQCRutBVRWZrgdp38Esvzi1v7j94Y5Y8Ss
eM2rjM47hAQExRmwSkpnJNaBiuh/Cpp0SxWSVLvO1WsZHPklJDqvRalwJ1jzbWc3eVw==
X-ARC-Authentication-Results: i=2; 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=L+9YznAa;
arc=pass header.oldest-pass=0 smtp.remote-ip=209.85.208.178
X-Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178])
(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 5A281606A32D
for <netdev@vger.kernel.org>; Thu, 3 Dec 2026 07:15:20 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5A281606A32D
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-lj1-f178.google.com with SMTP id 38308e7fff4ca-3adfcafaabbso138564071fa.3
for <netdev@vger.kernel.org>; Wed, 02 Dec 2026 23:15:20 -0800 (PST)
X-ARC-Seal: i=1; a=rsa-sha256; t=1796282119; cv=none;
d=google.com; s=arc-20260327;
b=BMgzj7FXR/gSlminCvGgre8TLkd0OJEiPCR4D3GhAvNZwj0dIpmjqCY5MfO+avqvP4
9HxXAe3ZRaS0dKtaeCDG9r77X1d7rHXql9mWAHPjs4QIOJ2L0saSqQP3Z56vj+YlOgmz
EA2XNOerc4AA3h6P5xrOOixgBAYASBlQzBXlIIdA6pkWCkyhMFuG2kXlXCWyua7p/KzQ
tltsSoir4BG0pIu7EKfkxfeSPG/O6l6nYD7YnJ81Eg4sOV5FE6ZvQSBV52KYU5eZn51l
6IuAaEGYA5ztD8mdU2Y70P0xXuJN1YOTu6Gk36KtGEWUea5W3LILqOImSwRPwebBuZwK
jmvA==
X-ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327;
h=cc:to:subject:message-id:date:from:mime-version:dkim-signature;
bh=4c7Mr/cx8vB8LFC0nU8jPl4Rta6IB3wnTp825IBHo+E=;
fh=k+Loj7F6V8Q4VjoJ/r+kKeUJp9eZHQqTSGtQnr86kSM=;
b=L0wDOj9piXoLFUnPxOSxNbAn6AQX9oyj8c+3mMIq1m7D12a5K8qeWSPC08osXlHphB
WSNfgcGOpASWdcpuVxSchycu4VI15zWsygAXiRCTpz4sUIF9MAKOJr6QecoAdm3ZkcF/
1VEhylRzxhfa8e9vYu8ZQcfCYGkX3Wvwb8kZ5eEtgYGMNOEqQAJOo6GMMF02qjJtUCkp
sJDRKR5nwMPQCeKGWqYdeCWR9rLuXSYlfmN7Qzzh6vqCaD8EMwuVKeT09YILka77qe7c
Ck8ptCX3dhznNA1JUfsvUZ+R9GCyikN0OP2m7ioE+9ldt0pg4dxNsXa04vTOc10FYVAx
TwxA==;
darn=vger.kernel.org
X-ARC-Authentication-Results: i=1; mx.google.com; arc=none
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1796282119; x=1796886919; darn=vger.kernel.org;
h=content-type:cc:to:subject:message-id:date:from:mime-version:from
:to:cc:subject:date:message-id:reply-to:content-type;
bh=4c7Mr/cx8vB8LFC0nU8jPl4Rta6IB3wnTp825IBHo+E=;
b=L+9YznAa4EIVk+1Di2VuBuybwwM+gGFWuOYSkngV9WG8R9v1GB9AupiCy+l5bKi3ZP
dnjSyOlfkVj+Y98zYYJ6Q5rfZa4FLSB/Zr8lmGEZ9l6IoUwQd/eFWOt3tNQrFHL5hecn
tO+RhmLpCyvKqOCVKEMkSi34m1dY43IJVIwklnXPcRv0UhJu9ksQDYYxBPJWVfNarkVA
hJU63a89Cqy7C4eUbFQUcrQuqr83d/C/SLkIwa2TwuJb71aLYkmjpm97MGgbmqhj76j6
VsFwWEZa0KWr+fL2/yYcr9v8X80W8is7ioRAz4Co2Is+i8eKGNHIa/iOQXfpBHJ5cZvB
HEqQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1796282119; x=1796886919;
h=content-type:cc:to:subject:message-id:date:from:mime-version
:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id
:reply-to:content-type;
bh=4c7Mr/cx8vB8LFC0nU8jPl4Rta6IB3wnTp825IBHo+E=;
b=f4n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UcotGyTEbzWz3cV0
yNtJlniGsNGU4+frRog5OtjtEC+uvpveXBO4k1Z04sAfRbZhH7EJ23vZVyH4wr6bWtORRRgi2DK
CbdSzbklKPiIWaA5ArM5UQ=
X-Received: by 2002:a05:651c:2214:b0:3ab:2d6a:1a1c with SMTP id
38308e7fff4ca-3ae7f9d9643mr127004051fa.12.1796282118377; Wed, 02 Dec 2026
23:15:18 -0800 (PST)
X-Received: from 1087654160852 named unknown by gmailapi.google.com with
HTTPREST; Wed, 2 Dec 2026 23:15:18 -0800
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-Gm-Features: Aa3M54oCFQiuja05f5t4iSWA9aG1aVoL8hGp_W2qmazhp2TQS5i8lw5sX5D9EZc
X-Cc: oe-linux-nfc@lists.linux.dev, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org