summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2009-12-24 08:27:30 +0100
committerAl Viro <viro@zeniv.linux.org.uk>2010-03-05 15:01:22 +0100
commitc99658fe970f442199733bcace1a00b087336a0d (patch)
treeb9065b274d8f00639af43bbb8e4eaabcda5b559d
parentpull the common predecessors into do_last() (diff)
downloadlinux-c99658fe970f442199733bcace1a00b087336a0d.tar.xz
linux-c99658fe970f442199733bcace1a00b087336a0d.zip
bail out with ELOOP earlier in do_link loop
If we'd passed through 32 trailing symlinks already, there's no sense following the 33rd - we'll bail out anyway. Better bugger off earlier. It *does* change behaviour, after a fashion - if the 33rd happens to be a procfs-style symlink, original code *would* allow it. This one will not. Cry me a river if that hurts you. Please, do. And post a video of that, while you are at it. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/namei.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/fs/namei.c b/fs/namei.c
index 976fc323272e..84f1ec3b4a5d 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1873,7 +1873,7 @@ exit_parent:
do_link:
error = -ELOOP;
- if (flag & O_NOFOLLOW)
+ if ((flag & O_NOFOLLOW) || count++ == 32)
goto exit_dput;
/*
* This is subtle. Instead of calling do_follow_link() we do the
@@ -1915,11 +1915,6 @@ do_link:
__putname(nd.last.name);
goto exit;
}
- error = -ELOOP;
- if (count++==32) {
- __putname(nd.last.name);
- goto exit;
- }
filp = do_last(&nd, &path, open_flag, flag, acc_mode, mode,
pathname, &is_link);
__putname(nd.last.name);