Messages in this thread Patch in this message | | | From | Andi Kleen <> | Subject | [PATCH 1/5] VFS: Make symlink nesting limit a define | Date | Fri, 13 May 2011 16:24:15 -0700 |
| |
From: Andi Kleen <ak@linux.intel.com>
Use a SYMLOOP_MAX define for the total symlink nesting limit instead of a hardcoded 40. No behaviour change.
Used in a followon patch
Signed-off-by: Andi Kleen <ak@linux.intel.com> --- fs/namei.c | 6 +++--- include/linux/limits.h | 1 + include/linux/namei.h | 1 + 3 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/fs/namei.c b/fs/namei.c index 54fc993..9d0a92e 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -763,7 +763,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p) if (link->mnt == nd->path.mnt) mntget(link->mnt); - if (unlikely(current->total_link_count >= 40)) { + if (unlikely(current->total_link_count >= SYMLOOP_MAX)) { *p = ERR_PTR(-ELOOP); /* no ->put_link(), please */ path_put(&nd->path); return -ELOOP; @@ -871,7 +871,7 @@ static int follow_automount(struct path *path, unsigned flags, return -EISDIR; current->total_link_count++; - if (current->total_link_count >= 40) + if (current->total_link_count >= SYMLOOP_MAX) return -ELOOP; mnt = path->dentry->d_op->d_automount(path); @@ -1369,7 +1369,7 @@ static inline int walk_component(struct nameidata *nd, struct path *path, /* * This limits recursive symlink follows to 8, while - * limiting consecutive symlinks to 40. + * limiting consecutive symlinks to 40 (SYMLOOP_MAX) * * Without that kind of total limit, nasty chains of consecutive * symlinks can cause almost arbitrarily long lookups. diff --git a/include/linux/limits.h b/include/linux/limits.h index 2d0f941..2f39657 100644 --- a/include/linux/limits.h +++ b/include/linux/limits.h @@ -14,6 +14,7 @@ #define XATTR_NAME_MAX 255 /* # chars in an extended attribute name */ #define XATTR_SIZE_MAX 65536 /* size of an extended attribute value (64k) */ #define XATTR_LIST_MAX 65536 /* size of extended attribute namelist (64k) */ +#define SYMLOOP_MAX 40 /* max number of total symlink nests */ #define RTSIG_MAX 32 diff --git a/include/linux/namei.h b/include/linux/namei.h index eba45ea..403e39c 100644 --- a/include/linux/namei.h +++ b/include/linux/namei.h @@ -4,6 +4,7 @@ #include <linux/dcache.h> #include <linux/linkage.h> #include <linux/path.h> +#include <linux/limits.h> struct vfsmount; -- 1.7.4.4
| |