From: Arnd Bergmann <arnd@arndb.de>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: Arnd Bergmann <arnd@arndb.de>, Vivek Goyal <vgoyal@redhat.com>,
Al Viro <viro@zeniv.linux.org.uk>,
Andreas Gruenbacher <agruenba@redhat.com>,
linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] ovl: avoid setting uninitialized creds
Date: Mon, 19 Sep 2016 14:38:46 +0200 [thread overview]
Message-ID: <20160919123859.1335236-1-arnd@arndb.de> (raw)
If the call to ovl_copy_up() fails, we now call revert_creds on
an uninitialized structure after a recent patch, as found
by "gcc -Wmayby-uninitialized":
fs/overlayfs/inode.c: In function 'ovl_open_maybe_copy_up':
fs/overlayfs/inode.c:39:2: error: 'old_cred' may be used uninitialized in this function [-Werror=maybe-uninitialized]
fs/overlayfs/inode.c:22:21: note: 'old_cred' was declared here
This changes the code back to not call revert_creds unless
we have already called ovl_override_creds().
Fixes: 54249cd03956 ("ovl: during copy up, switch to mounter's creds early")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
fs/overlayfs/inode.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index af87c7c109b7..65375f9c5563 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -30,13 +30,14 @@ static int ovl_copy_up_truncate(struct dentry *dentry)
old_cred = ovl_override_creds(dentry->d_sb);
err = vfs_getattr(&lowerpath, &stat);
if (err)
- goto out_dput_parent;
+ goto out_revert;
stat.size = 0;
err = ovl_copy_up_one(parent, dentry, &lowerpath, &stat);
-out_dput_parent:
+out_revert:
revert_creds(old_cred);
+out_dput_parent:
dput(parent);
return err;
}
--
2.9.0
next reply other threads:[~2016-09-19 12:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-19 12:38 Arnd Bergmann [this message]
2016-09-19 14:53 ` 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=20160919123859.1335236-1-arnd@arndb.de \
--to=arnd@arndb.de \
--cc=agruenba@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=vgoyal@redhat.com \
--cc=viro@zeniv.linux.org.uk \
/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®