security: testing the wrong variable in create_by_name()
There is a typo here. We should be testing "*dentry" instead of "dentry". If "*dentry" is an ERR_PTR, it gets dereferenced in either mkdir() or create() which would cause an OOPs. Signed-off-by: Dan Carpenter <error27@gmail.com> Signed-off-by: James Morris <jmorris@namei.org>
This commit is contained in:
Родитель
e134d200d5
Коммит
b338cc8207
|
@ -161,13 +161,13 @@ static int create_by_name(const char *name, mode_t mode,
|
||||||
|
|
||||||
mutex_lock(&parent->d_inode->i_mutex);
|
mutex_lock(&parent->d_inode->i_mutex);
|
||||||
*dentry = lookup_one_len(name, parent, strlen(name));
|
*dentry = lookup_one_len(name, parent, strlen(name));
|
||||||
if (!IS_ERR(dentry)) {
|
if (!IS_ERR(*dentry)) {
|
||||||
if ((mode & S_IFMT) == S_IFDIR)
|
if ((mode & S_IFMT) == S_IFDIR)
|
||||||
error = mkdir(parent->d_inode, *dentry, mode);
|
error = mkdir(parent->d_inode, *dentry, mode);
|
||||||
else
|
else
|
||||||
error = create(parent->d_inode, *dentry, mode);
|
error = create(parent->d_inode, *dentry, mode);
|
||||||
} else
|
} else
|
||||||
error = PTR_ERR(dentry);
|
error = PTR_ERR(*dentry);
|
||||||
mutex_unlock(&parent->d_inode->i_mutex);
|
mutex_unlock(&parent->d_inode->i_mutex);
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче