Article View: linux.kernel.netdev
Article #23889Re: [PATCH v5 5/5] nfc: preserve NCI data status error codes
From: netdev-bot+sashiko
Date: Sat, 28 Nov 2026 14:13
Date: Sat, 28 Nov 2026 14:13
117 lines
11574 bytes
11574 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message understates how userspace sees the bug.
- [Low] In nci_nfcc_loopback_cb() (net/nfc/nci/core.c), the `else
nci_req_complete(ndev, NCI_STATUS_FAILED);` branch for err > 0 is deadβ¦
--
nfc: preserve NCI data status error codes
The patch changes the status parameter of nci_add_rx_data_frag() from __u8
to int. Before, the negative errno from nci_to_errno() was truncated into
an unrelated positive value. With the change, the original errno reaches
nci_data_exchange_complete() and the AF_NFC raw socket.
> For userspace AF_NFC raw sockets, this corrupts the reported error: for
> example, an NCI status error mapped to -EBUSY (-16) is truncated to
> 240 and negated to SO_ERROR=-240 instead of reporting EBUSY (16).
[Severity: Low]
Should this paragraph also describe what recv() returns on the raw socket
before this patch? The wrong SO_ERROR value doesn't seem to be the only
symptom userspace sees.
With the old __u8 parameter, -EBUSY arrives as 240 and gets passed down
this path:
nci_add_rx_data_frag()->nci_data_exchange_complete()->
rawsock_data_exchange_complete()->rawsock_report_error()
net/nfc/rawsock.c:rawsock_report_error() {
...
sk->sk_err = -err;
...
}
That stores -240 in sk_err. On the next recv(), sock_error() returns
-xchg(&sk->sk_err, 0), which is +240.
__skb_recv_datagram() only retries on -EAGAIN, so it returns NULL with
*err = 240. rawsock_recvmsg() then returns that value as is:
net/nfc/rawsock.c:rawsock_recvmsg() {
...
skb = skb_recv_datagram(sk, flags, &rc);
if (!skb)
return rc;
...
}
So userspace sees a successful read of 240 bytes with nothing copied into
its buffer, and 240 can be larger than the buffer it passed in. The other
mapped statuses behave the same way: -EBADMSG gives 182, -EPROTO 185,
-ETIMEDOUT 146, -ECOMM 186 and -ENOSYS 218.
The code change fixes this path as well. Could the commit message mention
the phantom read so stable maintainers can see the full impact?
> diff --git a/net/nfc/nci/data.c b/net/nfc/nci/data.c
> index 3bbebb9505545..4a2326a337649 100644
> --- a/net/nfc/nci/data.c
> +++ b/net/nfc/nci/data.c
> @@ -213,13 +213,11 @@ EXPORT_SYMBOL(nci_send_data);
>
> static void nci_add_rx_data_frag(struct nci_dev *ndev,
> struct sk_buff *skb,
> - __u8 pbf, __u8 conn_id, __u8 status)
> + __u8 pbf, __u8 conn_id, int err)
[Severity: Low]
This isn't a bug, but with this change the err > 0 branch in
nci_nfcc_loopback_cb() can no longer run:
net/nfc/nci/core.c:nci_nfcc_loopback_cb() {
...
if (err) {
kfree_skb(skb);
if (err < 0)
nci_req_cancel(ndev, -err);
else
nci_req_complete(ndev, NCI_STATUS_FAILED);
return;
}
...
}
The else branch was added in the earlier commit "net/nfc: fix skb
ownership on data exchange errors". At that point, the truncated status
coming out of this __u8 parameter was the only source of positive err
values.
After this patch, nci_add_rx_data_frag() passes only 0, a negative
nci_to_errno() value, or -ENOMEM. The other callers of
nci_data_exchange_complete() pass -ENODEV, -ETIMEDOUT or -EIO.
Could nci_nfcc_loopback_cb() be simplified to always call
nci_req_cancel(ndev, -err) when err is nonzero? Leaving the positive
branch in suggests that positive NCI status values can still arrive there.
> {
> int reassembly_len;
> - int err = 0;
>
> - if (status) {
> - err = status;
> + if (err) {
> kfree_skb(ndev->rx_data_reassembly);
> ndev->rx_data_reassembly = NULL;
> goto exit;
--
Sashiko AI review Β· https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261127134029.1813-1-luob87709%40gmail.com
Technical Details
Message-ID:
<179587522130.3135.16484405009456028236@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373153-linux-kernel-netdev=dewy.ruReferences:
<20261127134029.1813-6-luob87709@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373153-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH v5 5/5] nfc: preserve NCI data status error codes Date: Sat, 28 Nov 2026 14:13:41 +0000 Organization: Usenet Network Message-ID: <179587522130.3135.16484405009456028236@kernel.org> References: <20261127134029.1813-6-luob87709@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="963337"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:5BHvy9C16hz5IT+ew3sURLZssQw= sha256:jFIbiHot572qEjp2N5Vo+7oTtY0iFT5tiCLCx7IkSvA= sha1:nMHO1HrPurCb8a1YwVD0Mf1Mmgw= sha256:kshcOn+SUwqumFiMwnTn5NUE0gECiiWPnnWA0DCD31A= 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 CD3F7125F81; Sat, 28 Nov 2026 17:14:01 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 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, URIBL_BLOCKED=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 v4M-kxYbnxEv; Sat, 28 Nov 2026 17:13:58 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-373153-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 13013125F80; Sat, 28 Nov 2026 17:13:49 +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 7D071291F1; Sat, 28 Nov 2026 14:13:43 +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=1795875223; b=PXNejf8MsoYBia1CUdcWl/uUDM7nkPJ/gLKGv+2A7kKoNN7r22VQEhlYE5XiFslT3Ed2 CSi2ThOGy0JNs3ifroJ7EaqAcanRyHflHe+r5L8gdpDiBdmYekqluQguXlaU8XZ3dmsuF eY9FvEaF4dOs0TScZZVN81T6Gw4q0MjUwF65XC3PMYejyfgEv9kpmCyXgonFeyCCxodPD fjelOS37Ssvv2WV08JkLQk8CjmaqXqimIKUdDu8ZlZAgvxjBfsq1AkAv/cdnWV9WdzIiK xRoY3uoGeuxVaaOFaUAW85nwI3da279mW39gbKb3wcQ4CUBRpQVJh2ivcBO+H2r1hzw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795875223; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=LsodqXcZa0UHB181ZZOcveL5yhIK0evm2ZkAitBAPEI=; b=qQM9+mYVBOZe92X2QbJXYzrIxPf+zy8rwzYNt5X3vW8Akd75WTJcEP36v6EHoGeIrOmh rgnbBsMp3VzCQrbT2FwI4SmwfoQYhtJdmBzZMLwRfTdEW5MonymkwNc1wp5YTBc6IlA34 4uJsvzOE+dWYSQ+1cTx1b8mLwaQc2Cjbq9fP21ieS3pZrtZb2tnae1lYjzWOEbl3eHZxQ RSA2PHMwWi/YAexOLhFHhgIx/HAgdrIyfPmBfid5DblskjLyJENx1gz8naevCr3t7LHD7 Koqeus5C6sw2QPk1VZvbB1CAYvfyB4aB0fBY41EMrm9yRAFY4nzfv13ig2gzco+6LeQ== 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=nW0MJA8y; 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 55256606A31F; Sat, 28 Nov 2026 14:13:43 +0000 (UTC) X-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=nW0MJA8y 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=1795875222; b=LRQ2f6xUQf/IyiE2ZbFTcny2v6CuihwdOXgTrTb/eE8PBTfg2ktE77hncL7ispkADJVT QSAUhPa6fNJ6JCH/NPvZK1uuOxpazSt1NVi1ndwL1vxnt8ekiXiaxBq09oZTltp+fA7SH Jrx9l40PpiAkUa+a2WX7UbJ5N8Cb/DaaVHSn/IGLsBUyUR3PGynhTtH+JP/GC2w72Za5H jKgqquefIbwC9d6zdx+RjXkJPGg+8yq1Zh6IF7fvIeDrKznflpC9TyRRvpyn/6/Lq8AeL d5CQGjEeQr4T9z8+uk8L/N2LJWS8ZkOYWxjgSnX/187QejGbgo+jCSjAURM2h35u29A== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795875222; 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=LsodqXcZa0UHB181ZZOcveL5yhIK0evm2ZkAitBAPEI=; b=2i/sgJZ28lDvzKTngs6w15jskmvwvd6qRApm34ST2RH6jzDyVn7n93LqgHXNElej/MW+ /TsmEDfHkVJHQPwIdzKmVErCqTLwJrPoUZdUFZn6p45ZxiQpFSjhpkQn1BazyHbHzXYCt 4Fj7ensOX7/jtbUP7ypbKdp8ToY4CdIS8rCfWVIR8OlAD4zwsn8/5tkQb6LjabtnSF8d7 OtZNfCEsLhfjAbBq/E4yuxRS0jgYO+m7hcmXN2iCdL6UExNIoY+NuMhCCYHiPsYD/CB28 ZhPlr7hs46rH57stgr6dhgIDL47b89J0dSxpirpuXBxdTQl+RCCcT0OMztXpX5QhC7w== 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=nW0MJA8y; 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 7542B606A325; Sat, 28 Nov 2026 14:13:42 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id B08D11F00898; Sat, 28 Nov 2026 14:13:41 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795875222; bh=LsodqXcZa0UHB181ZZOcveL5yhIK0evm2ZkAitBAPEI=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=nW0MJA8yt2Oq/PvWfW02oRhwcCr6slMH2qkxLs/c87z+kZ+VbtNIirAJlaOfj24uG ySvqjy76mfruqnOA8TEusfSXVVf6ekSBzkgXHLAF/PUx6MzOYe6COsCkVFz3kX3EBi l2ZPZkVJW7Xrk4YQIn0qJ4JHVqIvSSuZ513tsgWCHtC5KMeWk8SoWcJZ2dLFCSSSah T62Twp37bPzs3jQg7l68tuR0AFSPaHiJvlP8xJZQmLDe+PqAj33T25t5pwssUzZbeU CZW49Nk9FNCrT8xDwCcJDgzYUyZooc0K9jb5/vIdBsjOQA7UStUU0/aISYJS7tW1Ht 4w1CsJ0Du6Ecw== X-Cc: oe-linux-nfc@lists.linux.dev, johan@kernel.org, david@ixit.cz, kuba@kernel.org, netdev@vger.kernel.org, stable@vger.kernel.org X-In-Reply-To: <20261127134029.1813-6-luob87709@gmail.com> X-sashiko-severity: Low 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