[rh7,13/14] dcache: d_splice_alias should detect loops

Submitted by Andrey Ryabinin on June 10, 2019, 3:13 p.m.

Details

Message ID 20190610151400.12820-13-aryabinin@virtuozzo.com
State New
Series "Series without cover letter"
Headers show

Commit Message

Andrey Ryabinin June 10, 2019, 3:13 p.m.
From: "J. Bruce Fields" <bfields@redhat.com>

I believe this can only happen in the case of a corrupted filesystem.
So -EIO looks like the appropriate error.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
(cherry picked from commit 95ad5c291313b66a98a44dc92b57e0b37c1dd589)
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 fs/dcache.c | 5 +++++
 1 file changed, 5 insertions(+)

Patch hide | download patch | download mbox

diff --git a/fs/dcache.c b/fs/dcache.c
index f33f43e77449..a1be93d7101d 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -2832,6 +2832,11 @@  struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry)
 				dput(new);
 				return ERR_PTR(-EIO);
 			}
+			if (d_ancestor(new, dentry)) {
+				spin_unlock(&inode->i_lock);
+				dput(new);
+				return ERR_PTR(-EIO);
+			}
 			write_seqlock(&rename_lock);
 			__d_materialise_dentry(dentry, new);
 			write_sequnlock(&rename_lock);