Fix the race between capifs remount and node creation

we don't want to deal with half-updated config

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2009-05-08 16:23:30 -04:00
Родитель 2a32cebd6c
Коммит b0c4f3222c
1 изменённых файлов: 8 добавлений и 2 удалений

Просмотреть файл

@ -75,14 +75,17 @@ static int capifs_remount(struct super_block *s, int *flags, char *data)
} }
} }
replace_mount_options(s, new_opt); mutex_lock(&s->s_root->d_inode->i_mutex);
replace_mount_options(s, new_opt);
config.setuid = setuid; config.setuid = setuid;
config.setgid = setgid; config.setgid = setgid;
config.uid = uid; config.uid = uid;
config.gid = gid; config.gid = gid;
config.mode = mode; config.mode = mode;
mutex_unlock(&s->s_root->d_inode->i_mutex);
return 0; return 0;
} }
@ -153,13 +156,16 @@ void capifs_new_ncci(unsigned int number, dev_t device)
if (!inode) if (!inode)
return; return;
inode->i_ino = number+2; inode->i_ino = number+2;
dentry = get_node(number);
/* config contents is protected by root's i_mutex */
inode->i_uid = config.setuid ? config.uid : current_fsuid(); inode->i_uid = config.setuid ? config.uid : current_fsuid();
inode->i_gid = config.setgid ? config.gid : current_fsgid(); inode->i_gid = config.setgid ? config.gid : current_fsgid();
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
init_special_inode(inode, S_IFCHR|config.mode, device); init_special_inode(inode, S_IFCHR|config.mode, device);
//inode->i_op = &capifs_file_inode_operations; //inode->i_op = &capifs_file_inode_operations;
dentry = get_node(number);
if (!IS_ERR(dentry) && !dentry->d_inode) if (!IS_ERR(dentry) && !dentry->d_inode)
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
mutex_unlock(&capifs_root->d_inode->i_mutex); mutex_unlock(&capifs_root->d_inode->i_mutex);