diff options
author | Anand Avati <avati@gluster.com> | 2010-02-22 04:28:07 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2010-02-22 02:29:27 -0800 |
commit | 867b0beafbcd4dde7515923e21302926a1ca9fb9 (patch) | |
tree | 21a542d53465641648326542d6672f0670189471 /libglusterfs | |
parent | fa3b447cb058a7012ed2f68b89bc9b9e933c7367 (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.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c index f4561cc27..da851ff12 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); } |