From: Eric Dumazet <eric.dumazet@gmail.com>
To: dccp@vger.kernel.org
Subject: Re: [PATCH 25/26] net: pass a sockptr_t into ->setsockopt
Date: Thu, 06 Aug 2020 22:21:25 +0000 [thread overview]
Message-ID: <6357942b-0b6e-1901-7dce-e308c9fac347@gmail.com> (raw)
In-Reply-To: <20200723060908.50081-26-hch@lst.de>
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 <hch@lst.de>
> Acked-by: Stefan Schmidt <stefan@datenfreihafen.org> [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
next prev parent reply other threads:[~2020-08-06 22:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-23 6:09 [PATCH 25/26] net: pass a sockptr_t into ->setsockopt Christoph Hellwig
2020-08-06 22:21 ` Eric Dumazet [this message]
2020-08-07 7:21 ` Christoph Hellwig
2020-08-07 9:18 ` David Laight
2020-08-07 18:29 ` Eric Dumazet
2020-08-08 13:54 ` David Laight
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6357942b-0b6e-1901-7dce-e308c9fac347@gmail.com \
--to=eric.dumazet@gmail.com \
--cc=dccp@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox