All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aleksa Sarai <asarai@suse.de>
To: Aleksa Sarai <cyphar@cyphar.com>
Cc: Sargun Dhillon <sargun@sargun.me>,
	linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org,
	containers@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org, christian.brauner@ubuntu.com
Subject: Re: [PATCH 3/4] seccomp: Add SECCOMP_USER_NOTIF_FLAG_PIDFD to get pidfd on listener trap
Date: Sun, 26 Jan 2020 15:14:39 +1100	[thread overview]
Message-ID: <20200126041439.liwfmb4h74zmhi76@yavin.dot.cyphar.com> (raw)
In-Reply-To: <20200126040325.5eimmm7hli5qcqrr@yavin.dot.cyphar.com>

[-- Attachment #1: Type: text/plain, Size: 1323 bytes --]

On 2020-01-26, Aleksa Sarai <cyphar@cyphar.com> wrote:
> On 2020-01-24, Sargun Dhillon <sargun@sargun.me> wrote:
> >  static long seccomp_notify_recv(struct seccomp_filter *filter,
> >  				void __user *buf)
> >  {
> >  	struct seccomp_knotif *knotif = NULL, *cur;
> >  	struct seccomp_notif unotif;
> > +	struct task_struct *group_leader;
> > +	bool send_pidfd;
> >  	ssize_t ret;
> >  
> > +	if (copy_from_user(&unotif, buf, sizeof(unotif)))
> > +		return -EFAULT;
> >  	/* Verify that we're not given garbage to keep struct extensible. */
> > -	ret = check_zeroed_user(buf, sizeof(unotif));
> > -	if (ret < 0)
> > -		return ret;
> > -	if (!ret)
> > +	if (unotif.id ||
> > +	    unotif.pid ||
> > +	    memchr_inv(&unotif.data, 0, sizeof(unotif.data)) ||
> > +	    unotif.pidfd)
> > +		return -EINVAL;
> 
> IMHO this check is more confusing than the original check_zeroed_user().
> Something like the following is simpler and less prone to forgetting to
> add a new field in the future:
> 
> 	if (memchr_inv(&unotif, 0, sizeof(unotif)))
> 		return -EINVAL;

Also the check in the patch doesn't ensure that any unnamed padding is
zeroed -- memchr_inv(&unotif, 0, sizeof(unotif)) does.

-- 
Aleksa Sarai
Senior Software Engineer (Containers)
SUSE Linux GmbH
<https://www.cyphar.com/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2020-01-26  4:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-24  9:17 [PATCH 0/4] Add the ability to get a pidfd on seccomp user notifications Sargun Dhillon
2020-01-24  9:17 ` Sargun Dhillon
2020-01-24  9:17 ` [PATCH 1/4] pid: Add pidfd_create_file helper Sargun Dhillon
2020-01-24  9:17 ` [PATCH 2/4] fork: Use newly created " Sargun Dhillon
2020-01-24  9:17 ` [PATCH 3/4] seccomp: Add SECCOMP_USER_NOTIF_FLAG_PIDFD to get pidfd on listener trap Sargun Dhillon
2020-01-24 18:03   ` Tycho Andersen
2020-01-24 20:09     ` Sargun Dhillon
2020-01-24 20:09       ` Sargun Dhillon
2020-01-26  4:10       ` Aleksa Sarai
2020-01-26  5:42       ` Tycho Andersen
2020-01-26  5:42         ` Tycho Andersen
     [not found]         ` <CAMp4zn_Xv2iicmH2Nc4-EZceD7T8AFe9PQRNX4bNEiAuoKs+vA@mail.gmail.com>
2020-05-15 11:58           ` Christian Brauner
2020-01-26  4:03   ` Aleksa Sarai
2020-01-26  4:14     ` Aleksa Sarai [this message]
2020-01-27  5:06       ` Sargun Dhillon
2020-01-24  9:17 ` [PATCH 4/4] selftests/seccomp: test SECCOMP_USER_NOTIF_FLAG_PIDFD Sargun Dhillon
2020-01-24  9:17   ` Sargun Dhillon

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=20200126041439.liwfmb4h74zmhi76@yavin.dot.cyphar.com \
    --to=asarai@suse.de \
    --cc=christian.brauner@ubuntu.com \
    --cc=containers@lists.linux-foundation.org \
    --cc=cyphar@cyphar.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sargun@sargun.me \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.