From: Al Viro Date: Sat, 19 Sep 2020 16:55:58 +0000 (+0100) Subject: Make sure that make_create_in_sticky() never sees uninitialized value of dir_mode X-Git-Tag: accepted/tizen/unified/20230118.172025~8167^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1a97d899ecbc4b60c8e8f9b41cde443510b5b1bf;p=platform%2Fkernel%2Flinux-rpi.git Make sure that make_create_in_sticky() never sees uninitialized value of dir_mode 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 Tested-by: Anant Thazhemadam Signed-off-by: Al Viro --- diff --git a/fs/namei.c b/fs/namei.c index d4a6dd7..fc193c6 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -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(;;) {