* [PATCH] fuse: Initialize the flock flag in the fuse_file structure upon allocation
@ 2017-06-07 10:26 Mateusz Jurczyk
2017-06-09 9:20 ` Miklos Szeredi
0 siblings, 1 reply; 2+ messages in thread
From: Mateusz Jurczyk @ 2017-06-07 10:26 UTC (permalink / raw)
To: Miklos Szeredi; +Cc: linux-fsdevel, linux-kernel
Add initialization of the flock flag in the fuse_file structure after it
is allocated.
Before the patch, the flock flag could remain uninitialized for the
lifespan of the fuse_file allocation: it was not pre-set by kmalloc() or
later in the fuse_file_alloc() function. 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>
---
fs/fuse/file.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 3ee4fdc3da9e..c9a86a748ceb 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -66,6 +66,8 @@ struct fuse_file *fuse_file_alloc(struct fuse_conn *fc)
ff->kh = ++fc->khctr;
spin_unlock(&fc->lock);
+ ff->flock = false;
+
return ff;
}
--
2.13.1.508.gb3defc5cc-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] fuse: Initialize the flock flag in the fuse_file structure upon allocation
2017-06-07 10:26 [PATCH] fuse: Initialize the flock flag in the fuse_file structure upon allocation Mateusz Jurczyk
@ 2017-06-09 9:20 ` Miklos Szeredi
0 siblings, 0 replies; 2+ messages in thread
From: Miklos Szeredi @ 2017-06-09 9:20 UTC (permalink / raw)
To: Mateusz Jurczyk; +Cc: linux-fsdevel, linux-kernel
On Wed, Jun 7, 2017 at 12:26 PM, Mateusz Jurczyk <mjurczyk@google.com> wrote:
> Add initialization of the flock flag in the fuse_file structure after it
> is allocated.
>
> Before the patch, the flock flag could remain uninitialized for the
> lifespan of the fuse_file allocation: it was not pre-set by kmalloc() or
> later in the fuse_file_alloc() function. 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>
Thanks for spotting this. Pushed a modified version (kzalloc instead
of explicit init) to the fuse git tree.
Thanks,
Miklos
> ---
> fs/fuse/file.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> index 3ee4fdc3da9e..c9a86a748ceb 100644
> --- a/fs/fuse/file.c
> +++ b/fs/fuse/file.c
> @@ -66,6 +66,8 @@ struct fuse_file *fuse_file_alloc(struct fuse_conn *fc)
> ff->kh = ++fc->khctr;
> spin_unlock(&fc->lock);
>
> + ff->flock = false;
> +
> return ff;
> }
>
> --
> 2.13.1.508.gb3defc5cc-goog
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-06-09 9:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-07 10:26 [PATCH] fuse: Initialize the flock flag in the fuse_file structure upon allocation Mateusz Jurczyk
2017-06-09 9:20 ` Miklos Szeredi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).