linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
To: Laurent Vivier <laurent@vivier.eu>, linux-kernel@vger.kernel.org
Cc: Jann Horn <jannh@google.com>,
	James Bottomley <James.Bottomley@HansenPartnership.com>,
	linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	Andrei Vagin <avagin@gmail.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Eric Biederman <ebiederm@xmission.com>,
	containers@lists.linux-foundation.org,
	Dmitry Safonov <dima@arista.com>
Subject: Re: [PATCH v6 1/1] ns: add binfmt_misc to the user namespace
Date: Tue, 16 Oct 2018 12:13:47 +0200	[thread overview]
Message-ID: <97280bb2-933e-9281-bd91-99748e1dd653@rasmusvillemoes.dk> (raw)
In-Reply-To: <20181010161430.11633-2-laurent@vivier.eu>

On 2018-10-10 18:14, Laurent Vivier wrote:

> +	/* create a new binfmt namespace
> +	 * if we are not in the first user namespace
> +	 * but the binfmt namespace is the first one
> +	 */
> +	if (READ_ONCE(ns->binfmt_ns) == NULL) {
> +		struct binfmt_namespace *new_ns;
> +
> +		new_ns = kmalloc(sizeof(struct binfmt_namespace),
> +				 GFP_KERNEL);
> +		if (new_ns == NULL)
> +			return -ENOMEM;
> +		INIT_LIST_HEAD(&new_ns->entries);
> +		new_ns->enabled = 1;
> +		rwlock_init(&new_ns->entries_lock);
> +		new_ns->bm_mnt = NULL;
> +		new_ns->entry_count = 0;
> +		/* ensure new_ns is completely initialized before sharing it */
> +		smp_wmb();
> +		WRITE_ONCE(ns->binfmt_ns, new_ns);
> +	}

If ns->binfmt_ns can really change under us (given you use READ_ONCE),
what prevents two instances of this code running at the same time, in
which case one of them would leak its new_ns instance? Also, there
doesn't seem to be any smp_rmb() buddy to that wmb(), I don't think
that's implied by READ_ONCE() in binfmt_ns().

Rasmus

  reply	other threads:[~2018-10-16 10:13 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-10 16:14 [PATCH v6 0/1] ns: introduce binfmt_misc namespace Laurent Vivier
2018-10-10 16:14 ` [PATCH v6 1/1] ns: add binfmt_misc to the user namespace Laurent Vivier
2018-10-16 10:13   ` Rasmus Villemoes [this message]
2018-10-16 10:53     ` Laurent Vivier
2018-10-16 16:22   ` Andrei Vagin
2018-10-24 17:15     ` Laurent Vivier
2018-10-30  8:51       ` Laurent Vivier
2018-11-06 19:40         ` Jann Horn
2018-10-16  9:52 ` [PATCH v6 0/1] ns: introduce binfmt_misc namespace Laurent Vivier
2018-11-01  2:59   ` James Bottomley
2018-11-01  3:51     ` Jann Horn
2018-11-01 12:28       ` Laurent Vivier
2018-11-01 14:16         ` Eric W. Biederman
2018-11-29 13:05           ` Laurent Vivier
2018-12-29 15:41             ` Laurent Vivier
2018-11-01 14:10       ` James Bottomley
2018-11-01 14:44         ` Jann Horn

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=97280bb2-933e-9281-bd91-99748e1dd653@rasmusvillemoes.dk \
    --to=linux@rasmusvillemoes.dk \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=avagin@gmail.com \
    --cc=containers@lists.linux-foundation.org \
    --cc=dima@arista.com \
    --cc=ebiederm@xmission.com \
    --cc=jannh@google.com \
    --cc=laurent@vivier.eu \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --subject='Re: [PATCH v6 1/1] ns: add binfmt_misc to the user namespace' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).