summaryrefslogtreecommitdiff
path: root/fs/kernfs
diff options
context:
space:
mode:
authorMuchun Song <songmuchun@bytedance.com>2023-05-23 10:40:17 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-07-27 08:44:05 +0200
commit018eddcb6beff0c7e4f417a4cf05122b6c6d57db (patch)
tree287956e4b324ab92b882c448ce5977b7cee90d0e /fs/kernfs
parenta59f64a83516a2507920dd86ba3beee35d71cc6d (diff)
kernfs: fix missing kernfs_idr_lock to remove an ID from the IDR
[ Upstream commit 30480b988f88c279752f3202a26b6fee5f586aef ] The root->ino_idr is supposed to be protected by kernfs_idr_lock, fix it. Fixes: 488dee96bb62 ("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs/kernfs')
-rw-r--r--fs/kernfs/dir.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index 8b3c86a502da..c91ee05cce74 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -679,7 +679,9 @@ static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root,
return kn;
err_out3:
+ spin_lock(&kernfs_idr_lock);
idr_remove(&root->ino_idr, (u32)kernfs_ino(kn));
+ spin_unlock(&kernfs_idr_lock);
err_out2:
kmem_cache_free(kernfs_node_cache, kn);
err_out1: