[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230523024017.24851-1-songmuchun@bytedance.com>
Date: Tue, 23 May 2023 10:40:17 +0800
From: Muchun Song <songmuchun@...edance.com>
To: gregkh@...uxfoundation.org, tj@...nel.org
Cc: linux-kernel@...r.kernel.org, muchun.song@...ux.dev,
Muchun Song <songmuchun@...edance.com>
Subject: [PATCH v2] 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: 488dee96bb62 ("kernfs: allow creating kernfs objects with arbitrary uid/gid")
Signed-off-by: Muchun Song <songmuchun@...edance.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
Powered by blists - more mailing lists