rxrpc: Reject unsecured calls to userspace services with a minimum level
Subsystems (3)
PATCH 1/1 rxrpc: Reject unsecured calls to userspace services with a minimum level
From: Andrew Stellman <[email protected]>
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.
---
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(+)
net/rxrpc/security.c +5 -0
@@ -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,
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider.
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.
Quoted 1 line
Signed-off-by Andrew Stellman <[email protected]>
[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?
net/rxrpc/security.c const struct rxrpc_security *rxrpc_get_incoming_security(struct rxrpc_sock *rx, · line 142
Quoted 10 lines
net/rxrpc/security.c +2
-0@@ -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?
net/rxrpc/security.c const struct rxrpc_security *rxrpc_get_incoming_security(struct rxrpc_sock *rx, · line 143
Quoted 1 line
net/rxrpc/security.c +1
-0+ !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?
net/rxrpc/security.c const struct rxrpc_security *rxrpc_get_incoming_security(struct rxrpc_sock *rx, · line 144
Quoted 1 line
net/rxrpc/security.c +1
-0+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.
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126224137.55862-1-bugs%40stellman-greene.com
Thanks. The High and Medium points are fair.
High: I left rxkad and rxgk out and mentioned it below the ---. A v2 can check the negotiated level against min_sec_level in rxkad_verify_response() and the rxgk verify path too.
Medium: right, kAFS sets ENCRYPT on its CM socket, which also takes callbacks, so for kernel sockets the option only governs outgoing calls. A userspace program built the same way would have its incoming unsecured calls rejected by this patch.
David, which would you prefer: enforce the minimum on incoming calls for userspace service sockets (NONE, rxkad and rxgk, with its own abort reason, a Fixes: tag and a rxrpc.rst update), or document RXRPC_MIN_SECURITY_LEVEL as applying to outgoing calls only? I'll send a v2 either way.
pw-bot: cr