On 7/22/20 11:09 PM, Christoph Hellwig wrote: > Rework the remaining setsockopt code to pass a sockptr_t instead of a > plain user pointer. This removes the last remaining set_fs(KERNEL_DS) > outside of architecture specific code. > > Signed-off-by: Christoph Hellwig <[email protected]> > Acked-by: Stefan Schmidt <[email protected]> [ieee802154] > --- ... > diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c > index 594e01ad670aa6..874f01cd7aec42 100644 > --- a/net/ipv6/raw.c > +++ b/net/ipv6/raw.c > @@ -972,13 +972,13 @@ static int rawv6_sendmsg(struct sock *sk, struct msghdr > *msg, size_t len) > } > ... > static int do_rawv6_setsockopt(struct sock *sk, int level, int optname, > - char __user *optval, unsigned int optlen) > + sockptr_t optval, unsigned int optlen) > { > struct raw6_sock *rp = raw6_sk(sk); > int val; > > - if (get_user(val, (int __user *)optval)) > + if (copy_from_sockptr(&val, optval, sizeof(val))) > return -EFAULT; > converting get_user(...) to copy_from_sockptr(...) really assumed the optlen has been validated to be >= sizeof(int) earlier. Which is not always the case, for example here. User application can fool us passing optlen=0, and a user pointer of exactly TASK_SIZE-1
- Re: [Bridge] [PATCH 03/26] bpfilter: reject k... 'Christoph Hellwig'
- Re: [Bridge] [PATCH 03/26] bpfilter: reje... David Laight
- [Bridge] [PATCH 02/26] net/bpfilter: split __bpfilter_... Christoph Hellwig
- [Bridge] [PATCH 09/26] net/xfrm: switch xfrm_user_poli... Christoph Hellwig
- [Bridge] [PATCH 26/26] net: optimize the sockptr_t for... Christoph Hellwig
- [Bridge] [PATCH 16/26] net/ipv4: switch do_ip_setsocko... Christoph Hellwig
- [Bridge] [PATCH 17/26] net/ipv6: switch ip6_mroute_set... Christoph Hellwig
- [Bridge] [PATCH 23/26] net/tcp: switch ->md5_parse ... Christoph Hellwig
- [Bridge] [PATCH 25/26] net: pass a sockptr_t into ->... Christoph Hellwig
- Re: [Bridge] [MPTCP] [PATCH 25/26] net: pass a so... Matthieu Baerts
- Re: [Bridge] [PATCH 25/26] net: pass a sockptr_t ... Eric Dumazet
- Re: [Bridge] [PATCH 25/26] net: pass a sockpt... Christoph Hellwig
- Re: [Bridge] [PATCH 25/26] net: pass a sockpt... David Laight
- Re: [Bridge] [PATCH 25/26] net: pass a so... Eric Dumazet
- Re: [Bridge] [PATCH 25/26] net: pass ... David Laight
- Re: [Bridge] get rid of the address_space override in ... David Miller
- Re: [Bridge] get rid of the address_space overrid... Christoph Hellwig
- Re: [Bridge] get rid of the address_space ove... David Miller
- Re: [Bridge] get rid of the address_space ove... Andreas Schwab
- Re: [Bridge] get rid of the address_space overrid... David Laight
