Messages in this thread | | | Date | Tue, 14 Apr 1998 09:48:24 -0700 (PDT) | From | Linus Torvalds <> | Subject | Re: PATCH: smart symlink loop detection. |
| |
On Tue, 14 Apr 1998, C. Scott Ananian wrote: > > The attached patch replaces the hard-coded 5-symlink nesting limit with > an implementation of Tarjan's algorithm to accurately and exactly detect > symlink loops.
Hmm.. This is still recursive, and as such following a really deeply nested link will trash the kernel stack.
Changing the "follow_link" argument to zero in the filesystems does not mean that it isn't recursive: it will still follow links in the _middle_ of the pathname (and indeed it would have to: your code does not have any stack operations so if it didn't do that you would lose information when you have nested internal symlinks).
Essentially, what your patch does is to just remove the tail-recursion, which may be a good thing to do in itself, but it doesn't remove the mid-recursion.
Tail-recursion tends to be a fairly common form of symlink recursion, so you may flatten the recursion depth a lot by removing it, but the comments should be very clear about that - the link_depth counter is still needed to make sure we don't recurse in the middle.
To test mid-recursion, do something like
ln -s test/test test ls test/hello
which will still recurse (well, it's also a loop, so you'll get ELOOP regardless, but trace the path to how this is done to see what's going on).
Linus
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu
| |