Merge branch 'linux-linaro-lsk-v4.4-android' of git://git.linaro.org/kernel/linux...
[firefly-linux-kernel-4.4.55.git] / fs / binfmt_script.c
index 5027a3e149222bd5945c87d9521e6e7a6108dc77..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