2
0
mirror of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-09-04 20:19:47 +08:00

fhandle: do_handle_open() should get FD with user flags

In f07c7cc468, do_handle_open() was switched to use the automatic
cleanup method for getting a FD. In that change it was also switched
to pass O_CLOEXEC unconditionally to get_unused_fd_flags() instead
of passing the user-specified flags.

I don't see anything in that commit description that indicates this was
intentional, so I am assuming it was an oversight.

With this fix, the FD will again be opened with, or without, O_CLOEXEC
according to what the user requested.

Fixes: f07c7cc468 ("fhandle: simplify error handling")
Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com>
Link: https://lore.kernel.org/20250814235431.995876-4-tahbertschinger@gmail.com
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
Thomas Bertschinger 2025-08-14 17:54:28 -06:00 committed by Christian Brauner
parent 6d3c3ca4c7
commit b5ca88927e
No known key found for this signature in database
GPG Key ID: 91C61BC06578DCA2

View File

@ -402,7 +402,7 @@ static long do_handle_open(int mountdirfd, struct file_handle __user *ufh,
if (retval) if (retval)
return retval; return retval;
CLASS(get_unused_fd, fd)(O_CLOEXEC); CLASS(get_unused_fd, fd)(open_flag);
if (fd < 0) if (fd < 0)
return fd; return fd;