Skip to content

Commit 5b10a45

Browse files
xairylongsleep
authored andcommitted
net/packet: fix overflow in check for tp_reserve
When calculating po->tp_hdrlen + po->tp_reserve the result can overflow. Fix by checking that tp_reserve <= INT_MAX on assign. Signed-off-by: Andrey Konovalov <[email protected]> Acked-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ddbcbab commit 5b10a45

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

net/packet/af_packet.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3165,6 +3165,8 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv
31653165
return -EBUSY;
31663166
if (copy_from_user(&val, optval, sizeof(val)))
31673167
return -EFAULT;
3168+
if (val > INT_MAX)
3169+
return -EINVAL;
31683170
po->tp_reserve = val;
31693171
return 0;
31703172
}

0 commit comments

Comments
 (0)