linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Increase recursive symlink limit from 5 to 8
@ 2004-01-07 23:12 Petter Reinholdtsen
  2004-01-11  1:03 ` Petter Reinholdtsen
  0 siblings, 1 reply; 11+ messages in thread
From: Petter Reinholdtsen @ 2004-01-07 23:12 UTC (permalink / raw)
  To: linux-kernel


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. :)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Increase recursive symlink limit from 5 to 8
  2004-01-07 23:12 [PATCH] Increase recursive symlink limit from 5 to 8 Petter Reinholdtsen
@ 2004-01-11  1:03 ` Petter Reinholdtsen
  2004-01-11  7:01   ` Steve Youngs
  0 siblings, 1 reply; 11+ messages in thread
From: Petter Reinholdtsen @ 2004-01-11  1:03 UTC (permalink / raw)
  To: linux-kernel


[Petter Reinholdtsen]
> 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:

Hm, I wrote the following test script to test the current limit on
different unixes, and was surprised by the differences.  And, my
previous claim that RedHat must have increased this limit was wrong.
The test on RedHat showed that it had the same limit as Debian.  Not
sure why the symlinks in question seemed to be working on RedHat.

  Linux:         Symlink limit seem to be 6 path entities.
  AIX:           Symlink limit seem to be 21 path entities.
  HP-UX:         Symlink limit seem to be 21 path entities.
  Solaris:       Symlink limit seem to be 21 path entities.
  Irix:          Symlink limit seem to be 31 path entities.
  Mac OS X:      Symlink limit seem to be 33 path entities.
  Tru64 Unix:    Symlink limit seem to be 65 path entities.

I really think this limit should be increased in Linux.  Not sure how
high it should go, but from 5 to somewhere between 20 and 64 seem like
a good idea to me.

Petri Koistinen suggested that I sent my patch to
<URL:http://www.kernel.org/pub/linux/kernel/people/rusty/trivial/>.
I'll do that, replacing 5 with 64 instead of 8.  No need to have any
lower limit than Tru64 Unix, I figure.

This is the test program I used:

#!/bin/sh
#
# Author: Petter Reinholdtsen
# Date:   2004-01-11
#
# Script to detect the kernels "recursive" symlink limit.  This seem
# to differ from Unix to Unix, and from version to version.

TMPDIR=test

error() {
    echo $1
    exit 1
}

mkdir $TMPDIR || error "Unable to create $TMPDIR/"
(
    cd $TMPDIR
    for limit in `seq 1 10`; do
	last=foo
	echo "Limit $limit" > foo
	for n in `seq  $limit` ; do
	    ln -s $last $n
	    last="$n"
	done
	cat $last > /dev/null 2>&1 || error "Symlink limit seem to be $limit path entities."
	for n in `seq  $limit` ; do
	    rm $n
	done
    done
)
rm -rf $TMPDIR

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Increase recursive symlink limit from 5 to 8
  2004-01-11  1:03 ` Petter Reinholdtsen
@ 2004-01-11  7:01   ` Steve Youngs
  2004-01-11  9:37     ` Peter Osterlund
                       ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Steve Youngs @ 2004-01-11  7:01 UTC (permalink / raw)
  To: Linux Kernel List

