diff --git a/lustre/llite/llite_gns.c b/lustre/llite/llite_gns.c index 5c711b2addac8997c4384a4ab23a15771a7b38c5..bf36866930361767c7456f08b18eefa3362bd4ac 100644 --- a/lustre/llite/llite_gns.c +++ b/lustre/llite/llite_gns.c @@ -209,6 +209,14 @@ ll_gns_mount_object(struct dentry *dentry, struct vfsmount *mnt) GOTO(cleanup, rc); } + /* no data in mount object? */ + if (rc == 0) { + CERROR("mount object %*s/%*s is empty?\n", + (int)dentry->d_name.len, dentry->d_name.name, + strlen(sbi->ll_gns_oname), sbi->ll_gns_oname); + GOTO(cleanup, rc); + } + datapage[rc] = '\0'; fput(mntinfo_fd); mntinfo_fd = NULL; diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 50e56f94a132a6abecf6cf924c4a7436e68d3008..03c8d4d8d65dd2f8e7dc909ef013e112f517d99a 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -77,7 +77,9 @@ struct ll_sb_info *lustre_init_sbi(struct super_block *sb) sbi->ll_gns_oname[strlen(sbi->ll_gns_oname)] = '\0'; /* this later may be reset via /proc/fs/... */ - memset(sbi->ll_gns_upcall, 0, sizeof(sbi->ll_gns_upcall)); + memcpy(sbi->ll_gns_upcall, "/usr/sbin/gns_upcall", + strlen("/usr/sbin/gns_upcall")); + sbi->ll_gns_upcall[strlen(sbi->ll_gns_upcall)] = '\0'; /* default values, may be changed via /proc/fs/... */ sbi->ll_gns_state = LL_GNS_IDLE; diff --git a/lustre/llite/lproc_llite.c b/lustre/llite/lproc_llite.c index 2871ab72865e657551bd85ca97cdddc8c8ec5f21..8354c32c8b7324eaa572eb2ed2a6d234fb30a811 100644 --- a/lustre/llite/lproc_llite.c +++ b/lustre/llite/lproc_llite.c @@ -286,9 +286,17 @@ static int ll_wr_gns_upcall(struct file *file, const char *buffer, struct ll_sb_info *sbi = ll_s2sbi(sb); down(&sbi->ll_gns_sem); - snprintf(sbi->ll_gns_upcall, count, "%s", buffer); - up(&sbi->ll_gns_sem); + + /* + * upcall should not be the same as object name, check for possible + * overflow. + */ + if (count < sizeof(sbi->ll_gns_upcall) && + (strlen(sbi->ll_gns_oname) != count || + strncmp(sbi->ll_gns_oname, buffer, count))) + snprintf(sbi->ll_gns_upcall, count, "%s", buffer); + up(&sbi->ll_gns_sem); return count; } @@ -324,9 +332,17 @@ static int ll_wr_gns_object_name(struct file *file, const char *buffer, } down(&sbi->ll_gns_sem); - snprintf(sbi->ll_gns_oname, count, "%s", buffer); + + /* + * upcall should not be the same as object name, check for possible + * overflow. + */ + if (count < sizeof(sbi->ll_gns_oname) && + (strlen(sbi->ll_gns_upcall) != count || + strncmp(sbi->ll_gns_upcall, buffer, count))) + snprintf(sbi->ll_gns_oname, count, "%s", buffer); + up(&sbi->ll_gns_sem); - return count; } @@ -357,7 +373,8 @@ static int ll_wr_gns_timeout(struct file *file, const char *buffer, return rc; down(&sbi->ll_gns_sem); - sbi->ll_gns_timeout = val; + if (val > sbi->ll_gns_tick) + sbi->ll_gns_timeout = val; up(&sbi->ll_gns_sem); return count; @@ -390,12 +407,13 @@ static int ll_wr_gns_tick(struct file *file, const char *buffer, return rc; down(&sbi->ll_gns_sem); - if (sbi->ll_gns_tick < sbi->ll_gns_timeout) + if (val < sbi->ll_gns_timeout) sbi->ll_gns_tick = val; up(&sbi->ll_gns_sem); return count; } + static struct lprocfs_vars lprocfs_obd_vars[] = { { "uuid", ll_rd_sb_uuid, 0, 0 }, //{ "mntpt_path", ll_rd_path, 0, 0 },