From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796453082; b=O8s1qLqILnutY5Ekj1RxLgxiLMJJhKBuOy5QT8TuoKO9GRi7VjI11Im+fpbMGtEtvJgD ioFZmpoRpesjFEpuAo6/5cmrsyEdclW0ONdQ+kgOAuEn5rowme9f0p8UsFZJQpS7X0dcE 8hsFPJ8tJeCY/kXFv87OtRju4t0iFHqSemCs3HwWCnHWzfMCnsSV7kABGoNxGcgsRpJ4m Df/mVY5TvzL8BjG/z6WveZX5WHIoO5UljTv6a7ehsuLF9zv1KnrUMt7tHUwBIpdguiShV 28AtWQ5N6Py6136+SzZxokNIkHgtrCVco6OhvOLu3yfE7p8hFj6O3DjCnZGPKzSXgBg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796453082; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=vnVYEOrEIx+Oc5FKoI3mJ0b3BsLcSoRSPvN12pZWLuI=; b=tD76LYMFMkciUMSud0shzwwjYB4eQoQW9BqLYI2w6SmqRltPvof8+vXBbMHiGUeXy/M7 O26cWz6lWwlx5j160F82FfFqn3twteQ8QVQLeyWSXN/5vovBsC0IuSZSsdrWGOJdz48Ie LTuBRIw+SeTqWBSGjARKtcEqt5q2xUXRRYzIyxjn6xYPq0ANJFgRCuGEH9S3ksXALfK0x Y8zJ3RnZyFwqwh5GDrJzdNwoDHo8A9/ldcmvVYU7IuytJ2+nKgMSFQeqrXRrNKeWIXqd1 xBohXNkjHzSrmf7BAEEO3eFxmOJ3JkzLN/x+NVyOR0pci1bd9iC5wQJZQKqs2UrcKjQ== 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=fYv75avu; arc=none smtp.remote-ip=100.103.45.18 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 0C744606A33A; Sat, 5 Dec 2026 06:44:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=fYv75avu Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C8221F0092B; Sat, 5 Dec 2026 06:44:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796453081; bh=vnVYEOrEIx+Oc5FKoI3mJ0b3BsLcSoRSPvN12pZWLuI=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=fYv75avu+EOiX3WpdGNR9BVCrtbxzzhOxOQCdSwbDaUANuahG543eQPrFJGgyc3u/ BLfjwV+aqfnstOQD8xiQ2gMwB6dXWs6RwWBHX8KL1/vjBmBsfsCxYXzaK0/jyKUQlA aOeI4AM55V4SCG5tFPDVmstSFKUfR2vaFcs18C1HNDdWKA0BVtTYlXYpBh9zPWcDn/ OHrMmntRuHuPn8VxLpM6GGg6BdVwcZSitLTI07Obw4s7fVxu901hBYCbr2llxJdAO6 jOGdB6SnmwpxS6VjZ20zJVqQPTSN2Eb6Mv6RFj17QQ3uAwZz4x2ZpczYZXsTL2u0mY xHtckKKRhdGpA== Subject: Re: [PATCH net v2 2/2] nfc: rawsock: move nfc_deactivate_target() to rawsock_release() From: netdev-bot+sashiko@kernel.org To: luob87709@gmail.com Cc: david@ixit.cz, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, oe-linux-nfc@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Date: Sat, 05 Dec 2026 06:44:40 +0000 Message-ID: <179645308074.3146.1852550158044237615@kernel.org> In-Reply-To: <20261204060651.488-3-luob87709@gmail.com> References: <20261204060651.488-3-luob87709@gmail.com> X-sashiko-severity: Critical Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider. Critical: 1 · High: 0 · Medium: 0 · Low: 1 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Critical] This patch moves nfc_deactivate_target() out of rawsock_destruct() and into rawsock_release() in net/nfc/rawsock.c. - [Low] The commit's Author field has no real name: `luob87709@gmail.com `. -- nfc: rawsock: move nfc_deactivate_target() to rawsock_release() This moves the nfc_deactivate_target() call out of rawsock_destruct() and into rawsock_release(), where it runs after tx_work has been cancelled. The goal is to stop the synchronous NCI deactivate request from running on ndev->rx_wq when an in-flight data exchange drops the last socket reference. nfc_put_device() stays in rawsock_destruct(). > Fixes: 23b7869c0fd0 ("NFC: add the NFC socket raw protocol") > Cc: stable@vger.kernel.org > Signed-off-by: Bin Luo (University of Electronic Science and Technology of China) [Severity: Low] This isn't a bug, but the Author field on this commit is only the bare address "luob87709@gmail.com ". It doesn't match the name in the Signed-off-by line above, and the SoB name also includes an affiliation string. The previous patch in this series, "nfc: rawsock: serialize SEND_SHUTDOWN and write queue teardown", has the same mismatch. checkpatch reports it as a From:/Signed-off-by: name mismatch. It may come from the b4 web relay mentioned in the v2 changelog. Would a "From: Bin Luo " line in the body, plus a SoB without the affiliation, record the authorship correctly? > diff --git a/net/nfc/rawsock.c b/net/nfc/rawsock.c > index 291f509f07caf..e2a9a2b0bf5f9 100644 > --- a/net/nfc/rawsock.c > +++ b/net/nfc/rawsock.c > @@ -78,6 +78,10 @@ static int rawsock_release(struct socket *sock) > __rawsock_write_queue_purge(sk); > spin_unlock_bh(&sk->sk_write_queue.lock); > cancel_work_sync(&nfc_rawsock(sk)->tx_work); > + > + nfc_deactivate_target(nfc_rawsock(sk)->dev, > + nfc_rawsock(sk)->target_idx, > + NFC_TARGET_MODE_IDLE); > } [Severity: Critical] Can this deactivation now race with a data exchange from this same socket that is still in flight? cancel_work_sync() only waits for rawsock_tx_work() to return. It doesn't wait for the nfc_data_exchange() that rawsock_tx_work() already submitted, and that exchange holds its own sock_hold() reference. Before this patch, rawsock_destruct() could only run after rawsock_data_exchange_complete() dropped that reference. So deactivation always happened after the driver was done with the response. On pn533 the two sides look like this: close() side: rawsock_release() nfc_deactivate_target() device_lock(&dev->dev) pn533_deactivate_target() skb_queue_purge(&dev->resp_q); dev->wq side, without device_lock: pn533_wq_cmd_complete() pn533_send_async_complete() pn533_data_exchange_complete() skb_queue_tail(&dev->resp_q, resp); ... skb = pn533_build_response(dev); Suppose the purge runs after skb_queue_tail(). Then resp is already freed and pn533_build_response() finds resp_q empty and returns NULL. After that, pn533_data_exchange_complete() does: skb = pn533_build_response(dev); if (!skb) { rc = -ENOMEM; goto error; } ... error: dev_kfree_skb(resp); Doesn't that free resp a second time? Chained (MI) responses can leave several skbs on resp_q. In that case pn533_build_response() walks the queue without the queue lock: skb_queue_walk_safe(&dev->resp_q, tmp, t) { memcpy(skb->data + tmp_len, tmp->data, tmp->len); Could a concurrent purge turn this into a use-after-free read and a corrupted list walk? This also looks reachable without privileges now: - rawsock_create() checks CAP_NET_RAW only for SOCK_RAW. - nfc_sock_create(), rawsock_connect() and rawsock_sendmsg() don't check anything. Before this patch, deactivating pn533 during an in-flight exchange (pn533 has no check_presence op) needed NFC_CMD_DEACTIVATE_TARGET or NFC_CMD_ACTIVATE_TARGET. Both are GENL_ADMIN_PERM. A second socket can't do it either, because nfc_activate_target() returns -EBUSY while a target is active. The unlocked resp_q handling in pn533 predates this patch. What's new is the trigger: an unprivileged SOCK_SEQPACKET socket can send one frame and then call close() while the response is still being processed on dev->wq. Could the in-flight exchange be waited for or aborted before nfc_deactivate_target() is called here? Another option is to avoid the destruct-time deactivation some other way that doesn't run it alongside driver completions. > > sock_orphan(sk); [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204060651.488-1-luob87709%40gmail.com