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=1796226545; b=14HisGnMc1bHSYT6bb3WvuknPIrCnTdSeaHwIpsPVd+EFnYxzSPDTjPRKTbShRQz3O/k +deH0SHPK6H0h3isLtHLf/7THsNDCdTE2zzmqEObzdEJsr5BXPFlFsYq9iLdLfek9mMuH 0sMoPJCIKDwKblZRW7ekYF9tU46mx0oLXwxxen5sEcEULXqqxegcOkUxiOTbA53cixZxy QVcjkw67+A5fs1wQvi0nnAdN+M7UdoVGRZBTsBcU8PtIiZGW6cKCnUCM0oiv0/kgCyxYU rUs7NRSCpTIXT2AeQs5o1IEO2EIuLFvYHJ4z0hpHE6IWK0EVf24BT2wiptnvSnkM6xw== 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== 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 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) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2013E1F00919; Wed, 2 Dec 2026 15:49:02 +0000 (UTC) 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== Date: Wed, 2 Dec 2026 15:49:00 +0000 From: Simon Horman To: Suyuan Wang 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 Message-ID: <20261202154900.GB36956@horms.kernel.org> References: <20261121-nfc-se-io-filter-v1-1-a28b383a6300@gmail.com> 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 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 > > 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 > Signed-off-by: Kaixuan Li > Signed-off-by: Suyuan Wang > --- > 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