From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-f66.google.com ([209.85.166.66]:41026 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726393AbeJIWeJ (ORCPT ); Tue, 9 Oct 2018 18:34:09 -0400 Received: by mail-io1-f66.google.com with SMTP id q4-v6so1435994iob.8 for ; Tue, 09 Oct 2018 08:16:45 -0700 (PDT) Date: Tue, 9 Oct 2018 08:16:41 -0700 From: Tycho Andersen To: Laurent Vivier Cc: linux-kernel@vger.kernel.org, Dmitry Safonov , linux-api@vger.kernel.org, containers@lists.linux-foundation.org, Jann Horn , James Bottomley , Eric Biederman , linux-fsdevel@vger.kernel.org, Alexander Viro Subject: Re: [RFC v5 1/1] ns: add binfmt_misc to the user namespace Message-ID: <20181009151641.GB10149@cisco> References: <20181009103752.21482-1-laurent@vivier.eu> <20181009103752.21482-2-laurent@vivier.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181009103752.21482-2-laurent@vivier.eu> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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? Tycho