public inbox for linux-bcachefs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bcachefs: fix smatch data leak warning in fs usage ioctl
@ 2024-06-06 13:58 Brian Foster
  2024-06-06 15:45 ` Kent Overstreet
  0 siblings, 1 reply; 2+ messages in thread
From: Brian Foster @ 2024-06-06 13:58 UTC (permalink / raw)
  To: linux-bcachefs; +Cc: Dan Carpenter

smatch warns that the copy of arg to userspace is a potential data
leak by virtue of arg.pad not being checked or zeroed. This was
introduced by the commit referenced below that switched arg from
being a zeroed runtime allocation to living on the stack. Fix by
simply zero initializing the structure.

Fixes: cde738a61e65 ("bcachefs: Convert bch2_ioctl_fs_usage() to new accounting")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/bcachefs/chardev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/bcachefs/chardev.c b/fs/bcachefs/chardev.c
index 70db3a737d71..4248c251fce5 100644
--- a/fs/bcachefs/chardev.c
+++ b/fs/bcachefs/chardev.c
@@ -515,7 +515,7 @@ static long bch2_ioctl_data(struct bch_fs *c,
 static long bch2_ioctl_fs_usage(struct bch_fs *c,
 				struct bch_ioctl_fs_usage __user *user_arg)
 {
-	struct bch_ioctl_fs_usage arg;
+	struct bch_ioctl_fs_usage arg = {};
 	darray_char replicas = {};
 	u32 replica_entries_bytes;
 	int ret = 0;
-- 
2.44.0


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

* Re: [PATCH] bcachefs: fix smatch data leak warning in fs usage ioctl
  2024-06-06 13:58 [PATCH] bcachefs: fix smatch data leak warning in fs usage ioctl Brian Foster
@ 2024-06-06 15:45 ` Kent Overstreet
  0 siblings, 0 replies; 2+ messages in thread
From: Kent Overstreet @ 2024-06-06 15:45 UTC (permalink / raw)
  To: Brian Foster; +Cc: linux-bcachefs, Dan Carpenter

On Thu, Jun 06, 2024 at 09:58:26AM -0400, Brian Foster wrote:
> smatch warns that the copy of arg to userspace is a potential data
> leak by virtue of arg.pad not being checked or zeroed. This was
> introduced by the commit referenced below that switched arg from
> being a zeroed runtime allocation to living on the stack. Fix by
> simply zero initializing the structure.
> 
> Fixes: cde738a61e65 ("bcachefs: Convert bch2_ioctl_fs_usage() to new accounting")
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Signed-off-by: Brian Foster <bfoster@redhat.com>

Applied

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

end of thread, other threads:[~2024-06-06 15:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-06 13:58 [PATCH] bcachefs: fix smatch data leak warning in fs usage ioctl Brian Foster
2024-06-06 15:45 ` Kent Overstreet

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