# Re: \[PATCH net v7 00/11\] rxrpc: Fix CHALLENGE packet handling

- From: David Howells \<dhowells@redhat.com\>
- Date: 2026-08-18 14:49:21 
- List: netdev
- Page: https://ratatoskr.run/netdev/2026/08/17429587
- Thread: https://ratatoskr.run/netdev/2026/08/17401429/t.md

```text
David Howells [ref] wrote:

> 
>  (2) I should probably require READ permission on the key holding the appdata
>      provided by usespace through RXRPC_RESPONSE_APPDATA rather than SEARCH
>      permission to prevent this being used to pull the data out of keys that
>      can't otherwise read directly with keyctl().
> 
> I can fix both of these with follow-up single line fix patches or (2) could
> be fixed in place at the point of application:
> 
> --- a/net/rxrpc/sendmsg.c
> +++ b/net/rxrpc/sendmsg.c
> @@ -640,7 +640,7 @@ static int rxrpc_sendmsg_cmsg(struct msghdr *msg, struct rxrpc_send_params *p)
>  			if (p->call.app_data)
>  				return -EINVAL;
>  			key_id = *(key_serial_t *)CMSG_DATA(cmsg);
> -			key = lookup_user_key(key_id, 0, KEY_NEED_SEARCH);
> +			key = lookup_user_key(key_id, 0, KEY_NEED_READ);
>  			if (IS_ERR(key))
>  				return PTR_ERR(key);
>  			if (key_ref_to_ptr(key)->type != &key_type_user &&

Actually, there's a better way to do this, and that's to check the prefix on
the key description.  See attached patch.

David
---
commit 6d456b373d5c7cf2c1c9f5ead0e563c75e739442
Author: David Howells [ref]
Date:   Tue Aug 18 14:30:37 2026 +0100

    rxrpc: Fix user appdata key check
    
    The check made by rxrpc_sendmsg_cmsg() for RXRPC_RESPONSE_APPDATA on the
    key it retrieves allows keys to be accessed by generating
    CHALLENGE/RESPONSE exchange.  Currently, any user or logon key can be
    accessed in this manner.  Fix this by restricting the patch description to
    require a prefix of "rxrpc-appdata:".
    
    Fixes: xxxxxxxxxxxx ("rxrpc: Fix CHALLENGE packet overqueuing and simplify RESPONSE generation")
    Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260812110129.979970-6-dhowells@redhat.com
    Signed-off-by: David Howells [ref]
    cc: Marc Dionne [ref]
    cc: Jeffrey Altman [ref]
    cc: Eric Dumazet [ref]
    cc: "David S. Miller" [ref]
    cc: Jakub Kicinski [ref]
    cc: Paolo Abeni [ref]
    cc: Simon Horman [ref]
    cc: Jarkko Sakkinen [ref]
    cc: linux-afs@lists.infradead.org
    cc: keyrings@vger.kernel.org
    cc: stable@kernel.org

diff --git a/net/rxrpc/sendmsg.c b/net/rxrpc/sendmsg.c
index 4755fc76d8f3..eb3dc352684e 100644
--- a/net/rxrpc/sendmsg.c
+++ b/net/rxrpc/sendmsg.c
@@ -648,6 +648,13 @@ static int rxrpc_sendmsg_cmsg(struct msghdr *msg, struct rxrpc_send_params *p)
 				key_ref_put(key);
 				return -EINVAL;
 			}
+			if (!key_ref_to_ptr(key)->description ||
+			    strncmp(key_ref_to_ptr(key)->description,
+				    "rxrpc-appdata:", 14) != 0) {
+				key_ref_put(key);
+				return -EINVAL;
+			}
+				
 			p->call.app_data = key_ref_to_ptr(key);
 			break;
 
```
