* [PATCH -next] netrom: avoid overflows in nr_setsockopt()
@ 2011-12-27 19:44 Xi Wang
2011-12-28 19:08 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Xi Wang @ 2011-12-27 19:44 UTC (permalink / raw)
To: linux-hams; +Cc: David S. Miller, netdev, Ralf Baechle, Xi Wang
Check setsockopt arguments to avoid overflows and return -EINVAL for
too large arguments.
Signed-off-by: Xi Wang <xi.wang@gmail.com>
---
net/netrom/af_netrom.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
index c329b47..7dab229 100644
--- a/net/netrom/af_netrom.c
+++ b/net/netrom/af_netrom.c
@@ -306,26 +306,26 @@ static int nr_setsockopt(struct socket *sock, int level, int optname,
{
struct sock *sk = sock->sk;
struct nr_sock *nr = nr_sk(sk);
- int opt;
+ unsigned long opt;
if (level != SOL_NETROM)
return -ENOPROTOOPT;
- if (optlen < sizeof(int))
+ if (optlen < sizeof(unsigned int))
return -EINVAL;
- if (get_user(opt, (int __user *)optval))
+ if (get_user(opt, (unsigned int __user *)optval))
return -EFAULT;
switch (optname) {
case NETROM_T1:
- if (opt < 1)
+ if (opt < 1 || opt > ULONG_MAX / HZ)
return -EINVAL;
nr->t1 = opt * HZ;
return 0;
case NETROM_T2:
- if (opt < 1)
+ if (opt < 1 || opt > ULONG_MAX / HZ)
return -EINVAL;
nr->t2 = opt * HZ;
return 0;
@@ -337,13 +337,13 @@ static int nr_setsockopt(struct socket *sock, int level, int optname,
return 0;
case NETROM_T4:
- if (opt < 1)
+ if (opt < 1 || opt > ULONG_MAX / HZ)
return -EINVAL;
nr->t4 = opt * HZ;
return 0;
case NETROM_IDLE:
- if (opt < 0)
+ if (opt > ULONG_MAX / (60 * HZ))
return -EINVAL;
nr->idle = opt * 60 * HZ;
return 0;
--
1.7.5.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH -next] netrom: avoid overflows in nr_setsockopt()
2011-12-27 19:44 [PATCH -next] netrom: avoid overflows in nr_setsockopt() Xi Wang
@ 2011-12-28 19:08 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2011-12-28 19:08 UTC (permalink / raw)
To: xi.wang; +Cc: linux-hams, netdev, ralf
From: Xi Wang <xi.wang@gmail.com>
Date: Tue, 27 Dec 2011 14:44:53 -0500
> Check setsockopt arguments to avoid overflows and return -EINVAL for
> too large arguments.
>
> Signed-off-by: Xi Wang <xi.wang@gmail.com>
Applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-12-28 19:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-27 19:44 [PATCH -next] netrom: avoid overflows in nr_setsockopt() Xi Wang
2011-12-28 19:08 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox