Merge branch 'timecounter-next'
[cascardo/linux.git] / fs / binfmt_script.c
index 5027a3e..afdf4e3 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