Re: [RFC v5 1/1] ns: add binfmt_misc to the user namespace

From
Tycho Andersen <hidden>
Date
2018-10-09 22:34:09
Also in
linux-fsdevel, lkml
Reply to
Laurent Vivier, 2018-10-09
On Tue, Oct 09, 2018 at 12:37:52PM +0200, Laurent Vivier wrote:
quoted hunk ↗ jump to hunk
@@ -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,
quoted hunk ↗ jump to hunk
@@ -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
Thread (16 messages) 16 messages, 5 authors, last reply 2018-10-10
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help