🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #25867

Re: [PATCH net] nfc: only send the SE_IO response to privileged listeners

#25867
From: Simon Horman
Date: Wed, 02 Dec 2026 15:49
49 lines
10138 bytes
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>
Technical Details
Message-ID: <20261202154900.GB36956@horms.kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375916-linux-kernel-netdev=dewy.ru
References: <20261121-nfc-se-io-filter-v1-1-a28b383a6300@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375916-linux-kernel-netdev=dewy.ru
From: horms@kernel.org (Simon Horman)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] nfc: only send the SE_IO response to privileged
 listeners
Date: Wed, 2 Dec 2026 15:49:00 +0000
Organization: Usenet Network
Message-ID: <20261202154900.GB36956@horms.kernel.org>
References: <20261121-nfc-se-io-filter-v1-1-a28b383a6300@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="2002956"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:fl5wE3CgmSbHwwFRpGDsLRib61g= sha256:XNRJyYE0WAG38CnQmJNVRWs2tWtCFZ/+yCh8g/J7FOA=
	sha1:jbHbfQJl+TmiyZ9s2iyoU3XZjro= sha256:9HhXVtCi7E/QN9e1ZK/DykggErwovJrIYONZB9UhlPM=
Content-Disposition: inline
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 B5C311176A4; Wed,  2 Dec 2026 18:49:31 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 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] 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 NGeZrF3FIF6h;
	Wed,  2 Dec 2026 18:49:28 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-375916-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 80932117650; Wed,  2 Dec 2026 18:49:20 +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 50C182DEC4; Wed,  2 Dec 2026 15:49:11 +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=1796226551;
	b=u+N4bSMMoqSkykw4FZ8/uR7+ZMO11rZwvReVbIpY40sLLrO66h5l01BVaML8q9LwdUbQ
	 2DC61/8J6Bms8DRoagdw0jyun/BgZ63TzPl3j3SFyJU0tEqVxEU3vFD+R9Q+eFa717cLC
	 +DE+rOcu3k1aTIzveP8P9I9fHnatlOGkWHWNr3ExIYH1HfoLkZExmBiuGQnA7KEnIrwfZ
	 FNFnTqABPuM/CzcVBnJ1yaOCa03+7QOspI/zKAu0dZCLqBKH6Gs34HChlj0ZlZKc35/Ug
	 egORWlLsEez3b1GXcl/DzEp+GjOzUlP3kGQ4Gx055LiCh8tfxiGNaSSOGJCU9ujZpFw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796226551;
	h=X-Original-To:Received:Received:DKIM-Signature:Date:From:To:Cc:
	 Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=ynoQTAGFHakogO3+3YUEaCQxb8lZqYhY8i8d1MisLwM=;
	b=3TFYbNZCmjyGEJT6Cbt3v/hriY2ae6QHvyUzUGKjbSlPQwvpFinZ0WuF9J0DXh8K/H63
	 VhXIb5/z+FgwO9M4dZnKybfn5Fm6FJ3PmC7D7iLg0AWRsr1hxbwtNAc3epFqXE14Z1zGa
	 BIriO23Sio4QAlNo19HfTO7BaZqJPEYIdUEf0YGcWkqC/rupCLZcvtCYDl4uQxrWyexOu
	 HuV9McOidOgv3YXcHGawkOed8Y7ccMEnRwwfqraZs1doXywTQN8jIjyBTP0YoRs5WjuRj
	 1fR58v/KRyCs6gEissyd1scHiEpUK1GO+yEk/U8Fgs1H1h2u74t6db/8f90iZ2jFIDA==
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=BhNkPYpU;
	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 296EE606A327;
	Wed,  2 Dec 2026 15:49:11 +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=BhNkPYpU
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=1796226545;
	b=14HisGnMc1bHSYT6bb3WvuknPIrCnTdSeaHwIpsPVd+EFnYxzSPDTjPRKTbShRQz3O/k
	 +deH0SHPK6H0h3isLtHLf/7THsNDCdTE2zzmqEObzdEJsr5BXPFlFsYq9iLdLfek9mMuH
	 0sMoPJCIKDwKblZRW7ekYF9tU46mx0oLXwxxen5sEcEULXqqxegcOkUxiOTbA53cixZxy
	 QVcjkw67+A5fs1wQvi0nnAdN+M7UdoVGRZBTsBcU8PtIiZGW6cKCnUCM0oiv0/kgCyxYU
	 rUs7NRSCpTIXT2AeQs5o1IEO2EIuLFvYHJ4z0hpHE6IWK0EVf24BT2wiptnvSnkM6xw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796226545;
	h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID:
	 References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=ynoQTAGFHakogO3+3YUEaCQxb8lZqYhY8i8d1MisLwM=;
	b=as8WnDzvsHZwNNdOxXAGr9netGtVCblWy+2TN5+TmhmZ1FsvkneXJ7u0woElfJ2dCh2l
	 QNPhD04WWX0FUd+IC9f85miX/ioJdQYH5vmK+KFQEWc0YSoqG/pef9E7avfJU9RHeHB15
	 Zd5/R1ZQvxdh2aEPPUswyFThBQULGOfSMKuO2izEJYGjE39zfxochwe1XOYSoQTizkBwA
	 jl4PKC7eNmhD4A3NPBNpOvkL/yWsa/YuQXENm10UeEwlCtSic32vusXTblDoUyir3t9F4
	 ziooaa7weO6STFz7wYMS/uqzMKO6UDs3h5urO8owdDnMnOKC7dW91vzKzZzjplUxUsQ==
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=BhNkPYpU;
	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 455AA606A325;
	Wed,  2 Dec 2026 15:49:05 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2013E1F00919;
	Wed,  2 Dec 2026 15:49:02 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796226544;
	bh=ynoQTAGFHakogO3+3YUEaCQxb8lZqYhY8i8d1MisLwM=;
	h=Date:From:To:Cc:Subject:References:In-Reply-To;
	b=BhNkPYpU2YpIT7mSYWfvhCQ3JeYZWeFbbi5hz1Pclv54EJJJdIIB8MFQGf0Co0O1M
	 CRnqtjBZCKSACiISDUfHGcZBG3j9QmvxDwWFkraytxdfP1GmI2+kjNw3dMDbaygboT
	 bM+q+UQzAcEVDt3QtWh60aU056JSWj43AMIYBO+gO+LBpEOSCCj9tddKVBoMQ47aXG
	 o25y9QMr+6Dy5dDYBZqras+AXIA5fqMIZeu3Dq4et8SwPfzrNFDgQZVVJjf66uQPjA
	 GajCksl06IRE5DvHu+3LwdDToRGhUiEUsB7OyHA7MiFELLEkLPxXqZmhH7WAhN6Lqx
	 toXp8Nia8cf3A==
X-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
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-In-Reply-To: <20261121-nfc-se-io-filter-v1-1-a28b383a6300@gmail.com>