From: Brian Foster Date: Thu, 6 Jun 2024 13:58:26 +0000 (-0400) Subject: bcachefs: fix smatch data leak warning in fs usage ioctl X-Git-Tag: v6.11-rc1~120^2~44 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b5597347a5c7182dba80f9fb561c404abb3cead8;p=thirdparty%2Fkernel%2Flinux.git bcachefs: fix smatch data leak warning in fs usage ioctl 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 Signed-off-by: Brian Foster Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/chardev.c b/fs/bcachefs/chardev.c index cbadba4027c29..72ade3664d7b0 100644 --- a/fs/bcachefs/chardev.c +++ b/fs/bcachefs/chardev.c @@ -517,7 +517,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;