From: Simon Horman <horms@kernel.org>
To: Suyuan Wang <shyckless@gmail.com>
Cc: david@ixit.cz, kuba@kernel.org, edumazet@kernel.org,
pabeni@redhat.com, davem@davemloft.net,
oe-linux-nfc@lists.linux.dev, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org
Subject: Re: [PATCH net] nfc: only send the SE_IO response to privileged listeners
Date: Wed, 2 Dec 2026 15:49:00 +0000 [thread overview]
Message-ID: <20261202154900.GB36956@horms.kernel.org> (raw)
In-Reply-To: <20261121-nfc-se-io-filter-v1-1-a28b383a6300@gmail.com>
On Sat, Nov 21, 2026 at 11:21:13AM +0000, Suyuan Wang wrote:
> From: Suyuan Wang <stevewong@hust.edu.cn>
>
> NFC_CMD_SE_IO sends an APDU to a secure element and needs CAP_NET_ADMIN
> (GENL_ADMIN_PERM). The response from the secure element is not sent
> back to the requester, though: se_io_cb() multicasts it with
> NFC_ATTR_SE_APDU on the "events" group, and generic netlink lets any
> user join that group. So an unprivileged user can read every response
> APDU that a privileged process exchanges with the secure element.
>
> The response has to stay on the multicast group, because that is where
> userspace reads it: neard's seeld sends NFC_CMD_SE_IO on one socket and
> handles the response on the socket it has subscribed to "events".
> Requiring CAP_NET_ADMIN for the whole group would also hide the device
> and target events from unprivileged listeners.
>
> So keep the multicast, but filter the receivers: deliver the SE_IO
> response only to sockets that were opened with CAP_NET_ADMIN in the
> initial user namespace, the capability that NFC_CMD_SE_IO itself needs.
> The check uses the credentials of the socket's opener, as
> do_one_broadcast() does, because se_io_cb() runs in the driver's
> context; a socket opened by a privileged process still gets the
> response after the process drops the capability or passes the socket
> on. Kernel sockets have no file and are skipped. Other events on the
> group are not affected.
>
> Found with a static analysis tool and checked by hand.
>
> Fixes: 5ce3f32b5264 ("NFC: netlink: SE API implementation")
> Cc: stable@vger.kernel.org
> Co-developed-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
> Signed-off-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
> Signed-off-by: Suyuan Wang <stevewong@hust.edu.cn>
> ---
> Tested in QEMU (x86_64, KASAN) with a test-only NFC driver whose se_io
> answers from a work item. Four listeners subscribe to "events": root;
> a socket opened by root that then drops CAP_NET_ADMIN; and two sockets
> opened without the capability (root without CAP_NET_ADMIN, nobody).
> Root then does DEV_UP (which adds the secure element), ENABLE_SE and
> SE_IO.
>
> Before: all four get SE_ADDED and the SE_IO response with the APDU.
> After: root and the socket opened by root get both; the two sockets
> opened without the capability get SE_ADDED only.
>
> Not tested on hardware (st21nfca and st-nci implement se_io).
Reviewed-by: Simon Horman <horms@kernel.org>
prev parent reply other threads:[~2026-12-02 15:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-21 11:21 Suyuan Wang via B4 Relay
2026-12-02 15:49 ` 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=20261202154900.GB36956@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=netdev@vger.kernel.org \
--cc=oe-linux-nfc@lists.linux.dev \
--cc=pabeni@redhat.com \
--cc=shyckless@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®