Skip to content

Commit a80a014

Browse files
author
Paolo Abeni
committed
Merge branch 'net-x25-fix-overflow-and-double-free'
Martin Schiller says: ==================== net/x25: Fix overflow and double free This patch set includes 2 fixes: The first removes a potential double free of received skb The second fixes an overflow when accumulating packets with the more-bit set. Signed-off-by: Martin Schiller <ms@dev.tdt.de> ==================== Link: https://patch.msgid.link/20260331-x25_fraglen-v4-0-3e69f18464b4@dev.tdt.de Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2 parents 9351edf + a1822cb commit a80a014

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

net/x25/x25_in.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ static int x25_queue_rx_frame(struct sock *sk, struct sk_buff *skb, int more)
3434
struct sk_buff *skbo, *skbn = skb;
3535
struct x25_sock *x25 = x25_sk(sk);
3636

37+
/* make sure we don't overflow */
38+
if (x25->fraglen + skb->len > USHRT_MAX)
39+
return 1;
40+
3741
if (more) {
3842
x25->fraglen += skb->len;
3943
skb_queue_tail(&x25->fragment_queue, skb);
@@ -44,10 +48,9 @@ static int x25_queue_rx_frame(struct sock *sk, struct sk_buff *skb, int more)
4448
if (x25->fraglen > 0) { /* End of fragment */
4549
int len = x25->fraglen + skb->len;
4650

47-
if ((skbn = alloc_skb(len, GFP_ATOMIC)) == NULL){
48-
kfree_skb(skb);
51+
skbn = alloc_skb(len, GFP_ATOMIC);
52+
if (!skbn)
4953
return 1;
50-
}
5154

5255
skb_queue_tail(&x25->fragment_queue, skb);
5356

net/x25/x25_subr.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ void x25_clear_queues(struct sock *sk)
4040
skb_queue_purge(&x25->interrupt_in_queue);
4141
skb_queue_purge(&x25->interrupt_out_queue);
4242
skb_queue_purge(&x25->fragment_queue);
43+
x25->fraglen = 0;
4344
}
4445

4546

0 commit comments

Comments
 (0)