Skip to content

Commit 9371937

Browse files
Dan Carpenterdavem330
authored andcommitted
ax25: uninitialized variable in ax25_setsockopt()
The "opt" variable is unsigned long but we only copy 4 bytes from the user so the lower 4 bytes are uninitialized. I have changed the integer overflow checks from ULONG to UINT as well. This is a slight API change but I don't expect it to break anything. Fixes: a7b75c5 ("net: pass a sockptr_t into ->setsockopt") Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b69c5b5 commit 9371937

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

net/ax25/af_ax25.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ static int ax25_setsockopt(struct socket *sock, int level, int optname,
536536
ax25_cb *ax25;
537537
struct net_device *dev;
538538
char devname[IFNAMSIZ];
539-
unsigned long opt;
539+
unsigned int opt;
540540
int res = 0;
541541

542542
if (level != SOL_AX25)
@@ -568,7 +568,7 @@ static int ax25_setsockopt(struct socket *sock, int level, int optname,
568568
break;
569569

570570
case AX25_T1:
571-
if (opt < 1 || opt > ULONG_MAX / HZ) {
571+
if (opt < 1 || opt > UINT_MAX / HZ) {
572572
res = -EINVAL;
573573
break;
574574
}
@@ -577,7 +577,7 @@ static int ax25_setsockopt(struct socket *sock, int level, int optname,
577577
break;
578578

579579
case AX25_T2:
580-
if (opt < 1 || opt > ULONG_MAX / HZ) {
580+
if (opt < 1 || opt > UINT_MAX / HZ) {
581581
res = -EINVAL;
582582
break;
583583
}
@@ -593,15 +593,15 @@ static int ax25_setsockopt(struct socket *sock, int level, int optname,
593593
break;
594594

595595
case AX25_T3:
596-
if (opt < 1 || opt > ULONG_MAX / HZ) {
596+
if (opt < 1 || opt > UINT_MAX / HZ) {
597597
res = -EINVAL;
598598
break;
599599
}
600600
ax25->t3 = opt * HZ;
601601
break;
602602

603603
case AX25_IDLE:
604-
if (opt > ULONG_MAX / (60 * HZ)) {
604+
if (opt > UINT_MAX / (60 * HZ)) {
605605
res = -EINVAL;
606606
break;
607607
}

0 commit comments

Comments
 (0)