From 24fb33d40d60bd7d196400e7d5b26ff566fd98b7 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 12 Aug 2020 05:15:18 +0100 Subject: [PATCH] fix breakage in do_rmdir() syzbot reported and bisected a use-after-free due to the recent init cleanups. The putname() should happen only after we'd *not* branched to retry, same as it's done in do_unlinkat(). Reported-by: syzbot+bbeb1c88016c7db4aa24@syzkaller.appspotmail.com Fixes: e24ab0ef689d "fs: push the getname from do_rmdir into the callers" Cc: Christoph Hellwig Signed-off-by: Al Viro Signed-off-by: Linus Torvalds --- fs/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/namei.c b/fs/namei.c index fde8fe086c09..9fa10c614de7 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3770,11 +3770,11 @@ exit2: mnt_drop_write(path.mnt); exit1: path_put(&path); - putname(name); if (retry_estale(error, lookup_flags)) { lookup_flags |= LOOKUP_REVAL; goto retry; } + putname(name); return error; }