Skip to content

Commit 30480b9

Browse files
songmuchungregkh
authored andcommitted
kernfs: fix missing kernfs_idr_lock to remove an ID from the IDR
The root->ino_idr is supposed to be protected by kernfs_idr_lock, fix it. Fixes: 488dee9 ("kernfs: allow creating kernfs objects with arbitrary uid/gid") Signed-off-by: Muchun Song <songmuchun@bytedance.com> Acked-by: Tejun Heo <tj@kernel.org> Link: https://lore.kernel.org/r/20230523024017.24851-1-songmuchun@bytedance.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 6bea9ea commit 30480b9

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

fs/kernfs/dir.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,9 @@ static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root,
655655
return kn;
656656

657657
err_out3:
658+
spin_lock(&kernfs_idr_lock);
658659
idr_remove(&root->ino_idr, (u32)kernfs_ino(kn));
660+
spin_unlock(&kernfs_idr_lock);
659661
err_out2:
660662
kmem_cache_free(kernfs_node_cache, kn);
661663
err_out1:

0 commit comments

Comments
 (0)