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/ipv6 | |
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/ipv6')
-rw-r--r-- | net/ipv6/ip6mr.c | 2 | ||||
-rw-r--r-- | net/ipv6/ipv6_sockglue.c | 6 | ||||
-rw-r--r-- | net/ipv6/raw.c | 6 | ||||
-rw-r--r-- | net/ipv6/udp.c | 4 | ||||
-rw-r--r-- | net/ipv6/udp_impl.h | 4 |
5 files changed, 11 insertions, 11 deletions
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index 090675e269ee..716153941fc4 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c | |||
@@ -1281,7 +1281,7 @@ int ip6mr_sk_done(struct sock *sk) | |||
1281 | * MOSPF/PIM router set up we can clean this up. | 1281 | * MOSPF/PIM router set up we can clean this up. |
1282 | */ | 1282 | */ |
1283 | 1283 | ||
1284 | int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, int optlen) | 1284 | int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, unsigned int optlen) |
1285 | { | 1285 | { |
1286 | int ret; | 1286 | int ret; |
1287 | struct mif6ctl vif; | 1287 | struct mif6ctl vif; |
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index f5e0682b402d..14f54eb5a7fc 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c | |||
@@ -123,7 +123,7 @@ struct ipv6_txoptions *ipv6_update_options(struct sock *sk, | |||
123 | } | 123 | } |
124 | 124 | ||
125 | static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, | 125 | static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, |
126 | char __user *optval, int optlen) | 126 | char __user *optval, unsigned int optlen) |
127 | { | 127 | { |
128 | struct ipv6_pinfo *np = inet6_sk(sk); | 128 | struct ipv6_pinfo *np = inet6_sk(sk); |
129 | struct net *net = sock_net(sk); | 129 | struct net *net = sock_net(sk); |
@@ -773,7 +773,7 @@ e_inval: | |||
773 | } | 773 | } |
774 | 774 | ||
775 | int ipv6_setsockopt(struct sock *sk, int level, int optname, | 775 | int ipv6_setsockopt(struct sock *sk, int level, int optname, |
776 | char __user *optval, int optlen) | 776 | char __user *optval, unsigned int optlen) |
777 | { | 777 | { |
778 | int err; | 778 | int err; |
779 | 779 | ||
@@ -801,7 +801,7 @@ EXPORT_SYMBOL(ipv6_setsockopt); | |||
801 | 801 | ||
802 | #ifdef CONFIG_COMPAT | 802 | #ifdef CONFIG_COMPAT |
803 | int compat_ipv6_setsockopt(struct sock *sk, int level, int optname, | 803 | int compat_ipv6_setsockopt(struct sock *sk, int level, int optname, |
804 | char __user *optval, int optlen) | 804 | char __user *optval, unsigned int optlen) |
805 | { | 805 | { |
806 | int err; | 806 | int err; |
807 | 807 | ||
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index 7d675b8d82d3..4f24570b0869 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c | |||
@@ -957,7 +957,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname, | |||
957 | 957 | ||
958 | 958 | ||
959 | static int do_rawv6_setsockopt(struct sock *sk, int level, int optname, | 959 | static int do_rawv6_setsockopt(struct sock *sk, int level, int optname, |
960 | char __user *optval, int optlen) | 960 | char __user *optval, unsigned int optlen) |
961 | { | 961 | { |
962 | struct raw6_sock *rp = raw6_sk(sk); | 962 | struct raw6_sock *rp = raw6_sk(sk); |
963 | int val; | 963 | int val; |
@@ -1000,7 +1000,7 @@ static int do_rawv6_setsockopt(struct sock *sk, int level, int optname, | |||
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | static int rawv6_setsockopt(struct sock *sk, int level, int optname, | 1002 | static int rawv6_setsockopt(struct sock *sk, int level, int optname, |
1003 | char __user *optval, int optlen) | 1003 | char __user *optval, unsigned int optlen) |
1004 | { | 1004 | { |
1005 | switch(level) { | 1005 | switch(level) { |
1006 | case SOL_RAW: | 1006 | case SOL_RAW: |
@@ -1024,7 +1024,7 @@ static int rawv6_setsockopt(struct sock *sk, int level, int optname, | |||
1024 | 1024 | ||
1025 | #ifdef CONFIG_COMPAT | 1025 | #ifdef CONFIG_COMPAT |
1026 | static int compat_rawv6_setsockopt(struct sock *sk, int level, int optname, | 1026 | static int compat_rawv6_setsockopt(struct sock *sk, int level, int optname, |
1027 | char __user *optval, int optlen) | 1027 | char __user *optval, unsigned int optlen) |
1028 | { | 1028 | { |
1029 | switch (level) { | 1029 | switch (level) { |
1030 | case SOL_RAW: | 1030 | case SOL_RAW: |
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index b265b7047d3e..3a60f12b34ed 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c | |||
@@ -1044,7 +1044,7 @@ void udpv6_destroy_sock(struct sock *sk) | |||
1044 | * Socket option code for UDP | 1044 | * Socket option code for UDP |
1045 | */ | 1045 | */ |
1046 | int udpv6_setsockopt(struct sock *sk, int level, int optname, | 1046 | int udpv6_setsockopt(struct sock *sk, int level, int optname, |
1047 | char __user *optval, int optlen) | 1047 | char __user *optval, unsigned int optlen) |
1048 | { | 1048 | { |
1049 | if (level == SOL_UDP || level == SOL_UDPLITE) | 1049 | if (level == SOL_UDP || level == SOL_UDPLITE) |
1050 | return udp_lib_setsockopt(sk, level, optname, optval, optlen, | 1050 | return udp_lib_setsockopt(sk, level, optname, optval, optlen, |
@@ -1054,7 +1054,7 @@ int udpv6_setsockopt(struct sock *sk, int level, int optname, | |||
1054 | 1054 | ||
1055 | #ifdef CONFIG_COMPAT | 1055 | #ifdef CONFIG_COMPAT |
1056 | int compat_udpv6_setsockopt(struct sock *sk, int level, int optname, | 1056 | int compat_udpv6_setsockopt(struct sock *sk, int level, int optname, |
1057 | char __user *optval, int optlen) | 1057 | char __user *optval, unsigned int optlen) |
1058 | { | 1058 | { |
1059 | if (level == SOL_UDP || level == SOL_UDPLITE) | 1059 | if (level == SOL_UDP || level == SOL_UDPLITE) |
1060 | return udp_lib_setsockopt(sk, level, optname, optval, optlen, | 1060 | return udp_lib_setsockopt(sk, level, optname, optval, optlen, |
diff --git a/net/ipv6/udp_impl.h b/net/ipv6/udp_impl.h index 6bb303471e20..d7571046bfc4 100644 --- a/net/ipv6/udp_impl.h +++ b/net/ipv6/udp_impl.h | |||
@@ -16,10 +16,10 @@ extern int udp_v6_get_port(struct sock *sk, unsigned short snum); | |||
16 | extern int udpv6_getsockopt(struct sock *sk, int level, int optname, | 16 | extern int udpv6_getsockopt(struct sock *sk, int level, int optname, |
17 | char __user *optval, int __user *optlen); | 17 | char __user *optval, int __user *optlen); |
18 | extern int udpv6_setsockopt(struct sock *sk, int level, int optname, | 18 | extern int udpv6_setsockopt(struct sock *sk, int level, int optname, |
19 | char __user *optval, int optlen); | 19 | char __user *optval, unsigned int optlen); |
20 | #ifdef CONFIG_COMPAT | 20 | #ifdef CONFIG_COMPAT |
21 | extern int compat_udpv6_setsockopt(struct sock *sk, int level, int optname, | 21 | extern int compat_udpv6_setsockopt(struct sock *sk, int level, int optname, |
22 | char __user *optval, int optlen); | 22 | char __user *optval, unsigned int optlen); |
23 | extern int compat_udpv6_getsockopt(struct sock *sk, int level, int optname, | 23 | extern int compat_udpv6_getsockopt(struct sock *sk, int level, int optname, |
24 | char __user *optval, int __user *optlen); | 24 | char __user *optval, int __user *optlen); |
25 | #endif | 25 | #endif |