Skip to contentSkip to conversation

ovl: credential not reverted in ovl_copy_up_flags on error case

PATCH In review youngjun 2 participants 2 messages Jun 22, 2020 Overlay filesystem

lore
Share & tools
lore

youngjun

author
#0 lore raw

PATCH 1/1 ovl: credential not reverted in ovl_copy_up_flags on error case

In "ovl_copy_up_flags" on disconnected dir case(error case), credential not reverted.

Fixes aa3ff3c152ff9("ovl: copy up of disconnected dentries")
---
 fs/overlayfs/copy_up.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/overlayfs/copy_up.c +3 -1
index 79dd052c7dbf..53daa54ac859 100644
@@ -906,8 +906,10 @@ int ovl_copy_up_flags(struct dentry *dentry, int flags)
 	 * In this case, we will copy up lower inode to index dir without
 	 * linking it to upper dir.
 	 */
-	if (WARN_ON(disconnected && d_is_dir(dentry)))
+	if (WARN_ON(disconnected && d_is_dir(dentry))) {
+		revert_creds(old_cred);
 		return -EIO;
+	}
 
 	while (!err) {
 		struct dentry *next;
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 15 lines · youngjun

In "ovl_copy_up_flags" on disconnected dir case(error case), credential not reverted.

Fixes aa3ff3c152ff9("ovl: copy up of disconnected dentries")
---
 fs/overlayfs/copy_up.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/overlayfs/copy_up.c +0 -0
index 79dd052c7dbf..53daa54ac859 100644

fs/overlayfs/copy_up.c int ovl_copy_up_flags(struct dentry *dentry, int flags) · line 913

Quoted 9 lines
fs/overlayfs/copy_up.c +3 -1
@@ -906,8 +906,10 @@ int ovl_copy_up_flags(struct dentry *dentry, int flags)
         * In this case, we will copy up lower inode to index dir without
         * linking it to upper dir.
         */
-       if (WARN_ON(disconnected && d_is_dir(dentry)))
+       if (WARN_ON(disconnected && d_is_dir(dentry))) {
+               revert_creds(old_cred);
                return -EIO;
+       }
 

It is better to move ovl_override_creds() after the WARN_ON test. which does not require any credentials.

Thanks,
Amir.