summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorAnand Avati <avati@gluster.com>2010-02-22 04:28:07 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-02-22 02:29:34 -0800
commit85cda442079ba252d3a1e625b1f53ca207887159 (patch)
tree3add855a9472e3ec5e9598a3d103aa9da6462ff6 /libglusterfs
parent1f1a2f8c47c4b67438d9413e7fc7a18af9083f4b (diff)
inode: guard against possible infinite loops
Check to prevent accidental linkage of inodes with inode number 1. Such links will result in loop formation in the inode table. Signed-off-by: Anand V. Avati <avati@blackhole.gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 537 (infinite loop in inode_path ()) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=537
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/inode.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c
index f4561cc278b..da851ff1208 100644
--- a/libglusterfs/src/inode.c
+++ b/libglusterfs/src/inode.c
@@ -677,6 +677,17 @@ __inode_link (inode_t *inode, inode_t *parent, const char *name,
link_inode = inode;
+ if (stbuf->st_ino == 1 && inode != table->root) {
+ gf_log (table->name, GF_LOG_ERROR,
+ "inode_link called with stbuf->st_ino = 1. "
+ "inode=%"PRId64"/%"PRId64 "parent=%"PRId64"/%"PRId64
+ " name=%s",
+ inode ? inode->generation:0 , inode ? inode->ino:0,
+ parent ? parent->generation:0 , parent ? parent->ino:0,
+ name);
+ return link_inode;
+ }
+
if (!__is_inode_hashed (inode)) {
inode->ino = stbuf->st_ino;
inode->st_mode = stbuf->st_mode;
@@ -901,7 +912,7 @@ inode_path (inode_t *inode, const char *name, char **bufp)
i ++; /* "/" */
i += strlen (trav->name);
if (i > PATH_MAX) {
- gf_log ("inode", GF_LOG_CRITICAL,
+ gf_log (table->name, GF_LOG_CRITICAL,
"possible infinite loop detected, "
"forcing break. name=(%s)", name);
ret = -ENOENT;
@@ -1026,8 +1037,8 @@ __inode_table_init_root (inode_table_t *table)
stbuf.st_ino = 1;
stbuf.st_mode = S_IFDIR|0755;
- __inode_link (root, NULL, NULL, &stbuf);
table->root = root;
+ __inode_link (root, NULL, NULL, &stbuf);
}