From: Aleksa Sarai <asarai@suse.de>
To: unlisted-recipients:; (no To-header on input)
Cc: Tycho Andersen <tycho@tycho.ws>, Jann Horn <jannh@google.com>,
linux-api@vger.kernel.org, containers@lists.linux-foundation.org,
Dmitry Safonov <dima@arista.com>,
linux-kernel@vger.kernel.org,
James Bottomley <James.Bottomley@HansenPartnership.com>,
Eric Biederman <ebiederm@xmission.com>,
linux-fsdevel@vger.kernel.org,
Alexander Viro <viro@zeniv.linux.org.uk>
Subject: Re: [RFC v5 1/1] ns: add binfmt_misc to the user namespace
Date: Wed, 10 Oct 2018 18:14:47 +1100 [thread overview]
Message-ID: <20181010071447.whwwxjdv54qfnvsr@mikami> (raw)
In-Reply-To: <409c22e3-1df8-cf7f-2462-ead2bb3020cf@vivier.eu>
[-- Attachment #1: Type: text/plain, Size: 1610 bytes --]
On 2018-10-09, Laurent Vivier <laurent@vivier.eu> wrote:
> Le 09/10/2018 à 17:16, Tycho Andersen a écrit :
> > On Tue, Oct 09, 2018 at 12:37:52PM +0200, Laurent Vivier wrote:
> >> @@ -80,18 +74,32 @@ static int entry_count;
> >> */
> >> #define MAX_REGISTER_LENGTH 1920
> >>
> >> +static struct binfmt_namespace *binfmt_ns(struct user_namespace *ns)
> >> +{
> >> + struct binfmt_namespace *b_ns;
> >> +
> >> + while (ns) {
> >> + b_ns = READ_ONCE(ns->binfmt_ns);
> >> + if (b_ns)
> >> + return b_ns;
> >> + ns = ns->parent;
> >> + }
> >> + WARN_ON_ONCE(1);
> >
> > It looks like we warn here,
> >
> >> @@ -133,17 +141,18 @@ static int load_misc_binary(struct linux_binprm *bprm)
> >> struct file *interp_file = NULL;
> >> int retval;
> >> int fd_binary = -1;
> >> + struct binfmt_namespace *ns = binfmt_ns(current_user_ns());
> >>
> >> retval = -ENOEXEC;
> >> - if (!enabled)
> >> + if (!ns->enabled)
> >
> > ...but then in cases like this we immediately dereference the pointer
> > anyways and crash. Can we return some other error code here in the !ns
> > case so we don't crash?
>
> My concern here is I don't want to add code to check an error case that
> cannot happen. The first namespace binfmt_ns pointer is initialized with
> &init_binfmt_ns, so the return value cannot be NULL.
I'd argue that BUG() is a better thing to do then -- if doing a dummy
error path makes no sense. Though IIRC BUG() is no longer a popular
thing to do.
--
Aleksa Sarai
Senior Software Engineer (Containers)
SUSE Linux GmbH
<https://www.cyphar.com/>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2018-10-10 7:13 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-09 10:37 [RFC v5 0/1] ns: introduce binfmt_misc namespace Laurent Vivier
2018-10-09 10:37 ` [RFC v5 1/1] ns: add binfmt_misc to the user namespace Laurent Vivier
2018-10-09 12:43 ` Jann Horn
2018-10-09 13:06 ` Laurent Vivier
2018-10-09 13:15 ` Jann Horn
2018-10-09 15:16 ` Tycho Andersen
2018-10-09 15:19 ` Laurent Vivier
2018-10-10 7:14 ` Aleksa Sarai [this message]
2018-10-10 10:11 ` Laurent Vivier
2018-10-09 16:15 ` Kirill Tkhai
2018-10-09 16:45 ` Laurent Vivier
2018-10-09 16:53 ` Jann Horn
2018-10-09 16:57 ` Laurent Vivier
2018-10-09 17:01 ` Jann Horn
2018-10-09 17:01 ` Kirill Tkhai
2018-10-09 17:22 ` Laurent Vivier
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=20181010071447.whwwxjdv54qfnvsr@mikami \
--to=asarai@suse.de \
--cc=James.Bottomley@HansenPartnership.com \
--cc=containers@lists.linux-foundation.org \
--cc=dima@arista.com \
--cc=ebiederm@xmission.com \
--cc=jannh@google.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tycho@tycho.ws \
--cc=viro@zeniv.linux.org.uk \
/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
all inboxes | Powered by JetHome®