]> 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 8c954997e7f73a22b39718a9564c0c9ed3465a58..afdf4e3cafc2aa5f1c1ff1dc0e8cfb256c6a3b89 100644 (file)
@@ -22,15 +22,23 @@ static int load_script(struct linux_binprm *bprm)
        char interp[BINPRM_BUF_SIZE];
        int retval;
 
-       if ((bprm->buf[0] != '#') || (bprm->buf[1] != '!') ||
-           (bprm->recursion_depth > BINPRM_MAX_RECURSION))
+       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
         */
 
-       bprm->recursion_depth++;
        allow_write_access(bprm->file);
        fput(bprm->file);
        bprm->file = NULL;
@@ -82,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.