diff options
author | David S. Miller <davem@davemloft.net> | 2009-09-30 19:12:20 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-09-30 19:12:20 -0400 |
commit | b7058842c940ad2c08dd829b21e5c92ebe3b8758 (patch) | |
tree | 5fe78d599fc345ca0bcd4b083b79095a54b2921b /net/compat.c | |
parent | eb1cf0f8f7a9e5a6d573d5bd72c015686a042db0 (diff) |
net: Make setsockopt() optlen be unsigned.
This provides safety against negative optlen at the type
level instead of depending upon (sometimes non-trivial)
checks against this sprinkled all over the the place, in
each and every implementation.
Based upon work done by Arjan van de Ven and feedback
from Linus Torvalds.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/compat.c')
-rw-r--r-- | net/compat.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/net/compat.c b/net/compat.c index 12728b17a226..a407c3addbae 100644 --- a/net/compat.c +++ b/net/compat.c | |||
@@ -331,7 +331,7 @@ struct compat_sock_fprog { | |||
331 | }; | 331 | }; |
332 | 332 | ||
333 | static int do_set_attach_filter(struct socket *sock, int level, int optname, | 333 | static int do_set_attach_filter(struct socket *sock, int level, int optname, |
334 | char __user *optval, int optlen) | 334 | char __user *optval, unsigned int optlen) |
335 | { | 335 | { |
336 | struct compat_sock_fprog __user *fprog32 = (struct compat_sock_fprog __user *)optval; | 336 | struct compat_sock_fprog __user *fprog32 = (struct compat_sock_fprog __user *)optval; |
337 | struct sock_fprog __user *kfprog = compat_alloc_user_space(sizeof(struct sock_fprog)); | 337 | struct sock_fprog __user *kfprog = compat_alloc_user_space(sizeof(struct sock_fprog)); |
@@ -351,7 +351,7 @@ static int do_set_attach_filter(struct socket *sock, int level, int optname, | |||
351 | } | 351 | } |
352 | 352 | ||
353 | static int do_set_sock_timeout(struct socket *sock, int level, | 353 | static int do_set_sock_timeout(struct socket *sock, int level, |
354 | int optname, char __user *optval, int optlen) | 354 | int optname, char __user *optval, unsigned int optlen) |
355 | { | 355 | { |
356 | struct compat_timeval __user *up = (struct compat_timeval __user *) optval; | 356 | struct compat_timeval __user *up = (struct compat_timeval __user *) optval; |
357 | struct timeval ktime; | 357 | struct timeval ktime; |
@@ -373,7 +373,7 @@ static int do_set_sock_timeout(struct socket *sock, int level, | |||
373 | } | 373 | } |
374 | 374 | ||
375 | static int compat_sock_setsockopt(struct socket *sock, int level, int optname, | 375 | static int compat_sock_setsockopt(struct socket *sock, int level, int optname, |
376 | char __user *optval, int optlen) | 376 | char __user *optval, unsigned int optlen) |
377 | { | 377 | { |
378 | if (optname == SO_ATTACH_FILTER) | 378 | if (optname == SO_ATTACH_FILTER) |
379 | return do_set_attach_filter(sock, level, optname, | 379 | return do_set_attach_filter(sock, level, optname, |
@@ -385,7 +385,7 @@ static int compat_sock_setsockopt(struct socket *sock, int level, int optname, | |||
385 | } | 385 | } |
386 | 386 | ||
387 | asmlinkage long compat_sys_setsockopt(int fd, int level, int optname, | 387 | asmlinkage long compat_sys_setsockopt(int fd, int level, int optname, |
388 | char __user *optval, int optlen) | 388 | char __user *optval, unsigned int optlen) |
389 | { | 389 | { |
390 | int err; | 390 | int err; |
391 | struct socket *sock; | 391 | struct socket *sock; |
@@ -558,8 +558,8 @@ struct compat_group_filter { | |||
558 | 558 | ||
559 | 559 | ||
560 | int compat_mc_setsockopt(struct sock *sock, int level, int optname, | 560 | int compat_mc_setsockopt(struct sock *sock, int level, int optname, |
561 | char __user *optval, int optlen, | 561 | char __user *optval, unsigned int optlen, |
562 | int (*setsockopt)(struct sock *,int,int,char __user *,int)) | 562 | int (*setsockopt)(struct sock *,int,int,char __user *,unsigned int)) |
563 | { | 563 | { |
564 | char __user *koptval = optval; | 564 | char __user *koptval = optval; |
565 | int koptlen = optlen; | 565 | int koptlen = optlen; |