Commit c34645ac authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David S. Miller

net: switch sock_set_timeout to sockptr_t

Pass a sockptr_t to prepare for set_fs-less handling of the kernel
pointer from bpf-cgroup.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5790642b
...@@ -361,7 +361,8 @@ static int sock_get_timeout(long timeo, void *optval, bool old_timeval) ...@@ -361,7 +361,8 @@ static int sock_get_timeout(long timeo, void *optval, bool old_timeval)
return sizeof(tv); return sizeof(tv);
} }
static int sock_set_timeout(long *timeo_p, char __user *optval, int optlen, bool old_timeval) static int sock_set_timeout(long *timeo_p, sockptr_t optval, int optlen,
bool old_timeval)
{ {
struct __kernel_sock_timeval tv; struct __kernel_sock_timeval tv;
...@@ -371,7 +372,7 @@ static int sock_set_timeout(long *timeo_p, char __user *optval, int optlen, bool ...@@ -371,7 +372,7 @@ static int sock_set_timeout(long *timeo_p, char __user *optval, int optlen, bool
if (optlen < sizeof(tv32)) if (optlen < sizeof(tv32))
return -EINVAL; return -EINVAL;
if (copy_from_user(&tv32, optval, sizeof(tv32))) if (copy_from_sockptr(&tv32, optval, sizeof(tv32)))
return -EFAULT; return -EFAULT;
tv.tv_sec = tv32.tv_sec; tv.tv_sec = tv32.tv_sec;
tv.tv_usec = tv32.tv_usec; tv.tv_usec = tv32.tv_usec;
...@@ -380,14 +381,14 @@ static int sock_set_timeout(long *timeo_p, char __user *optval, int optlen, bool ...@@ -380,14 +381,14 @@ static int sock_set_timeout(long *timeo_p, char __user *optval, int optlen, bool
if (optlen < sizeof(old_tv)) if (optlen < sizeof(old_tv))
return -EINVAL; return -EINVAL;
if (copy_from_user(&old_tv, optval, sizeof(old_tv))) if (copy_from_sockptr(&old_tv, optval, sizeof(old_tv)))
return -EFAULT; return -EFAULT;
tv.tv_sec = old_tv.tv_sec; tv.tv_sec = old_tv.tv_sec;
tv.tv_usec = old_tv.tv_usec; tv.tv_usec = old_tv.tv_usec;
} else { } else {
if (optlen < sizeof(tv)) if (optlen < sizeof(tv))
return -EINVAL; return -EINVAL;
if (copy_from_user(&tv, optval, sizeof(tv))) if (copy_from_sockptr(&tv, optval, sizeof(tv)))
return -EFAULT; return -EFAULT;
} }
if (tv.tv_usec < 0 || tv.tv_usec >= USEC_PER_SEC) if (tv.tv_usec < 0 || tv.tv_usec >= USEC_PER_SEC)
...@@ -1051,12 +1052,14 @@ int sock_setsockopt(struct socket *sock, int level, int optname, ...@@ -1051,12 +1052,14 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
case SO_RCVTIMEO_OLD: case SO_RCVTIMEO_OLD:
case SO_RCVTIMEO_NEW: case SO_RCVTIMEO_NEW:
ret = sock_set_timeout(&sk->sk_rcvtimeo, optval, optlen, optname == SO_RCVTIMEO_OLD); ret = sock_set_timeout(&sk->sk_rcvtimeo, USER_SOCKPTR(optval),
optlen, optname == SO_RCVTIMEO_OLD);
break; break;
case SO_SNDTIMEO_OLD: case SO_SNDTIMEO_OLD:
case SO_SNDTIMEO_NEW: case SO_SNDTIMEO_NEW:
ret = sock_set_timeout(&sk->sk_sndtimeo, optval, optlen, optname == SO_SNDTIMEO_OLD); ret = sock_set_timeout(&sk->sk_sndtimeo, USER_SOCKPTR(optval),
optlen, optname == SO_SNDTIMEO_OLD);
break; break;
case SO_ATTACH_FILTER: { case SO_ATTACH_FILTER: {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment