Skip to content

Commit 24481a7

Browse files
dhowellskuba-moo
authored andcommitted
rxrpc: Fix conn-level packet handling to unshare RESPONSE packets
The security operations that verify the RESPONSE packets decrypt bits of it in place - however, the sk_buff may be shared with a packet sniffer, which would lead to the sniffer seeing an apparently corrupt packet (actually decrypted). Fix this by handing a copy of the packet off to the specific security handler if the packet was cloned. Fixes: 17926a7 ("[AF_RXRPC]: Provide secure RxRPC sockets for use by userspace and kernel both") Closes: https://sashiko.dev/#/patchset/20260408121252.2249051-1-dhowells%40redhat.com Signed-off-by: David Howells <dhowells@redhat.com> cc: Marc Dionne <marc.dionne@auristor.com> cc: Jeffrey Altman <jaltman@auristor.com> cc: Simon Horman <horms@kernel.org> cc: linux-afs@lists.infradead.org cc: stable@kernel.org Link: https://patch.msgid.link/20260422161438.2593376-5-dhowells@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 1f27401 commit 24481a7

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

net/rxrpc/conn_event.c

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,33 @@ static void rxrpc_call_is_secure(struct rxrpc_call *call)
240240
rxrpc_notify_socket(call);
241241
}
242242

243+
static int rxrpc_verify_response(struct rxrpc_connection *conn,
244+
struct sk_buff *skb)
245+
{
246+
int ret;
247+
248+
if (skb_cloned(skb)) {
249+
/* Copy the packet if shared so that we can do in-place
250+
* decryption.
251+
*/
252+
struct sk_buff *nskb = skb_copy(skb, GFP_NOFS);
253+
254+
if (nskb) {
255+
rxrpc_new_skb(nskb, rxrpc_skb_new_unshared);
256+
ret = conn->security->verify_response(conn, nskb);
257+
rxrpc_free_skb(nskb, rxrpc_skb_put_response_copy);
258+
} else {
259+
/* OOM - Drop the packet. */
260+
rxrpc_see_skb(skb, rxrpc_skb_see_unshare_nomem);
261+
ret = -ENOMEM;
262+
}
263+
} else {
264+
ret = conn->security->verify_response(conn, skb);
265+
}
266+
267+
return ret;
268+
}
269+
243270
/*
244271
* connection-level Rx packet processor
245272
*/
@@ -270,7 +297,7 @@ static int rxrpc_process_event(struct rxrpc_connection *conn,
270297
}
271298
spin_unlock_irq(&conn->state_lock);
272299

273-
ret = conn->security->verify_response(conn, skb);
300+
ret = rxrpc_verify_response(conn, skb);
274301
if (ret < 0)
275302
return ret;
276303

0 commit comments

Comments
 (0)