Skip to content

Commit d9bf5f1

Browse files
Weiping Pandavem330
authored andcommitted
tun: compare with 0 instead of total_len
Since we set "len = total_len" in the beginning of tun_get_user(), so we should compare the new len with 0, instead of total_len, or the if statement always returns false. Signed-off-by: Weiping Pan <wpan@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 3e805ad commit d9bf5f1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/net/tun.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
10741074
u32 rxhash;
10751075

10761076
if (!(tun->flags & TUN_NO_PI)) {
1077-
if ((len -= sizeof(pi)) > total_len)
1077+
if ((len -= sizeof(pi)) < 0)
10781078
return -EINVAL;
10791079

10801080
if (memcpy_fromiovecend((void *)&pi, iv, 0, sizeof(pi)))
@@ -1083,7 +1083,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
10831083
}
10841084

10851085
if (tun->flags & TUN_VNET_HDR) {
1086-
if ((len -= tun->vnet_hdr_sz) > total_len)
1086+
if ((len -= tun->vnet_hdr_sz) < 0)
10871087
return -EINVAL;
10881088

10891089
if (memcpy_fromiovecend((void *)&gso, iv, offset, sizeof(gso)))

0 commit comments

Comments
 (0)