Message ID | 20230523024017.24851-1-songmuchun@bytedance.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1854864vqo; Mon, 22 May 2023 19:55:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6ELD/DZ9HnX+3+QDn83whtAja6TwMG13fgoJ9TuWev74J6GS0NoBkhJWHLKSaYqnQv31wX X-Received: by 2002:aa7:88c4:0:b0:64c:f4f9:de87 with SMTP id k4-20020aa788c4000000b0064cf4f9de87mr17550043pff.18.1684810546175; Mon, 22 May 2023 19:55:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684810546; cv=none; d=google.com; s=arc-20160816; b=U3I0z2v7fbqfesYbTH3E8doI9C4m4EC0+flhuZ408PdAuOpATsXWWsPDlNQhQ6zE4/ fHH/wmyptSoKhi5qpsOdA05H1nLAsfbKICGvEjQ+1u4jfw32cJ7txYas1nyFpeN+vuVZ 3G7hJcJ/UMQn1TUKgtLHJ5Ythb4+M2N9dtUhhzjJ8orxBDkLuOqX1at6GaFyPh5peylu 1grzCNrXC56bUGJS1/12oQJDf4S2EXdyN7sWkQadwheq3vWrDMbN66jwJOHjN5euAt5I O5zaSs63nEwdhPw5nobyjV0kpqJ/5I8bSQYu7IcmWsFaCxwefFANJLwyDgYuvTnCisy1 khqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=ZS9nTwBGX8qR14S3jVVw2sqVNUKYzEeG4IZM9AzTvVI=; b=djorb0IPQ1Jl36pH8g5OyKvw8xGoFd4DHOQjLpL2VNfsqnfhfJDKJSOHjsXHzvDVBI qvviDdP7ZcG9uvDNQEIrIO7GJL0RomDqoJfdIi1cteyEGs4wqEoqa1shm+qN9N+o65k3 xjrZ+WjPqiYaNxyX5jjeq3XWBIeWUwKV2OeMuqNQKqwQ4bJvxJuyDn+DaVbgwCxlcXtM P7LMumFnF0Eyij3eyFBXuRMt+rjAPoHTVFXU4UX7rN5FbgVpNFS6ba2KXOY2SzUqGdON ks9+OA0f6g+snxvLHAsqoeeMuprKGLrnwbto1DXj6V0XA8rtqmEMcPmIUyIRnQ+q4hKB +QuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=FhsYx37F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a28-20020aa78e9c000000b0064380c6010fsi2007382pfr.397.2023.05.22.19.55.31; Mon, 22 May 2023 19:55:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=FhsYx37F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234786AbjEWCkj (ORCPT <rfc822;ahmedalshaiji.dev@gmail.com> + 99 others); Mon, 22 May 2023 22:40:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234812AbjEWCka (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 22 May 2023 22:40:30 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62FC5CD for <linux-kernel@vger.kernel.org>; Mon, 22 May 2023 19:40:29 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-64d2e8a842cso3327053b3a.3 for <linux-kernel@vger.kernel.org>; Mon, 22 May 2023 19:40:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1684809629; x=1687401629; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ZS9nTwBGX8qR14S3jVVw2sqVNUKYzEeG4IZM9AzTvVI=; b=FhsYx37F97Z7aOmK6PMZd0phvrQIdIeUdkA9tyyT6UK2zyQMTVMVcpQxZUCDo34etC EOdMjLNoj/xT4u7MLGIEox3EmjucpiXL95HEqcTqU8jwUZ6wb932I+kWKEz5nofIU2uD ovGKxz3lP8y5zfl7DIhsCpf+BJEPPkxYgfb77CJoFvfneDZmJB2gWjzuSXeLTupGgbvi /1+2zPdAgPyuq24vnAYdmF2mil0THD2W+j7/m9ewZinGF1z4ritDda3a2n2UqzKRYCr9 lkJN4PEuXRmoj+NPCKukYpooeAHXYgh3CqL9nIRcaB+tvqe1iWurnjZvlO15xRhxVx0D xkiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684809629; x=1687401629; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ZS9nTwBGX8qR14S3jVVw2sqVNUKYzEeG4IZM9AzTvVI=; b=Ew4iTm+auBtVrg9MlVeSr360/J/TyiF64Oz5FEODz+4KFe17o8IuNF4BebNagtQBdQ OsFkhB7bMyrPHhthz3QIVF2iyyz/QEy3pbcf4F7g5NHlaK3IB1JImmo0Ex4ldGOpmImj 2XkNQX29nP47Zt24g40jWgqbuUbiOPiaIz7AGkZ6Rth+yDFeHOUGYjm1J9QAAJTT9Tdp Db94ex2XzWqBHCZMCi6IRfUIvtWNw7ltwWU9fLS7/B+nE/PZxxeuuTxWM1gTy0wFUiWl too3sdgC0f1hnDYBltRFjaPd52aPjJzr0kIX1VKieKr4m64x/RqNnrW2A/6fNDlV8vxF AT4w== X-Gm-Message-State: AC+VfDy+QTGOnE/47N5pi0LWm0r+DYYCOSh8oRN4HFkdS3X4TijwA9rQ cWqOChq40Gs90mP6LGd22e4sRA== X-Received: by 2002:a05:6a20:394c:b0:100:15c4:23af with SMTP id r12-20020a056a20394c00b0010015c423afmr12713687pzg.60.1684809628835; Mon, 22 May 2023 19:40:28 -0700 (PDT) Received: from PXLDJ45XCM.bytedance.net ([139.177.225.247]) by smtp.gmail.com with ESMTPSA id c18-20020a17090abf1200b00250d908a771sm4616876pjs.50.2023.05.22.19.40.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 22 May 2023 19:40:27 -0700 (PDT) From: Muchun Song <songmuchun@bytedance.com> To: gregkh@linuxfoundation.org, tj@kernel.org Cc: linux-kernel@vger.kernel.org, muchun.song@linux.dev, Muchun Song <songmuchun@bytedance.com> Subject: [PATCH v2] kernfs: fix missing kernfs_idr_lock to remove an ID from the IDR Date: Tue, 23 May 2023 10:40:17 +0800 Message-Id: <20230523024017.24851-1-songmuchun@bytedance.com> X-Mailer: git-send-email 2.39.2 (Apple Git-143) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766651902810590303?= X-GMAIL-MSGID: =?utf-8?q?1766651902810590303?= |
Series |
[v2] kernfs: fix missing kernfs_idr_lock to remove an ID from the IDR
|
|
Commit Message
Muchun Song
May 23, 2023, 2:40 a.m. UTC
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(+)
Comments
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.
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: