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/core/sock.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/core/sock.c')
-rw-r--r-- | net/core/sock.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/net/core/sock.c b/net/core/sock.c index 524712a7b154..77fbfed332e8 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -446,7 +446,7 @@ static inline void sock_valbool_flag(struct sock *sk, int bit, int valbool) | |||
446 | */ | 446 | */ |
447 | 447 | ||
448 | int sock_setsockopt(struct socket *sock, int level, int optname, | 448 | int sock_setsockopt(struct socket *sock, int level, int optname, |
449 | char __user *optval, int optlen) | 449 | char __user *optval, unsigned int optlen) |
450 | { | 450 | { |
451 | struct sock *sk = sock->sk; | 451 | struct sock *sk = sock->sk; |
452 | int val; | 452 | int val; |
@@ -1697,7 +1697,7 @@ int sock_no_shutdown(struct socket *sock, int how) | |||
1697 | EXPORT_SYMBOL(sock_no_shutdown); | 1697 | EXPORT_SYMBOL(sock_no_shutdown); |
1698 | 1698 | ||
1699 | int sock_no_setsockopt(struct socket *sock, int level, int optname, | 1699 | int sock_no_setsockopt(struct socket *sock, int level, int optname, |
1700 | char __user *optval, int optlen) | 1700 | char __user *optval, unsigned int optlen) |
1701 | { | 1701 | { |
1702 | return -EOPNOTSUPP; | 1702 | return -EOPNOTSUPP; |
1703 | } | 1703 | } |
@@ -2018,7 +2018,7 @@ EXPORT_SYMBOL(sock_common_recvmsg); | |||
2018 | * Set socket options on an inet socket. | 2018 | * Set socket options on an inet socket. |
2019 | */ | 2019 | */ |
2020 | int sock_common_setsockopt(struct socket *sock, int level, int optname, | 2020 | int sock_common_setsockopt(struct socket *sock, int level, int optname, |
2021 | char __user *optval, int optlen) | 2021 | char __user *optval, unsigned int optlen) |
2022 | { | 2022 | { |
2023 | struct sock *sk = sock->sk; | 2023 | struct sock *sk = sock->sk; |
2024 | 2024 | ||
@@ -2028,7 +2028,7 @@ EXPORT_SYMBOL(sock_common_setsockopt); | |||
2028 | 2028 | ||
2029 | #ifdef CONFIG_COMPAT | 2029 | #ifdef CONFIG_COMPAT |
2030 | int compat_sock_common_setsockopt(struct socket *sock, int level, int optname, | 2030 | int compat_sock_common_setsockopt(struct socket *sock, int level, int optname, |
2031 | char __user *optval, int optlen) | 2031 | char __user *optval, unsigned int optlen) |
2032 | { | 2032 | { |
2033 | struct sock *sk = sock->sk; | 2033 | struct sock *sk = sock->sk; |
2034 | 2034 | ||