Make sure that make_create_in_sticky() never sees uninitialized value of dir_mode
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 19 Sep 2020 16:55:58 +0000 (17:55 +0100)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 10 Dec 2020 22:33:17 +0000 (17:33 -0500)
make sure nd->dir_mode is always initialized after success exit from
link_path_walk(); in case of empty path it did not happen.

Reported-by: Anant Thazhemadam <anant.thazhemadam@gmail.com>
Tested-by: Anant Thazhemadam <anant.thazhemadam@gmail.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/namei.c

index d4a6dd7..fc193c6 100644 (file)
@@ -2114,8 +2114,10 @@ static int link_path_walk(const char *name, struct nameidata *nd)
                return PTR_ERR(name);
        while (*name=='/')
                name++;
-       if (!*name)
+       if (!*name) {
+               nd->dir_mode = 0; // short-circuit the 'hardening' idiocy
                return 0;
+       }
 
        /* At this point we know we have a real path component. */
        for(;;) {