aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2009-09-30 19:12:20 -0400
committerDavid S. Miller <davem@davemloft.net>2009-09-30 19:12:20 -0400
commitb7058842c940ad2c08dd829b21e5c92ebe3b8758 (patch)
tree5fe78d599fc345ca0bcd4b083b79095a54b2921b /net/ipv4/tcp.c
parenteb1cf0f8f7a9e5a6d573d5bd72c015686a042db0 (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/ipv4/tcp.c')
-rw-r--r--net/ipv4/tcp.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 21387ebabf00..5a15e7629d8e 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2032,7 +2032,7 @@ int tcp_disconnect(struct sock *sk, int flags)
2032 * Socket option code for TCP. 2032 * Socket option code for TCP.
2033 */ 2033 */
2034static int do_tcp_setsockopt(struct sock *sk, int level, 2034static int do_tcp_setsockopt(struct sock *sk, int level,
2035 int optname, char __user *optval, int optlen) 2035 int optname, char __user *optval, unsigned int optlen)
2036{ 2036{
2037 struct tcp_sock *tp = tcp_sk(sk); 2037 struct tcp_sock *tp = tcp_sk(sk);
2038 struct inet_connection_sock *icsk = inet_csk(sk); 2038 struct inet_connection_sock *icsk = inet_csk(sk);
@@ -2220,7 +2220,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
2220} 2220}
2221 2221
2222int tcp_setsockopt(struct sock *sk, int level, int optname, char __user *optval, 2222int tcp_setsockopt(struct sock *sk, int level, int optname, char __user *optval,
2223 int optlen) 2223 unsigned int optlen)
2224{ 2224{
2225 struct inet_connection_sock *icsk = inet_csk(sk); 2225 struct inet_connection_sock *icsk = inet_csk(sk);
2226 2226
@@ -2232,7 +2232,7 @@ int tcp_setsockopt(struct sock *sk, int level, int optname, char __user *optval,
2232 2232
2233#ifdef CONFIG_COMPAT 2233#ifdef CONFIG_COMPAT
2234int compat_tcp_setsockopt(struct sock *sk, int level, int optname, 2234int compat_tcp_setsockopt(struct sock *sk, int level, int optname,
2235 char __user *optval, int optlen) 2235 char __user *optval, unsigned int optlen)
2236{ 2236{
2237 if (level != SOL_TCP) 2237 if (level != SOL_TCP)
2238 return inet_csk_compat_setsockopt(sk, level, optname, 2238 return inet_csk_compat_setsockopt(sk, level, optname,