* [PATCH v2] kernfs: fix missing kernfs_idr_lock to remove an ID from the IDR
@ 2023-05-23 2:40 Muchun Song
2023-05-23 2:41 ` Tejun Heo
0 siblings, 1 reply; 2+ messages in thread
From: Muchun Song @ 2023-05-23 2:40 UTC (permalink / raw)
To: gregkh, tj; +Cc: linux-kernel, muchun.song, Muchun Song
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>
---
v2:
- Open code the locking.
fs/kernfs/dir.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index 45b6919903e6..5a1a4af9d3d2 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -655,7 +655,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:
--
2.11.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] kernfs: fix missing kernfs_idr_lock to remove an ID from the IDR
2023-05-23 2:40 [PATCH v2] kernfs: fix missing kernfs_idr_lock to remove an ID from the IDR Muchun Song
@ 2023-05-23 2:41 ` Tejun Heo
0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2023-05-23 2:41 UTC (permalink / raw)
To: Muchun Song; +Cc: gregkh, linux-kernel, muchun.song
On Tue, May 23, 2023 at 10:40:17AM +0800, Muchun Song wrote:
> 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>
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-05-23 2:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-23 2:40 [PATCH v2] kernfs: fix missing kernfs_idr_lock to remove an ID from the IDR Muchun Song
2023-05-23 2:41 ` Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®