]> www.infradead.org Git - nvme.git/commitdiff
bcachefs: fix smatch data leak warning in fs usage ioctl
authorBrian Foster <bfoster@redhat.com>
Thu, 6 Jun 2024 13:58:26 +0000 (09:58 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 14 Jul 2024 23:00:15 +0000 (19:00 -0400)
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>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/chardev.c

index cbadba4027c29ba74227af75682a512f4bc2c1ef..72ade3664d7b0600356cd71c8126200ac0132352 100644 (file)
@@ -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;