From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 61F028F6D for ; Sun, 16 Jul 2023 20:22:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9C0CC433C8; Sun, 16 Jul 2023 20:22:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1689538935; bh=xmj9AElFo3wHOchIoNzrbAlUEFk4jSK+ubQvw9qLn5c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2dzaGLpC0acu7rYQ6HMMSTWoueYqodPTPQ07Oa/8ZRL7YsvwNvBF5+kW0Zx4ZmWFg MzupOoaROtNxOAnTEzzelhXlqYcAJawgLnHz/+4MpxL8wDn5qWngacoQ80UbnXswq9 4nyuGklTaTgBb3RzHUYCs5FbQOQbffx/B3s5jBZ0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Muchun Song , Tejun Heo , Sasha Levin Subject: [PATCH 6.4 599/800] kernfs: fix missing kernfs_idr_lock to remove an ID from the IDR Date: Sun, 16 Jul 2023 21:47:32 +0200 Message-ID: <20230716195003.015835830@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230716194949.099592437@linuxfoundation.org> References: <20230716194949.099592437@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Muchun Song [ 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 Acked-by: Tejun Heo Link: https://lore.kernel.org/r/20230523024017.24851-1-songmuchun@bytedance.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- fs/kernfs/dir.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c index 45b6919903e6b..5a1a4af9d3d29 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.39.2