Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next] rxrpc: Reject unsecured calls to userspace services with a minimum level
@ 2026-11-26 22:41 Andrew Stellman
  2026-11-27 23:24 ` netdev-bot+sashiko
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Stellman @ 2026-11-26 22:41 UTC (permalink / raw)
  To: David Howells, Marc Dionne
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, linux-afs, netdev, linux-kernel

From: Andrew Stellman <astellman@stellman-greene.com>

rxrpc_get_incoming_security() doesn't check rx->min_sec_level, so a
userspace service socket that sets RXRPC_MIN_SECURITY_LEVEL above
RXRPC_SECURITY_PLAIN still accepts incoming calls with security index
RXRPC_SECURITY_NONE.

Refuse security index NONE in that case. Kernel sockets are skipped,
because kAFS and rxperf set RXRPC_SECURITY_ENCRYPT on the kernel sockets
they serve on. This changes behaviour for a userspace service that sets
the minimum and relies on unsecured incoming calls being accepted.

Tested in an arm64 QEMU guest built from mainline 9437ee8b6cf6, as uid
1000 with no capabilities: a service socket with the minimum set to
RXRPC_SECURITY_ENCRYPT received an unsecured call over loopback without
this patch, and with it didn't receive the call within four seconds. A
service with no minimum received the call in both cases.

The issue was found by Claude Fable 5.2 and Claude Opus 5.5 running
Quality Playbook, an LLM-driven code review tool:
https://github.com/andrewstellman/quality-playbook
The fix was drafted with OpenAI GPT-6 (Codex) and this changelog with
Claude Opus 5.5, and both were reviewed by me.

Signed-off-by: Andrew Stellman <astellman@stellman-greene.com>
---
This only covers security index NONE. I didn't test rxkad or rxgk, but
nothing in them reads rx->min_sec_level, so calls secured below the
minimum look like they would still be accepted. I can send a v2 that
enforces the minimum for those too, or a documentation patch if the
option is meant for client calls only.

A reproducer is available on request.

 net/rxrpc/security.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/rxrpc/security.c b/net/rxrpc/security.c
index 2bfbf2b2bb37a..52015c73c583c 100644
--- a/net/rxrpc/security.c
+++ b/net/rxrpc/security.c
@@ -138,6 +138,11 @@ const struct rxrpc_security *rxrpc_get_incoming_security(struct rxrpc_sock *rx,
 
 	_enter("");
 
+	if (sp->hdr.securityIndex == RXRPC_SECURITY_NONE &&
+	    rx->min_sec_level > RXRPC_SECURITY_PLAIN &&
+	    !rx->sk.sk_kern_sock)
+		return NULL;
+
 	sec = rxrpc_security_lookup(sp->hdr.securityIndex);
 	if (!sec) {
 		rxrpc_direct_conn_abort(skb, rxrpc_abort_unsupported_security,

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] rxrpc: Reject unsecured calls to userspace services with a minimum level
  2026-11-26 22:41 [PATCH net-next] rxrpc: Reject unsecured calls to userspace services with a minimum level Andrew Stellman
@ 2026-11-27 23:24 ` netdev-bot+sashiko
  0 siblings, 0 replies; 2+ messages in thread
From: netdev-bot+sashiko @ 2026-11-27 23:24 UTC (permalink / raw)
  To: bugs
  Cc: dhowells, marc.dionne, davem, edumazet, kuba, pabeni, horms,
	linux-afs, netdev, linux-kernel

Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 1 · Low: 2

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).

- [High] The fix is incomplete.
- [Medium] After this patch, RXRPC_MIN_SECURITY_LEVEL means different
  things depending on rx->sk.sk_kern_sock, and the documentation does…
- [Low] The new reject path in rxrpc_get_incoming_security() returns NULL
  without calling rxrpc_direct_conn_abort() with its own reason.
