From 3d99a3e1d2be9c13fca87bfe9ded1010827c8d4a Mon Sep 17 00:00:00 2001 From: Aleksa Sarai Date: Mon, 27 Nov 2023 10:37:51 +0800 Subject: [PATCH] open: make RESOLVE_CACHED correctly test for O_TMPFILE stable inclusion from stable-v6.5-rc5 commit a0fc452a5d7fed986205539259df1d60546f536c category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8JN4Q?from=project-issue Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a0fc452a5d7fed986205539259df1d60546f536c -------------------------------- O_TMPFILE is actually __O_TMPFILE|O_DIRECTORY. This means that the old fast-path check for RESOLVE_CACHED would reject all users passing O_DIRECTORY with -EAGAIN, when in fact the intended test was to check for __O_TMPFILE. Cc: stable@vger.kernel.org # v5.12+ Fixes: 99668f618062 ("fs: expose LOOKUP_CACHED through openat2() RESOLVE_CACHED") Signed-off-by: Aleksa Sarai Message-Id: <20230806-resolve_cached-o_tmpfile-v1-1-7ba16308465e@cyphar.com> Signed-off-by: Christian Brauner Signed-off-by: Zizhi Wo --- fs/open.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/open.c b/fs/open.c index 8530ca1c0345..8092178ceab0 100644 --- a/fs/open.c +++ b/fs/open.c @@ -1101,7 +1101,7 @@ inline int build_open_flags(const struct open_how *how, struct open_flags *op) lookup_flags |= LOOKUP_IN_ROOT; if (how->resolve & RESOLVE_CACHED) { /* Don't bother even trying for create/truncate/tmpfile open */ - if (flags & (O_TRUNC | O_CREAT | O_TMPFILE)) + if (flags & (O_TRUNC | O_CREAT | __O_TMPFILE)) return -EAGAIN; lookup_flags |= LOOKUP_CACHED; } -- Gitee