linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ovl: avoid setting uninitialized creds
@ 2016-09-19 12:38 Arnd Bergmann
  2016-09-19 14:53 ` Miklos Szeredi
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2016-09-19 12:38 UTC (permalink / raw)
  To: Miklos Szeredi
  Cc: Arnd Bergmann, Vivek Goyal, Al Viro, Andreas Gruenbacher,
	linux-unionfs, linux-kernel

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ovl: avoid setting uninitialized creds
  2016-09-19 12:38 [PATCH] ovl: avoid setting uninitialized creds Arnd Bergmann
@ 2016-09-19 14:53 ` Miklos Szeredi
  0 siblings, 0 replies; 2+ messages in thread
From: Miklos Szeredi @ 2016-09-19 14:53 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Vivek Goyal, Al Viro, Andreas Gruenbacher, linux-unionfs, linux-kernel

On Mon, Sep 19, 2016 at 2:38 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> 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().

Thanks.   Slightly reworked fix folded into original patch and pushed out.

Thanks,
Miklos

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-09-19 14:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-19 12:38 [PATCH] ovl: avoid setting uninitialized creds Arnd Bergmann
2016-09-19 14:53 ` 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).