* [PATCH] open: make RESOLVE_CACHED correctly test for O_TMPFILE
@ 2023-08-05 16:11 Aleksa Sarai
2023-08-05 17:17 ` Christian Brauner
0 siblings, 1 reply; 3+ messages in thread
From: Aleksa Sarai @ 2023-08-05 16:11 UTC (permalink / raw)
To: Alexander Viro, Christian Brauner, Jens Axboe
Cc: linux-fsdevel, linux-kernel, stable, Aleksa Sarai
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 <cyphar@cyphar.com>
---
fs/open.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/open.c b/fs/open.c
index b8883ec286f5..2634047c9e9f 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -1337,7 +1337,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;
}
---
base-commit: bf5ad7af0516cb47121dae1b1c160e4385615274
change-id: 20230806-resolve_cached-o_tmpfile-978cb238bd68
Best regards,
--
Aleksa Sarai <cyphar@cyphar.com>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] open: make RESOLVE_CACHED correctly test for O_TMPFILE
2023-08-05 16:11 [PATCH] open: make RESOLVE_CACHED correctly test for O_TMPFILE Aleksa Sarai
@ 2023-08-05 17:17 ` Christian Brauner
2023-08-05 17:21 ` Christian Brauner
0 siblings, 1 reply; 3+ messages in thread
From: Christian Brauner @ 2023-08-05 17:17 UTC (permalink / raw)
To: Aleksa Sarai
Cc: Christian Brauner, linux-fsdevel, linux-kernel, stable,
Alexander Viro, Jens Axboe
On Sun, 06 Aug 2023 02:11:58 +1000, Aleksa Sarai wrote:
> 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.
>
>
Applied to the vfs.fixes branch of the vfs/vfs.git tree.
Patches in the vfs.fixes branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.fixes
[1/1] open: make RESOLVE_CACHED correctly test for O_TMPFILE
https://git.kernel.org/vfs/vfs/c/7c62794bc37f
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] open: make RESOLVE_CACHED correctly test for O_TMPFILE
2023-08-05 17:17 ` Christian Brauner
@ 2023-08-05 17:21 ` Christian Brauner
0 siblings, 0 replies; 3+ messages in thread
From: Christian Brauner @ 2023-08-05 17:21 UTC (permalink / raw)
To: Aleksa Sarai, Jens Axboe
Cc: linux-fsdevel, linux-kernel, stable, Alexander Viro
On Sat, Aug 05, 2023 at 07:17:54PM +0200, Christian Brauner wrote:
> On Sun, 06 Aug 2023 02:11:58 +1000, Aleksa Sarai wrote:
> > 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.
And afaict, io_uring has the same problem in
static bool io_openat_force_async(struct io_open *open)
{
/*
* Don't bother trying for O_TRUNC, O_CREAT, or O_TMPFILE open,
* it'll always -EAGAIN
*/
return open->how.flags & (O_TRUNC | O_CREAT | O_TMPFILE);
}
always forcing O_DIRECTORY lookups to go async. So that needs another
fix.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-05 17:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-05 16:11 [PATCH] open: make RESOLVE_CACHED correctly test for O_TMPFILE Aleksa Sarai
2023-08-05 17:17 ` Christian Brauner
2023-08-05 17:21 ` Christian Brauner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).