aboutsummaryrefslogtreecommitdiffstats
path: root/include/net
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 /include/net
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 'include/net')
-rw-r--r--include/net/compat.h4
-rw-r--r--include/net/inet_connection_sock.h6
-rw-r--r--include/net/ip.h4
-rw-r--r--include/net/ipv6.h4
-rw-r--r--include/net/sctp/structs.h4
-rw-r--r--include/net/sock.h12
-rw-r--r--include/net/tcp.h4
-rw-r--r--include/net/udp.h2
8 files changed, 20 insertions, 20 deletions
diff --git a/include/net/compat.h b/include/net/compat.h
index 5bbf8bf9efea..7c3002832d05 100644
--- a/include/net/compat.h
+++ b/include/net/compat.h
@@ -40,8 +40,8 @@ extern int put_cmsg_compat(struct msghdr*, int, int, int, void *);
40 40
41extern int cmsghdr_from_user_compat_to_kern(struct msghdr *, struct sock *, unsigned char *, int); 41extern int cmsghdr_from_user_compat_to_kern(struct msghdr *, struct sock *, unsigned char *, int);
42 42
43extern int compat_mc_setsockopt(struct sock *, int, int, char __user *, int, 43extern int compat_mc_setsockopt(struct sock *, int, int, char __user *, unsigned int,
44 int (*)(struct sock *, int, int, char __user *, int)); 44 int (*)(struct sock *, int, int, char __user *, unsigned int));
45extern int compat_mc_getsockopt(struct sock *, int, int, char __user *, 45extern int compat_mc_getsockopt(struct sock *, int, int, char __user *,
46 int __user *, int (*)(struct sock *, int, int, char __user *, 46 int __user *, int (*)(struct sock *, int, int, char __user *,
47 int __user *)); 47 int __user *));
diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
index 03cffd9f64e3..696d6e4ce68a 100644
--- a/include/net/inet_connection_sock.h
+++ b/include/net/inet_connection_sock.h
@@ -48,13 +48,13 @@ struct inet_connection_sock_af_ops {
48 u16 net_header_len; 48 u16 net_header_len;
49 u16 sockaddr_len; 49 u16 sockaddr_len;
50 int (*setsockopt)(struct sock *sk, int level, int optname, 50 int (*setsockopt)(struct sock *sk, int level, int optname,
51 char __user *optval, int optlen); 51 char __user *optval, unsigned int optlen);
52 int (*getsockopt)(struct sock *sk, int level, int optname, 52 int (*getsockopt)(struct sock *sk, int level, int optname,
53 char __user *optval, int __user *optlen); 53 char __user *optval, int __user *optlen);
54#ifdef CONFIG_COMPAT 54#ifdef CONFIG_COMPAT
55 int (*compat_setsockopt)(struct sock *sk, 55 int (*compat_setsockopt)(struct sock *sk,
56 int level, int optname, 56 int level, int optname,
57 char __user *optval, int optlen); 57 char __user *optval, unsigned int optlen);
58 int (*compat_getsockopt)(struct sock *sk, 58 int (*compat_getsockopt)(struct sock *sk,
59 int level, int optname, 59 int level, int optname,
60 char __user *optval, int __user *optlen); 60 char __user *optval, int __user *optlen);
@@ -332,5 +332,5 @@ extern void inet_csk_addr2sockaddr(struct sock *sk, struct sockaddr *uaddr);
332extern int inet_csk_compat_getsockopt(struct sock *sk, int level, int optname, 332extern int inet_csk_compat_getsockopt(struct sock *sk, int level, int optname,
333 char __user *optval, int __user *optlen); 333 char __user *optval, int __user *optlen);
334extern int inet_csk_compat_setsockopt(struct sock *sk, int level, int optname, 334extern int inet_csk_compat_setsockopt(struct sock *sk, int level, int optname,
335 char __user *optval, int optlen); 335 char __user *optval, unsigned int optlen);
336#endif /* _INET_CONNECTION_SOCK_H */ 336#endif /* _INET_CONNECTION_SOCK_H */
diff --git a/include/net/ip.h b/include/net/ip.h
index 5b26a0bd178e..2f47e5482b55 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -381,10 +381,10 @@ extern int ip_options_rcv_srr(struct sk_buff *skb);
381extern void ip_cmsg_recv(struct msghdr *msg, struct sk_buff *skb); 381extern void ip_cmsg_recv(struct msghdr *msg, struct sk_buff *skb);
382extern int ip_cmsg_send(struct net *net, 382extern int ip_cmsg_send(struct net *net,
383 struct msghdr *msg, struct ipcm_cookie *ipc); 383 struct msghdr *msg, struct ipcm_cookie *ipc);
384extern int ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval, int optlen); 384extern int ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval, unsigned int optlen);
385extern int ip_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); 385extern int ip_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen);
386extern int compat_ip_setsockopt(struct sock *sk, int level, 386extern int compat_ip_setsockopt(struct sock *sk, int level,
387 int optname, char __user *optval, int optlen); 387 int optname, char __user *optval, unsigned int optlen);
388extern int compat_ip_getsockopt(struct sock *sk, int level, 388extern int compat_ip_getsockopt(struct sock *sk, int level,
389 int optname, char __user *optval, int __user *optlen); 389 int optname, char __user *optval, int __user *optlen);
390extern int ip_ra_control(struct sock *sk, unsigned char on, void (*destructor)(struct sock *)); 390extern int ip_ra_control(struct sock *sk, unsigned char on, void (*destructor)(struct sock *));
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index ad9a51130254..8c31d8a0c1fe 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -550,7 +550,7 @@ extern int ipv6_find_tlv(struct sk_buff *skb, int offset, int type);
550extern int ipv6_setsockopt(struct sock *sk, int level, 550extern int ipv6_setsockopt(struct sock *sk, int level,
551 int optname, 551 int optname,
552 char __user *optval, 552 char __user *optval,
553 int optlen); 553 unsigned int optlen);
554extern int ipv6_getsockopt(struct sock *sk, int level, 554extern int ipv6_getsockopt(struct sock *sk, int level,
555 int optname, 555 int optname,
556 char __user *optval, 556 char __user *optval,
@@ -559,7 +559,7 @@ extern int compat_ipv6_setsockopt(struct sock *sk,
559 int level, 559 int level,
560 int optname, 560 int optname,
561 char __user *optval, 561 char __user *optval,
562 int optlen); 562 unsigned int optlen);
563extern int compat_ipv6_getsockopt(struct sock *sk, 563extern int compat_ipv6_getsockopt(struct sock *sk,
564 int level, 564 int level,
565 int optname, 565 int optname,
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index 42d00ced5eb8..6e5f0e0c7967 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -544,7 +544,7 @@ struct sctp_af {
544 int level, 544 int level,
545 int optname, 545 int optname,
546 char __user *optval, 546 char __user *optval,
547 int optlen); 547 unsigned int optlen);
548 int (*getsockopt) (struct sock *sk, 548 int (*getsockopt) (struct sock *sk,
549 int level, 549 int level,
550 int optname, 550 int optname,
@@ -554,7 +554,7 @@ struct sctp_af {
554 int level, 554 int level,
555 int optname, 555 int optname,
556 char __user *optval, 556 char __user *optval,
557 int optlen); 557 unsigned int optlen);
558 int (*compat_getsockopt) (struct sock *sk, 558 int (*compat_getsockopt) (struct sock *sk,
559 int level, 559 int level,
560 int optname, 560 int optname,
diff --git a/include/net/sock.h b/include/net/sock.h
index 950409dcec3d..1621935aad5b 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -624,7 +624,7 @@ struct proto {
624 void (*shutdown)(struct sock *sk, int how); 624 void (*shutdown)(struct sock *sk, int how);
625 int (*setsockopt)(struct sock *sk, int level, 625 int (*setsockopt)(struct sock *sk, int level,
626 int optname, char __user *optval, 626 int optname, char __user *optval,
627 int optlen); 627 unsigned int optlen);
628 int (*getsockopt)(struct sock *sk, int level, 628 int (*getsockopt)(struct sock *sk, int level,
629 int optname, char __user *optval, 629 int optname, char __user *optval,
630 int __user *option); 630 int __user *option);
@@ -632,7 +632,7 @@ struct proto {
632 int (*compat_setsockopt)(struct sock *sk, 632 int (*compat_setsockopt)(struct sock *sk,
633 int level, 633 int level,
634 int optname, char __user *optval, 634 int optname, char __user *optval,
635 int optlen); 635 unsigned int optlen);
636 int (*compat_getsockopt)(struct sock *sk, 636 int (*compat_getsockopt)(struct sock *sk,
637 int level, 637 int level,
638 int optname, char __user *optval, 638 int optname, char __user *optval,
@@ -951,7 +951,7 @@ extern void sock_rfree(struct sk_buff *skb);
951 951
952extern int sock_setsockopt(struct socket *sock, int level, 952extern int sock_setsockopt(struct socket *sock, int level,
953 int op, char __user *optval, 953 int op, char __user *optval,
954 int optlen); 954 unsigned int optlen);
955 955
956extern int sock_getsockopt(struct socket *sock, int level, 956extern int sock_getsockopt(struct socket *sock, int level,
957 int op, char __user *optval, 957 int op, char __user *optval,
@@ -993,7 +993,7 @@ extern int sock_no_shutdown(struct socket *, int);
993extern int sock_no_getsockopt(struct socket *, int , int, 993extern int sock_no_getsockopt(struct socket *, int , int,
994 char __user *, int __user *); 994 char __user *, int __user *);
995extern int sock_no_setsockopt(struct socket *, int, int, 995extern int sock_no_setsockopt(struct socket *, int, int,
996 char __user *, int); 996 char __user *, unsigned int);
997extern int sock_no_sendmsg(struct kiocb *, struct socket *, 997extern int sock_no_sendmsg(struct kiocb *, struct socket *,
998 struct msghdr *, size_t); 998 struct msghdr *, size_t);
999extern int sock_no_recvmsg(struct kiocb *, struct socket *, 999extern int sock_no_recvmsg(struct kiocb *, struct socket *,
@@ -1015,11 +1015,11 @@ extern int sock_common_getsockopt(struct socket *sock, int level, int optname,
1015extern int sock_common_recvmsg(struct kiocb *iocb, struct socket *sock, 1015extern int sock_common_recvmsg(struct kiocb *iocb, struct socket *sock,
1016 struct msghdr *msg, size_t size, int flags); 1016 struct msghdr *msg, size_t size, int flags);
1017extern int sock_common_setsockopt(struct socket *sock, int level, int optname, 1017extern int sock_common_setsockopt(struct socket *sock, int level, int optname,
1018 char __user *optval, int optlen); 1018 char __user *optval, unsigned int optlen);
1019extern int compat_sock_common_getsockopt(struct socket *sock, int level, 1019extern int compat_sock_common_getsockopt(struct socket *sock, int level,
1020 int optname, char __user *optval, int __user *optlen); 1020 int optname, char __user *optval, int __user *optlen);
1021extern int compat_sock_common_setsockopt(struct socket *sock, int level, 1021extern int compat_sock_common_setsockopt(struct socket *sock, int level,
1022 int optname, char __user *optval, int optlen); 1022 int optname, char __user *optval, unsigned int optlen);
1023 1023
1024extern void sk_common_release(struct sock *sk); 1024extern void sk_common_release(struct sock *sk);
1025 1025
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 56b76027b85e..03a49c703377 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -394,13 +394,13 @@ extern int tcp_getsockopt(struct sock *sk, int level,
394 int __user *optlen); 394 int __user *optlen);
395extern int tcp_setsockopt(struct sock *sk, int level, 395extern int tcp_setsockopt(struct sock *sk, int level,
396 int optname, char __user *optval, 396 int optname, char __user *optval,
397 int optlen); 397 unsigned int optlen);
398extern int compat_tcp_getsockopt(struct sock *sk, 398extern int compat_tcp_getsockopt(struct sock *sk,
399 int level, int optname, 399 int level, int optname,
400 char __user *optval, int __user *optlen); 400 char __user *optval, int __user *optlen);
401extern int compat_tcp_setsockopt(struct sock *sk, 401extern int compat_tcp_setsockopt(struct sock *sk,
402 int level, int optname, 402 int level, int optname,
403 char __user *optval, int optlen); 403 char __user *optval, unsigned int optlen);
404extern void tcp_set_keepalive(struct sock *sk, int val); 404extern void tcp_set_keepalive(struct sock *sk, int val);
405extern int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, 405extern int tcp_recvmsg(struct kiocb *iocb, struct sock *sk,
406 struct msghdr *msg, 406 struct msghdr *msg,
diff --git a/include/net/udp.h b/include/net/udp.h
index 5fb029f817a3..f98abd2ce709 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -144,7 +144,7 @@ extern unsigned int udp_poll(struct file *file, struct socket *sock,
144extern int udp_lib_getsockopt(struct sock *sk, int level, int optname, 144extern int udp_lib_getsockopt(struct sock *sk, int level, int optname,
145 char __user *optval, int __user *optlen); 145 char __user *optval, int __user *optlen);
146extern int udp_lib_setsockopt(struct sock *sk, int level, int optname, 146extern int udp_lib_setsockopt(struct sock *sk, int level, int optname,
147 char __user *optval, int optlen, 147 char __user *optval, unsigned int optlen,
148 int (*push_pending_frames)(struct sock *)); 148 int (*push_pending_frames)(struct sock *));
149 149
150extern struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport, 150extern struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport,