Skip to content

Commit c0428a2

Browse files
dhowellsgregkh
authored andcommitted
rxrpc: Fix conn-level packet handling to unshare RESPONSE packets
[ Upstream commit 24481a7 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 594973a commit c0428a2

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
@@ -226,6 +226,33 @@ static void rxrpc_call_is_secure(struct rxrpc_call *call)
226226
rxrpc_notify_socket(call);
227227
}
228228

229+
static int rxrpc_verify_response(struct rxrpc_connection *conn,
230+
struct sk_buff *skb)
231+
{
232+
int ret;
233+
234+
if (skb_cloned(skb)) {
235+
/* Copy the packet if shared so that we can do in-place
236+
* decryption.
237+
*/
238+
struct sk_buff *nskb = skb_copy(skb, GFP_NOFS);
239+
240+
if (nskb) {
241+
rxrpc_new_skb(nskb, rxrpc_skb_new_unshared);
242+
ret = conn->security->verify_response(conn, nskb);
243+
rxrpc_free_skb(nskb, rxrpc_skb_put_response_copy);
244+
} else {
245+
/* OOM - Drop the packet. */
246+
rxrpc_see_skb(skb, rxrpc_skb_see_unshare_nomem);
247+
ret = -ENOMEM;
248+
}
249+
} else {
250+
ret = conn->security->verify_response(conn, skb);
251+
}
252+
253+
return ret;
254+
}
255+
229256
/*
230257
* connection-level Rx packet processor
231258
*/
@@ -253,7 +280,7 @@ static int rxrpc_process_event(struct rxrpc_connection *conn,
253280
}
254281
spin_unlock(&conn->state_lock);
255282

256-
ret = conn->security->verify_response(conn, skb);
283+
ret = rxrpc_verify_response(conn, skb);
257284
if (ret < 0)
258285
return ret;
259286

0 commit comments

Comments
 (0)