[-- Attachment #1: Type: text/plain, Size: 1025 bytes --]

* Petter Reinholdtsen <pere@hungry.com> writes:

  >   Linux:         Symlink limit seem to be 6 path entities.
  >   AIX:           Symlink limit seem to be 21 path entities.
  >   HP-UX:         Symlink limit seem to be 21 path entities.
  >   Solaris:       Symlink limit seem to be 21 path entities.
  >   Irix:          Symlink limit seem to be 31 path entities.
  >   Mac OS X:      Symlink limit seem to be 33 path entities.
  >   Tru64 Unix:    Symlink limit seem to be 65 path entities.

  > I really think this limit should be increased in Linux.  Not sure
  > how high it should go, but from 5 to somewhere between 20 and 64
  > seem like a good idea to me.

6 does seem pretty low.  What was the reason for setting it there?  Is
there a downside to increasing it?

-- 
|---<Steve Youngs>---------------<GnuPG KeyID: A94B3003>---|
|              Ashes to ashes, dust to dust.               |
|      The proof of the pudding, is under the crust.       |
|------------------------------<sryoungs@bigpond.net.au>---|

[-- Attachment #2: Type: application/pgp-signature, Size: 256 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Increase recursive symlink limit from 5 to 8
  2004-01-11  7:01   ` Steve Youngs
@ 2004-01-11  9:37     ` Peter Osterlund
  2004-01-11  9:49     ` Arjan van de Ven
  2004-01-11 12:10     ` Felipe Alfaro Solana
  2 siblings, 0 replies; 11+ messages in thread
From: Peter Osterlund @ 2004-01-11  9:37 UTC (permalink / raw)
  To: Linux Kernel List

Steve Youngs <sryoungs@bigpond.net.au> writes:

> * Petter Reinholdtsen <pere@hungry.com> writes:
> 
>   >   Linux:         Symlink limit seem to be 6 path entities.
>   >   AIX:           Symlink limit seem to be 21 path entities.
>   >   HP-UX:         Symlink limit seem to be 21 path entities.
>   >   Solaris:       Symlink limit seem to be 21 path entities.
>   >   Irix:          Symlink limit seem to be 31 path entities.
>   >   Mac OS X:      Symlink limit seem to be 33 path entities.
>   >   Tru64 Unix:    Symlink limit seem to be 65 path entities.
> 
>   > I really think this limit should be increased in Linux.  Not sure
>   > how high it should go, but from 5 to somewhere between 20 and 64
>   > seem like a good idea to me.
> 
> 6 does seem pretty low.  What was the reason for setting it there?  Is
> there a downside to increasing it?

Search the archives for "symlink recursion":

http://marc.theaimsgroup.com/?l=linux-kernel&w=2&r=1&s=symlink+recursion&q=b

-- 
Peter Osterlund - petero2@telia.com
http://w1.894.telia.com/~u89404340

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Increase recursive symlink limit from 5 to 8
  2004-01-11  7:01   ` Steve Youngs
  2004-01-11  9:37     ` Peter Osterlund
@ 2004-01-11  9:49     ` Arjan van de Ven
  2004-01-16  0:45       ` GOTO Masanori
  2004-01-11 12:10     ` Felipe Alfaro Solana
  2 siblings, 1 reply; 11+ messages in thread
From: Arjan van de Ven @ 2004-01-11  9:49 UTC (permalink / raw)
  To: Steve Youngs; +Cc: Linux Kernel List

[-- Attachment #1: Type: text/plain, Size: 272 bytes --]


> 6 does seem pretty low.  What was the reason for setting it there?  Is
> there a downside to increasing it?

It was reduced down from 8 because it can lead to stack overflows.
Recursive links like this usually point at a quite broken filesystem
setup too afaik.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Increase recursive symlink limit from 5 to 8
  2004-01-11  7:01   ` Steve Youngs
  2004-01-11  9:37     ` Peter Osterlund
  2004-01-11  9:49     ` Arjan van de Ven
@ 2004-01-11 12:10     ` Felipe Alfaro Solana
  2 siblings, 0 replies; 11+ messages in thread
From: Felipe Alfaro Solana @ 2004-01-11 12:10 UTC (permalink / raw)
  To: Steve Youngs; +Cc: Linux Kernel List

On Sun, 2004-01-11 at 08:01, Steve Youngs wrote:
> * Petter Reinholdtsen <pere@hungry.com> writes:
> 
>   >   Linux:         Symlink limit seem to be 6 path entities.
>   >   AIX:           Symlink limit seem to be 21 path entities.
>   >   HP-UX:         Symlink limit seem to be 21 path entities.
>   >   Solaris:       Symlink limit seem to be 21 path entities.
>   >   Irix:          Symlink limit seem to be 31 path entities.
>   >   Mac OS X:      Symlink limit seem to be 33 path entities.
>   >   Tru64 Unix:    Symlink limit seem to be 65 path entities.
> 
>   > I really think this limit should be increased in Linux.  Not sure
>   > how high it should go, but from 5 to somewhere between 20 and 64
>   > seem like a good idea to me.
> 
> 6 does seem pretty low.  What was the reason for setting it there?  Is
> there a downside to increasing it?

I think we cannot set this value much higher due to constraints in
kernel stack size, and this limits maximum recursion levels.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Increase recursive symlink limit from 5 to 8
  2004-01-11  9:49     ` Arjan van de Ven
@ 2004-01-16  0:45       ` GOTO Masanori
  2004-01-16  0:56         ` Måns Rullgård
                           ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: GOTO Masanori @ 2004-01-16  0:45 UTC (permalink / raw)
  To: arjanv; +Cc: Steve Youngs, Linux Kernel List

At Sun, 11 Jan 2004 10:49:30 +0100,
Arjan van de Ven wrote:
> > 6 does seem pretty low.  What was the reason for setting it there?  Is
> > there a downside to increasing it?
> 
> It was reduced down from 8 because it can lead to stack overflows.
> Recursive links like this usually point at a quite broken filesystem
> setup too afaik.

But I still think 6 is too small from user level point of view, as
Petter wrote.  The example is /usr/lib library links.  I got bug
report which complained that a library want to use "bounce" link:

	/usr/lib/liba -> /etc/alternatives/liba -> /usr/lib/another/libb.

If .so file uses major.minor scheme, then /usr/lib/liba.so links:

	/usr/lib/liba.so -> /usr/lib/liba.so.2 -> /usr/lib/liba.so.2.3

and so on.  It can easily exceed 6 symlinks.  I think the correct fix
is to make VFS not to overflow stacks.  Is it allowable change?

Regards,
-- gotom


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Increase recursive symlink limit from 5 to 8
  2004-01-16  0:45       ` GOTO Masanori
@ 2004-01-16  0:56         ` Måns Rullgård
  2004-01-16  1:25         ` viro
  2004-01-16  3:08         ` Steve Youngs
  2 siblings, 0 replies; 11+ messages in thread
From: Måns Rullgård @ 2004-01-16  0:56 UTC (permalink / raw)
  To: linux-kernel

GOTO Masanori <gotom@debian.or.jp> writes:

> At Sun, 11 Jan 2004 10:49:30 +0100,
> Arjan van de Ven wrote:
>> > 6 does seem pretty low.  What was the reason for setting it there?  Is
>> > there a downside to increasing it?
>> 
>> It was reduced down from 8 because it can lead to stack overflows.
>> Recursive links like this usually point at a quite broken filesystem
>> setup too afaik.
>
> But I still think 6 is too small from user level point of view, as
> Petter wrote.  The example is /usr/lib library links.  I got bug
> report which complained that a library want to use "bounce" link:
>
> 	/usr/lib/liba -> /etc/alternatives/liba -> /usr/lib/another/libb.
>
> If .so file uses major.minor scheme, then /usr/lib/liba.so links:
>
> 	/usr/lib/liba.so -> /usr/lib/liba.so.2 -> /usr/lib/liba.so.2.3
>
> and so on.  It can easily exceed 6 symlinks.  I think the correct fix
> is to make VFS not to overflow stacks.  Is it allowable change?

One of the reasons for the limit is that it doesn't require any
special detection of circular links.

-- 
Måns Rullgård
mru@kth.se


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Increase recursive symlink limit from 5 to 8
  2004-01-16  0:45       ` GOTO Masanori
  2004-01-16  0:56         ` Måns Rullgård
@ 2004-01-16  1:25         ` viro
  2004-01-16 15:46           ` Andries Brouwer
  2004-01-16  3:08         ` Steve Youngs
  2 siblings, 1 reply; 11+ messages in thread
From: viro @ 2004-01-16  1:25 UTC (permalink / raw)
  To: GOTO Masanori; +Cc: arjanv, Steve Youngs, Linux Kernel List

On Fri, Jan 16, 2004 at 09:45:47AM +0900, GOTO Masanori wrote:
 
> But I still think 6 is too small from user level point of view, as
> Petter wrote.  The example is /usr/lib library links.  I got bug
> report which complained that a library want to use "bounce" link:
> 
> 	/usr/lib/liba -> /etc/alternatives/liba -> /usr/lib/another/libb.
> 
> If .so file uses major.minor scheme, then /usr/lib/liba.so links:
> 
> 	/usr/lib/liba.so -> /usr/lib/liba.so.2 -> /usr/lib/liba.so.2.3
> 
> and so on.  It can easily exceed 6 symlinks.  I think the correct fix
> is to make VFS not to overflow stacks.  Is it allowable change?

	You are quite welcome to submit clean patches that would do that.
So far all suggested "solutions" had turned out to be broken _and_ ugly.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Increase recursive symlink limit from 5 to 8
  2004-01-16  0:45       ` GOTO Masanori
  2004-01-16  0:56         ` Måns Rullgård
  2004-01-16  1:25         ` viro
@ 2004-01-16  3:08         ` Steve Youngs
  2 siblings, 0 replies; 11+ messages in thread
From: Steve Youngs @ 2004-01-16  3:08 UTC (permalink / raw)
  To: Linux Kernel List

[-- Attachment #1: Type: text/plain, Size: 1080 bytes --]

* GOTO Masanori <gotom@debian.or.jp> writes:

  > But I still think 6 is too small from user level point of view

When I first saw this thread I thought "yeah, that's a low limit", but
now I'm not so sure.  

The truth is, up until a few days ago when this thread started, I
wasn't even aware that there was a limit.[1] Which means, that for me
at least, I have never had the need to exceed the limit.  Because, if
I had I would have discovered what that limit was.

I'm not an "occasional dual-booting" Linux user, I've been using Linux
_exclusively_ since late 1996.  In that 7, going on 8 years I have
_never_ hit the limit.  Does that mean that it is high enough?  For
me, yes.  For others, I can't say.


Footnotes: 
[1]  Not quite true, I knew that there probably was some sort of
     limit, I just didn't know what it was.

-- 
|---<Steve Youngs>---------------<GnuPG KeyID: A94B3003>---|
|              Ashes to ashes, dust to dust.               |
|      The proof of the pudding, is under the crust.       |
|------------------------------<sryoungs@bigpond.net.au>---|

[-- Attachment #2: Type: application/pgp-signature, Size: 256 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Increase recursive symlink limit from 5 to 8
  2004-01-16  1:25         ` viro
@ 2004-01-16 15:46           ` Andries Brouwer
  0 siblings, 0 replies; 11+ messages in thread
From: Andries Brouwer @ 2004-01-16 15:46 UTC (permalink / raw)
  To: viro; +Cc: GOTO Masanori, arjanv, Steve Youngs, Linux Kernel List

On Fri, Jan 16, 2004 at 01:25:11AM +0000, viro@parcelfarce.linux.theplanet.co.uk wrote:

> > and so on.  It can easily exceed 6 symlinks.  I think the correct fix
> > is to make VFS not to overflow stacks.  Is it allowable change?
> 
> 	You are quite welcome to submit clean patches that would do that.
> So far all suggested "solutions" had turned out to be broken _and_ ugly.

Ugly, possibly - broken, no.


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2004-01-16 15:46 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-07 23:12 [PATCH] Increase recursive symlink limit from 5 to 8 Petter Reinholdtsen
2004-01-11  1:03 ` Petter Reinholdtsen
2004-01-11  7:01   ` Steve Youngs
2004-01-11  9:37     ` Peter Osterlund
2004-01-11  9:49     ` Arjan van de Ven
2004-01-16  0:45       ` GOTO Masanori
2004-01-16  0:56         ` Måns Rullgård
2004-01-16  1:25         ` viro
2004-01-16 15:46           ` Andries Brouwer
2004-01-16  3:08         ` Steve Youngs
2004-01-11 12:10     ` Felipe Alfaro Solana

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).