linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: keescook@chromium.org
Cc: syzbot+e2d6cfb305e9f3911dea@syzkaller.appspotmail.com,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	ebiggers3@gmail.com, james.morse@arm.com,
	keun-o.park@darkmatter.ae, labbott@redhat.com,
	linux-mm@kvack.org, mingo@kernel.org
Subject: Re: [PATCH v2] socket: Provide put_cmsg_whitelist() for constant size copies
Date: Tue, 06 Feb 2018 11:19:49 -0500 (EST)	[thread overview]
Message-ID: <20180206.111949.1986970583522698316.davem@davemloft.net> (raw)
In-Reply-To: <CAGXu5j+VnhgXFajjxR7HJkN=Z6r3Kfw-+Gg2x37AacOD6C+Wdg@mail.gmail.com>

From: Kees Cook <keescook@chromium.org>
Date: Tue, 6 Feb 2018 04:31:50 +1100

> On Tue, Feb 6, 2018 at 2:03 AM, David Miller <davem@davemloft.net> wrote:
>> From: Kees Cook <keescook@chromium.org>
>> Date: Fri, 2 Feb 2018 02:27:49 -0800
>>
>>> @@ -343,6 +343,14 @@ struct ucred {
>>>
>>>  extern int move_addr_to_kernel(void __user *uaddr, int ulen, struct sockaddr_storage *kaddr);
>>>  extern int put_cmsg(struct msghdr*, int level, int type, int len, void *data);
>>> +/*
>>> + * Provide a bounce buffer for copying cmsg data to userspace when the
>>> + * target memory isn't already whitelisted for hardened usercopy.
>>> + */
>>> +#define put_cmsg_whitelist(_msg, _level, _type, _ptr) ({             \
>>> +             typeof(*(_ptr)) _val = *(_ptr);                         \
>>> +             put_cmsg(_msg, _level, _type, sizeof(_val), &_val);     \
>>> +     })
>>
>> I understand what you are trying to achieve, but it's at a real cost
>> here.  Some of these objects are structures, for example the struct
>> sock_extended_err is 16 bytes.
> 
> It didn't look like put_cmsg() was on a fast path, so it seemed like a
> bounce buffer was the best solution here (and it's not without
> precedent).

For some things like timestamps it can be important.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2018-02-06 16:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-02 10:27 Kees Cook
2018-02-05 15:03 ` David Miller
2018-02-05 17:31   ` Kees Cook
2018-02-06 16:19     ` David Miller [this message]
2018-02-06 18:36       ` Kees Cook
2018-02-06 18:42         ` David Miller

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=20180206.111949.1986970583522698316.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=ebiggers3@gmail.com \
    --cc=james.morse@arm.com \
    --cc=keescook@chromium.org \
    --cc=keun-o.park@darkmatter.ae \
    --cc=labbott@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mingo@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=syzbot+e2d6cfb305e9f3911dea@syzkaller.appspotmail.com \
    /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