[PATCH] Increase recursive symlink limit from 5 to 8

From: Petter Reinholdtsen
Date: Wed Jan 07 2004 - 18:13:33 EST



The comment in do_follow_link() do not match the code. The comment
explain that the limit for recursive symlinks are 8, but the code
limit it to 5. This is the current comment:

/*
* This limits recursive symlink follows to 8, while
* limiting consecutive symlinks to 40.
*
* Without that kind of total limit, nasty chains of consecutive
* symlinks can cause almost arbitrarily long lookups.
*/

I discovered it when I ran into a problem with the following symlinks
producing the error message "Too many levels of symbolic links" when I
tried to run /usr/lib/sendmail in our current software configuration.

/usr/lib/sendmail -> /local/sbin/sendmail
/local/sbin/sendmail -> /store/store/diskless/.exim/ver-4.22/sbin/sendmail
/store/store/diskless/.exim/ver-4.22/sbin/sendmail -> /local/sbin/exim
/local/sbin/exim ->
/store/store/diskless/.exim/ver-4.22/sbin/exim@386linuxlibc62

As you can see, this have to visit exactly 5 files to reach the real
file "/store/store/diskless/.exim/ver-4.22/sbin/exim@386linuxlibc62".

I discovered this when testing Debian for the first time using this
software configuration. RedHat did not have any problems follwing the
links, which suggests to me that they already increased the limit.

The fix seem to be to bring the code in sync with the comment of the
function, and increase the limit from 5 to 8.

--- linux-2.4.24/fs/namei.c.orig Wed Jan 7 23:46:03 2004
+++ linux-2.4.24/fs/namei.c Wed Jan 7 23:46:34 2004
@@ -335,7 +335,7 @@
static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd)
{
int err;
- if (current->link_count >= 5)
+ if (current->link_count >= 8)
goto loop;
if (current->total_link_count >= 40)
goto loop;

(I'm not on this mailing list, and do not really know how to proceed
to increase the chances of this patch being accepted into the official
source. Please CC me if you reply. :)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/