fuse: initialize the flock flag in fuse_file on allocation
authorMateusz Jurczyk <mjurczyk@google.com>
Wed, 7 Jun 2017 10:26:49 +0000 (12:26 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 1 Nov 2017 21:12:44 +0000 (22:12 +0100)
commit 68227c03cba84a24faf8a7277d2b1a03c8959c2c upstream.

Before the patch, the flock flag could remain uninitialized for the
lifespan of the fuse_file allocation. Unless set to true in
fuse_file_flock(), it would remain in an indeterminate state until read in
an if statement in fuse_release_common(). This could consequently lead to
taking an unexpected branch in the code.

The bug was discovered by a runtime instrumentation designed to detect use
of uninitialized memory in the kernel.

Signed-off-by: Mateusz Jurczyk <mjurczyk@google.com>
Fixes: 37fb3a30b462 ("fuse: fix flock")
Cc: <stable@vger.kernel.org> # v3.1+
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
fs/fuse/file.c

index 1dce93041012f205e3cab7a18a1e645f0ffbdb84..ee5c3e9a5983b8770dda7d0673b5dbe14de8a993 100644 (file)
@@ -54,7 +54,7 @@ struct fuse_file *fuse_file_alloc(struct fuse_conn *fc)
 {
        struct fuse_file *ff;
 
-       ff = kmalloc(sizeof(struct fuse_file), GFP_KERNEL);
+       ff = kzalloc(sizeof(struct fuse_file), GFP_KERNEL);
        if (unlikely(!ff))
                return NULL;