]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - fs/binfmt_script.c
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux...
[karo-tx-linux.git] / fs / binfmt_script.c
index 1610a91637e57d88c54b1a88d6a3ba1e4a230ac4..afdf4e3cafc2aa5f1c1ff1dc0e8cfb256c6a3b89 100644 (file)
@@ -24,6 +24,16 @@ static int load_script(struct linux_binprm *bprm)
 
        if ((bprm->buf[0] != '#') || (bprm->buf[1] != '!'))
                return -ENOEXEC;
+
+       /*
+        * If the script filename will be inaccessible after exec, typically
+        * because it is a "/dev/fd/<fd>/.." path against an O_CLOEXEC fd, give
+        * up now (on the assumption that the interpreter will want to load
+        * this file).
+        */
+       if (bprm->interp_flags & BINPRM_FLAGS_PATH_INACCESSIBLE)
+               return -ENOENT;
+
        /*
         * This section does the #! interpretation.
         * Sorta complicated, but hopefully it will work.  -TYT
@@ -80,7 +90,9 @@ static int load_script(struct linux_binprm *bprm)
        retval = copy_strings_kernel(1, &i_name, bprm);
        if (retval) return retval; 
        bprm->argc++;
-       bprm->interp = interp;
+       retval = bprm_change_interp(interp, bprm);
+       if (retval < 0)
+               return retval;
 
        /*
         * OK, now restart the process with the interpreter's dentry.