From: Thomas Bertschinger Date: Thu, 14 Aug 2025 23:54:28 +0000 (-0600) Subject: fhandle: do_handle_open() should get FD with user flags X-Git-Tag: v6.16.4~174 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f24ea09d04e093034a7b418d5b0761eb77aeb4ea;p=thirdparty%2Fkernel%2Fstable.git fhandle: do_handle_open() should get FD with user flags [ Upstream commit b5ca88927e353185b3d9ac4362d33e5aeb25771f ] In f07c7cc4684a, 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: f07c7cc4684a ("fhandle: simplify error handling") Signed-off-by: Thomas Bertschinger Link: https://lore.kernel.org/20250814235431.995876-4-tahbertschinger@gmail.com Reviewed-by: Amir Goldstein Signed-off-by: Christian Brauner Signed-off-by: Sasha Levin --- diff --git a/fs/fhandle.c b/fs/fhandle.c index 66ff60591d17b..e21ec857f2abc 100644 --- a/fs/fhandle.c +++ b/fs/fhandle.c @@ -404,7 +404,7 @@ static long do_handle_open(int mountdirfd, struct file_handle __user *ufh, if (retval) return retval; - CLASS(get_unused_fd, fd)(O_CLOEXEC); + CLASS(get_unused_fd, fd)(open_flag); if (fd < 0) return fd;