Skip to content

Commit 3bbf629

Browse files
authored
Merge pull request #55 from longsleep/backport_fix-cve-2017-7308
Backport fix CVE-2017-7308
2 parents 26ca488 + 5b10a45 commit 3bbf629

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

net/packet/af_packet.c

Lines changed: 6 additions & 2 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
}
@@ -3651,8 +3653,8 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,
36513653
if (unlikely(req->tp_block_size & (PAGE_SIZE - 1)))
36523654
goto out;
36533655
if (po->tp_version >= TPACKET_V3 &&
3654-
(int)(req->tp_block_size -
3655-
BLK_PLUS_PRIV(req_u->req3.tp_sizeof_priv)) <= 0)
3656+
req->tp_block_size <=
3657+
BLK_PLUS_PRIV((u64)req_u->req3.tp_sizeof_priv))
36563658
goto out;
36573659
if (unlikely(req->tp_frame_size < po->tp_hdrlen +
36583660
po->tp_reserve))
@@ -3663,6 +3665,8 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,
36633665
rb->frames_per_block = req->tp_block_size/req->tp_frame_size;
36643666
if (unlikely(rb->frames_per_block <= 0))
36653667
goto out;
3668+
if (unlikely(req->tp_block_size > UINT_MAX / req->tp_block_nr))
3669+
goto out;
36663670
if (unlikely((rb->frames_per_block * req->tp_block_nr) !=
36673671
req->tp_frame_nr))
36683672
goto out;

0 commit comments

Comments
 (0)