Skip to content

Commit d10a26a

Browse files
sch-mPaolo Abeni
authored andcommitted
net/x25: Fix potential double free of skb
When alloc_skb fails in x25_queue_rx_frame it calls kfree_skb(skb) at line 48 and returns 1 (error). This error propagates back through the call chain: x25_queue_rx_frame returns 1 | v x25_state3_machine receives the return value 1 and takes the else branch at line 278, setting queued=0 and returning 0 | v x25_process_rx_frame returns queued=0 | v x25_backlog_rcv at line 452 sees queued=0 and calls kfree_skb(skb) again This would free the same skb twice. Looking at x25_backlog_rcv: net/x25/x25_in.c:x25_backlog_rcv() { ... queued = x25_process_rx_frame(sk, skb); ... if (!queued) kfree_skb(skb); } Fixes: 1da177e ("Linux-2.6.12-rc2") Signed-off-by: Martin Schiller <ms@dev.tdt.de> Link: https://patch.msgid.link/20260331-x25_fraglen-v4-1-3e69f18464b4@dev.tdt.de Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 9351edf commit d10a26a

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

net/x25/x25_in.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@ static int x25_queue_rx_frame(struct sock *sk, struct sk_buff *skb, int more)
4444
if (x25->fraglen > 0) { /* End of fragment */
4545
int len = x25->fraglen + skb->len;
4646

47-
if ((skbn = alloc_skb(len, GFP_ATOMIC)) == NULL){
48-
kfree_skb(skb);
47+
skbn = alloc_skb(len, GFP_ATOMIC);
48+
if (!skbn)
4949
return 1;
50-
}
5150

5251
skb_queue_tail(&x25->fragment_queue, skb);
5352

0 commit comments

Comments
 (0)