mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mateusz Jurczyk <mjurczyk@google.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] fuse: Initialize the flock flag in the fuse_file structure upon allocation
Date: Wed,  7 Jun 2017 12:26:49 +0200	[thread overview]
Message-ID: <20170607102649.14713-1-mjurczyk@google.com> (raw)

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

             reply	other threads:[~2017-06-07 10:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-07 10:26 Mateusz Jurczyk [this message]
2017-06-09  9:20 ` Miklos Szeredi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170607102649.14713-1-mjurczyk@google.com \
    --to=mjurczyk@google.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®