- [Low] The commit is described as a fix for a security-policy bug (a
  service minimum security level that is not enforced for unsecured…

--

rxrpc: Reject unsecured calls to userspace services with a minimum level

This patch makes rxrpc_get_incoming_security() refuse incoming calls with
security index RXRPC_SECURITY_NONE when a userspace service socket has set
RXRPC_MIN_SECURITY_LEVEL above RXRPC_SECURITY_PLAIN. Kernel sockets are
exempted, because kAFS and rxperf set RXRPC_SECURITY_ENCRYPT on the sockets
they serve on.

> Signed-off-by: Andrew Stellman <astellman@stellman-greene.com>

[Severity: Low]
This isn't a bug, but should this have a Fixes: tag? The changelog
describes the patch as a fix for a security policy bug.

The patch also deliberately changes behaviour for existing userspace
services. Could the changelog say whether it is meant for stable?

> diff --git a/net/rxrpc/security.c b/net/rxrpc/security.c
> index 2bfbf2b2bb37a..52015c73c583c 100644
> --- a/net/rxrpc/security.c
> +++ b/net/rxrpc/security.c
> @@ -138,6 +138,11 @@ const struct rxrpc_security *rxrpc_get_incoming_security(struct rxrpc_sock *rx,
>  
>  	_enter("");
>  
> +	if (sp->hdr.securityIndex == RXRPC_SECURITY_NONE &&
> +	    rx->min_sec_level > RXRPC_SECURITY_PLAIN &&

[Severity: High]
The commit message gives the root cause as:

  rxrpc_get_incoming_security() doesn't check rx->min_sec_level

This check only covers security index NONE, though. Will a userspace
service socket with RXRPC_MIN_SECURITY_LEVEL set to RXRPC_SECURITY_ENCRYPT
still accept rxkad or rxgk calls negotiated at a lower level?

In rxkad_verify_response(), the level comes from the client's RESPONSE
packet. It only gets an upper bound check:

net/rxrpc/rxkad.c:rxkad_verify_response() {
    ...
	level = ntohl(response->encrypted.level);
	if (level > RXRPC_SECURITY_ENCRYPT) {
		...
	}
	conn->security_level = level;
    ...
}

rxgk_verify_response() does the same thing with the token level:

net/rxrpc/rxgk.c:rxgk_verify_response() {
    ...
	conn->security_level = token->rxgk->level;
    ...
}

Neither of these compares the level against rx->min_sec_level. Apart
from the setters and this new check, min_sec_level is only read in the
client call setup paths, rxrpc_kernel_begin_call() and
rxrpc_new_client_call_for_sendmsg().

An authenticated client could answer the CHALLENGE with level
RXRPC_SECURITY_PLAIN or RXRPC_SECURITY_AUTH. Its calls would then reach a
service that requires ENCRYPT. At PLAIN level the data has no integrity
protection either.

That seems to contradict Documentation/networking/rxrpc.rst, which
describes the option as "the minimum security level required for calls
on this socket".

The gap is only mentioned below the --- line, so the note won't end up
in git history. Should the negotiated level also be checked where the
connection gets secured, in rxkad_verify_response() and the rxgk verify
path?

> +	    !rx->sk.sk_kern_sock)

[Severity: Medium]
With this exemption, RXRPC_MIN_SECURITY_LEVEL means different things
depending on sk_kern_sock. Is that split meant to be documented?

For userspace service sockets, the option now also rejects incoming
NONE calls.

For kernel sockets that use rxrpc_sock_set_min_security_level(), it is
still only the level used for outgoing client calls:

net/rxrpc/sendmsg.c:rxrpc_new_client_call_for_sendmsg() {
    ...
	cp.security_level	= rx->min_sec_level;
    ...
}

The in-tree kernel users already depend on this client-only meaning.
afs_open_socket() sets ENCRYPT on the CM service socket, and that socket
must accept unsecured fileserver callbacks:

fs/afs/rxrpc.c:afs_open_socket() {
    ...
	ret = rxrpc_sock_set_min_security_level(socket->sk,
						RXRPC_SECURITY_ENCRYPT);
    ...
}

rxperf does the same.

Documentation/networking/rxrpc.rst uses the same words for the sockopt
and for rxrpc_sock_set_min_security_level(): "the minimum security level
required for calls on this socket". It doesn't cover the new service
side enforcement or the kernel socket exemption.

A userspace program built like kAFS uses one socket to make encrypted
client calls and to accept unsecured callbacks. With this patch, its
incoming calls will be aborted.

It could bind a separate client socket to the same transport address as
a workaround. Existing programs would still break with no indication of
why.

Should Documentation/networking/rxrpc.rst be updated to describe this
behaviour?

> +		return NULL;

[Severity: Low]
The other two NULL returns in rxrpc_get_incoming_security() call
rxrpc_direct_conn_abort() with their own reason, but this one doesn't.
Will this rejection be traced as rxrpc_abort_service_not_offered?

The caller falls through to this code:

net/rxrpc/call_accept.c:rxrpc_new_incoming_call() {
    ...
unsupported_security:
	read_unlock_irq(&local->services_lock);
	return rxrpc_direct_conn_abort(skb, rxrpc_abort_service_not_offered,
				       RX_INVALID_OPERATION, -EKEYREJECTED);
    ...
}

So trace_rxrpc_abort reports "service not offered" even though the
service is bound and listening. The peer gets a generic
RX_INVALID_OPERATION abort.

This fallback in rxrpc_new_incoming_call() also overwrites the abort
codes set by the existing NULL paths in rxrpc_get_incoming_security().
That part is older than this patch.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126224137.55862-1-bugs%40stellman-greene.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-27 23:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 22:41 [PATCH net-next] rxrpc: Reject unsecured calls to userspace services with a minimum level Andrew Stellman
2026-11-27 23:24 ` netdev-bot+sashiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox