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 63C5C27F34 for ; Fri, 21 Jul 2023 19:05:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9F62C433C7; Fri, 21 Jul 2023 19:05:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1689966358; bh=2GGiDpXqr6ZG6zTUWp7hXFbEWJqu9Ilt5M5JIbNdVm4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R+swW7RHt2CBKE1oZI4SL0ISLf2qMlO061vEziHXAhwsYpASU1uznJmSna6AEYSa/ AYj+juK4eREQNMurmtclqbTG5oFGPqg3HckGoOFC70J4SMwrtEytNXFT7ft55lvlXi oftb3yS2cUB94nxbv7Gn01EUKbu7jtbCdNrs5qLY= 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 5.15 287/532] kernfs: fix missing kernfs_idr_lock to remove an ID from the IDR Date: Fri, 21 Jul 2023 18:03:11 +0200 Message-ID: <20230721160629.987186745@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230721160614.695323302@linuxfoundation.org> References: <20230721160614.695323302@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 90677cfbcf9c2..6a1cb2a182b67 100644 --- a/fs/kernfs/dir.c +++ b/fs/kernfs/dir.c @@ -637,7 +637,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