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 7820C1ED38 for ; Tue, 25 Jul 2023 11:21:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2E05C433C7; Tue, 25 Jul 2023 11:21:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1690284107; bh=swAHfD33s/u/gSMbygOmXiXwI1iruQiIsLbB4A8hkKg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eawGiPZ6Kc/IrWM84J6/w0xM8uHPPsKtcfXxsVDrhZ4Emflvl5rF69KmM1AVK6cxY vmprU6zwrMfFECBHjAOcS2jgrOT2VxvQ52SfYiIFvuRtlkWkxu1a+2sA4PJPcPy9lX AP/H86y0H60ZuNbxn7Gd1UR41JYniyKBPUaKDIvw= 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.10 237/509] kernfs: fix missing kernfs_idr_lock to remove an ID from the IDR Date: Tue, 25 Jul 2023 12:42:56 +0200 Message-ID: <20230725104604.602358425@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230725104553.588743331@linuxfoundation.org> References: <20230725104553.588743331@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 8b3c86a502daa..c91ee05cce74f 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: -- 2.39.2