($INBOX_DIR/description missing)
 help / color / Atom feed
* [PATCH] ovl: fix missing revert_creds() on error path
@ 2021-03-23 13:19 Dan Carpenter
  2021-03-29 14:14 ` Miklos Szeredi
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2021-03-23 13:19 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: Amir Goldstein, linux-unionfs, kernel-janitors

Smatch complains about missing that the ovl_override_creds() doesn't
have a matching revert_creds() if the dentry is disconnected.  Fix this
by moving the ovl_override_creds() until after the disconnected check.

Fixes: aa3ff3c152ff ("ovl: copy up of disconnected dentries")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 fs/overlayfs/copy_up.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
index 0b2891c6c71e..2846b943e80c 100644
--- a/fs/overlayfs/copy_up.c
+++ b/fs/overlayfs/copy_up.c
@@ -932,7 +932,7 @@ static int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry,
 static int ovl_copy_up_flags(struct dentry *dentry, int flags)
 {
 	int err = 0;
-	const struct cred *old_cred = ovl_override_creds(dentry->d_sb);
+	const struct cred *old_cred;
 	bool disconnected = (dentry->d_flags & DCACHE_DISCONNECTED);
 
 	/*
@@ -943,6 +943,7 @@ static int ovl_copy_up_flags(struct dentry *dentry, int flags)
 	if (WARN_ON(disconnected && d_is_dir(dentry)))
 		return -EIO;
 
+	old_cred = ovl_override_creds(dentry->d_sb);
 	while (!err) {
 		struct dentry *next;
 		struct dentry *parent = NULL;
-- 
2.30.2


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

* Re: [PATCH] ovl: fix missing revert_creds() on error path
  2021-03-23 13:19 [PATCH] ovl: fix missing revert_creds() on error path Dan Carpenter
@ 2021-03-29 14:14 ` Miklos Szeredi
  0 siblings, 0 replies; 2+ messages in thread
From: Miklos Szeredi @ 2021-03-29 14:14 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Amir Goldstein, overlayfs, kernel-janitors

On Tue, Mar 23, 2021 at 2:19 PM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> Smatch complains about missing that the ovl_override_creds() doesn't
> have a matching revert_creds() if the dentry is disconnected.  Fix this
> by moving the ovl_override_creds() until after the disconnected check.
>
> Fixes: aa3ff3c152ff ("ovl: copy up of disconnected dentries")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thanks, applied.

Miklos

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

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-23 13:19 [PATCH] ovl: fix missing revert_creds() on error path Dan Carpenter
2021-03-29 14:14 ` Miklos Szeredi

($INBOX_DIR/description missing)

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-unionfs/0 linux-unionfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-unionfs linux-unionfs/ https://lore.kernel.org/linux-unionfs \
		linux-unionfs@vger.kernel.org
	public-inbox-index linux-unionfs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-unionfs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git