public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] backing_file: Fix error code swallow
@ 2026-03-22 23:26 Ethan Tidmore
  2026-03-23  0:53 ` Paul Moore
  0 siblings, 1 reply; 2+ messages in thread
From: Ethan Tidmore @ 2026-03-22 23:26 UTC (permalink / raw)
  To: viro, brauner
  Cc: jack, amir73il, paul, linux-fsdevel, linux-kernel, Ethan Tidmore

The macro WARN_ON() returns true if the condition inside is true. So if
there is an error with vfs_open() 1 is returned.

Capture the return value of vfs_open() then run WARN_ON() on it.

Detected by Smatch:
fs/backing-file.c:52 backing_file_open() warn:
passing positive error code '1' to 'ERR_PTR'

fs/backing-file.c:77 backing_tmpfile_open() warn:
passing positive error code '1' to 'ERR_PTR'

Fixes: 7ea30795d6b7d ("backing_file: store user_path_file")
Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
---
 fs/file_table.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/file_table.c b/fs/file_table.c
index e8b4eb2bbff8..0898b1816c14 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -69,8 +69,12 @@ EXPORT_SYMBOL_GPL(backing_file_user_path_file);
 
 int backing_file_open_user_path(struct file *f, const struct path *path)
 {
+	int ret;
+
 	/* open an O_PATH file to reference the user path - should not fail */
-	return WARN_ON(vfs_open(path, &backing_file(f)->user_path_file));
+	ret = vfs_open(path, &backing_file(f)->user_path_file);
+	WARN_ON(ret);
+	return ret;
 }
 EXPORT_SYMBOL_GPL(backing_file_open_user_path);
 
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] backing_file: Fix error code swallow
  2026-03-22 23:26 [PATCH] backing_file: Fix error code swallow Ethan Tidmore
@ 2026-03-23  0:53 ` Paul Moore
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Moore @ 2026-03-23  0:53 UTC (permalink / raw)
  To: Ethan Tidmore; +Cc: viro, brauner, jack, amir73il, linux-fsdevel, linux-kernel

On Sun, Mar 22, 2026 at 7:27 PM Ethan Tidmore <ethantidmore06@gmail.com> wrote:
>
> The macro WARN_ON() returns true if the condition inside is true. So if
> there is an error with vfs_open() 1 is returned.
>
> Capture the return value of vfs_open() then run WARN_ON() on it.
>
> Detected by Smatch:
> fs/backing-file.c:52 backing_file_open() warn:
> passing positive error code '1' to 'ERR_PTR'
>
> fs/backing-file.c:77 backing_tmpfile_open() warn:
> passing positive error code '1' to 'ERR_PTR'
>
> Fixes: 7ea30795d6b7d ("backing_file: store user_path_file")
> Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
> ---
>  fs/file_table.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)

Due to other discussions (see the related threads) I have removed the
patch{set} this targets from lsm/{stable-7.0,next}.

-- 
paul-moore.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-23  0:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-22 23:26 [PATCH] backing_file: Fix error code swallow Ethan Tidmore
2026-03-23  0:53 ` Paul Moore

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox