Skip to content

Commit 3c730b1

Browse files
committed
Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs fixes from Al Viro: "A couple of fixes - no common topic ;-)" [ The aio spectre patch also came in from Jens, so now we have that doubly fixed .. ] * 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: proc/sysctl: don't return ENOMEM on lookup when a table is unregistering aio: fix spectre gadget in lookup_ioctx
2 parents 9105b8a + ea5751c commit 3c730b1

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

fs/proc/proc_sysctl.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ static struct inode *proc_sys_make_inode(struct super_block *sb,
464464

465465
inode = new_inode(sb);
466466
if (!inode)
467-
goto out;
467+
return ERR_PTR(-ENOMEM);
468468

469469
inode->i_ino = get_next_ino();
470470

@@ -474,8 +474,7 @@ static struct inode *proc_sys_make_inode(struct super_block *sb,
474474
if (unlikely(head->unregistering)) {
475475
spin_unlock(&sysctl_lock);
476476
iput(inode);
477-
inode = NULL;
478-
goto out;
477+
return ERR_PTR(-ENOENT);
479478
}
480479
ei->sysctl = head;
481480
ei->sysctl_entry = table;
@@ -500,7 +499,6 @@ static struct inode *proc_sys_make_inode(struct super_block *sb,
500499
if (root->set_ownership)
501500
root->set_ownership(head, table, &inode->i_uid, &inode->i_gid);
502501

503-
out:
504502
return inode;
505503
}
506504

@@ -549,10 +547,11 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
549547
goto out;
550548
}
551549

552-
err = ERR_PTR(-ENOMEM);
553550
inode = proc_sys_make_inode(dir->i_sb, h ? h : head, p);
554-
if (!inode)
551+
if (IS_ERR(inode)) {
552+
err = ERR_CAST(inode);
555553
goto out;
554+
}
556555

557556
d_set_d_op(dentry, &proc_sys_dentry_operations);
558557
err = d_splice_alias(inode, dentry);
@@ -685,7 +684,7 @@ static bool proc_sys_fill_cache(struct file *file,
685684
if (d_in_lookup(child)) {
686685
struct dentry *res;
687686
inode = proc_sys_make_inode(dir->d_sb, head, table);
688-
if (!inode) {
687+
if (IS_ERR(inode)) {
689688
d_lookup_done(child);
690689
dput(child);
691690
return false;

0 commit comments

Comments
 (0)