aboutsummaryrefslogtreecommitdiffstats
path: root/net/socket.c
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@gmail.com>2010-09-06 23:55:00 -0400
committerDavid S. Miller <davem@davemloft.net>2010-09-08 16:46:13 -0400
commitfb8621bb6c040a25ac2fc246653859f841a1f53d (patch)
treec29874ad2a871e87cfef70cb21f47129ce2a1db9 /net/socket.c
parente3634169bcc0cce33c815865d62ab378739f7389 (diff)
net: remove address space warnings in net/socket.c
Casts __kernel to __user pointer require __force markup, so add it. Also sock_get/setsockopt() takes @optval and/or @optlen arguments as user pointers but were taking kernel pointers, use new variables 'uoptval' and/or 'uoptlen' to fix it. These remove following warnings from sparse: net/socket.c:1922:46: warning: cast adds address space to expression (<asn:1>) net/socket.c:3061:61: warning: incorrect type in argument 4 (different address spaces) net/socket.c:3061:61: expected char [noderef] <asn:1>*optval net/socket.c:3061:61: got char *optval net/socket.c:3061:69: warning: incorrect type in argument 5 (different address spaces) net/socket.c:3061:69: expected int [noderef] <asn:1>*optlen net/socket.c:3061:69: got int *optlen net/socket.c:3063:67: warning: incorrect type in argument 4 (different address spaces) net/socket.c:3063:67: expected char [noderef] <asn:1>*optval net/socket.c:3063:67: got char *optval net/socket.c:3064:45: warning: incorrect type in argument 5 (different address spaces) net/socket.c:3064:45: expected int [noderef] <asn:1>*optlen net/socket.c:3064:45: got int *optlen net/socket.c:3078:61: warning: incorrect type in argument 4 (different address spaces) net/socket.c:3078:61: expected char [noderef] <asn:1>*optval net/socket.c:3078:61: got char *optval net/socket.c:3080:67: warning: incorrect type in argument 4 (different address spaces) net/socket.c:3080:67: expected char [noderef] <asn:1>*optval net/socket.c:3080:67: got char *optval Signed-off-by: Namhyung Kim <namhyung@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/socket.c')
-rw-r--r--net/socket.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/net/socket.c b/net/socket.c
index 7848d12f5e4d..717a5f1c8792 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1918,7 +1918,8 @@ SYSCALL_DEFINE3(sendmsg, int, fd, struct msghdr __user *, msg, unsigned, flags)
1918 * Afterwards, it will be a kernel pointer. Thus the compiler-assisted 1918 * Afterwards, it will be a kernel pointer. Thus the compiler-assisted
1919 * checking falls down on this. 1919 * checking falls down on this.
1920 */ 1920 */
1921 if (copy_from_user(ctl_buf, (void __user *)msg_sys.msg_control, 1921 if (copy_from_user(ctl_buf,
1922 (void __user __force *)msg_sys.msg_control,
1922 ctl_len)) 1923 ctl_len))
1923 goto out_freectl; 1924 goto out_freectl;
1924 msg_sys.msg_control = ctl_buf; 1925 msg_sys.msg_control = ctl_buf;
@@ -3053,14 +3054,19 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
3053 char *optval, int *optlen) 3054 char *optval, int *optlen)
3054{ 3055{
3055 mm_segment_t oldfs = get_fs(); 3056 mm_segment_t oldfs = get_fs();
3057 char __user *uoptval;
3058 int __user *uoptlen;
3056 int err; 3059 int err;
3057 3060
3061 uoptval = (char __user __force *) optval;
3062 uoptlen = (int __user __force *) optlen;
3063
3058 set_fs(KERNEL_DS); 3064 set_fs(KERNEL_DS);
3059 if (level == SOL_SOCKET) 3065 if (level == SOL_SOCKET)
3060 err = sock_getsockopt(sock, level, optname, optval, optlen); 3066 err = sock_getsockopt(sock, level, optname, uoptval, uoptlen);
3061 else 3067 else
3062 err = sock->ops->getsockopt(sock, level, optname, optval, 3068 err = sock->ops->getsockopt(sock, level, optname, uoptval,
3063 optlen); 3069 uoptlen);
3064 set_fs(oldfs); 3070 set_fs(oldfs);
3065 return err; 3071 return err;
3066} 3072}
@@ -3070,13 +3076,16 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
3070 char *optval, unsigned int optlen) 3076 char *optval, unsigned int optlen)
3071{ 3077{
3072 mm_segment_t oldfs = get_fs(); 3078 mm_segment_t oldfs = get_fs();
3079 char __user *uoptval;
3073 int err; 3080 int err;
3074 3081
3082 uoptval = (char __user __force *) optval;
3083
3075 set_fs(KERNEL_DS); 3084 set_fs(KERNEL_DS);
3076 if (level == SOL_SOCKET) 3085 if (level == SOL_SOCKET)
3077 err = sock_setsockopt(sock, level, optname, optval, optlen); 3086 err = sock_setsockopt(sock, level, optname, uoptval, optlen);
3078 else 3087 else
3079 err = sock->ops->setsockopt(sock, level, optname, optval, 3088 err = sock->ops->setsockopt(sock, level, optname, uoptval,
3080 optlen); 3089 optlen);
3081 set_fs(oldfs); 3090 set_fs(oldfs);
3082 return err; 3091 return err;