Skip to content

Commit a1822cb

Browse files
sch-mPaolo Abeni
authored andcommitted
net/x25: Fix overflow when accumulating packets
Add a check to ensure that `x25_sock.fraglen` does not overflow. The `fraglen` also needs to be resetted when purging `fragment_queue` in `x25_clear_queues()`. Fixes: 1da177e ("Linux-2.6.12-rc2") Suggested-by: Yiming Qian <[email protected]> Signed-off-by: Martin Schiller <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent d10a26a commit a1822cb

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

net/x25/x25_in.c

Lines changed: 4 additions & 0 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);

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)