Received: by 2002:a05:7412:9c07:b0:fa:6e18:a558 with SMTP id lr7csp777024rdb; Sun, 28 Jan 2024 08:27:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IFQ1BcGnmUyYqKzjICEIdmCyJ35b4O1HCM1kHWiEVMvPB2Eac3toYeIrxCBJt5EwJL2LfCq X-Received: by 2002:a17:906:27d3:b0:a35:95a4:7d5d with SMTP id k19-20020a17090627d300b00a3595a47d5dmr1040890ejc.13.1706459257493; Sun, 28 Jan 2024 08:27:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706459257; cv=pass; d=google.com; s=arc-20160816; b=ZM8TEHBrV/KC0QrWYwmu3DWKAfukZU4ZiIRwYkSgIVFy99sCNS8ZcLrlFU4k5OiqDX 1lUxBKl3wv9JtWVDKEjduaKRjybyGcBtqZ0omRwiM82hM2mPwJitf3KLan1mLpItI+jV 0PuDDC7yeg3f/VQxPFeD7cbl39dS10FpAemyxp+j5Wm++p4Y/eV2VjyNXNeW18fp8903 eB7SNyxSVXNtfnm/yQ8+Uzl3j6+cTvInt1joKCM17rg9dF87Mt7aA85sb+WtyeLiRYCv lxm6224xDKMtr8E/VY3kIyAKLUzMpIESuNX4ZPXyTlpIQwrLMR6wH3UhvpjnxOwnrdAg 6XVQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=rQEG4oYzf+6w+BV7IqRFSphNrRtxO8MFa4YTfWVyZfg=; fh=PGvckvZ6LFee6MMu4Lh1a9nXOJYAH2L6Jmaseb08TOs=; b=N8aBYP6pSCSPvPLwFpoVjdTfUATL6puubcsj02BS1Mhx6KYTxQL/ALzLv5uRmIRzn4 cb3yDuS10BXV1VV4or47X2ma8fYqwaGIhBW+xtRHUvQ00dUzll0KtcO+Tkp5C1BAVyCO i46I806MIi+m1/uesJnVdY2aTG3PtUUKGWCEqDR2hvGA4aU63SYnjjOsx9bWEqQH+6Na N2Uwly1S8LZ9t85FLRUPg6zp4vX651k7HQqchuj+a2bEjJ5zT9p4RvKDs2ZcBIZE87tt pwA4V2arVM4PoOTku4Wq7NDk/btGn9h75SOwLSqXiTN28xICFkfNIsT9+n7c6xrpzk3g Fxnw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lK1g+hyl; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-41714-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41714-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ce8-20020a170906b24800b00a32e34b96d0si2783900ejb.398.2024.01.28.08.27.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 08:27:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-41714-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lK1g+hyl; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-41714-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41714-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 46EF81F27ABA for ; Sun, 28 Jan 2024 16:20:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 73CE95647D; Sun, 28 Jan 2024 16:12:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lK1g+hyl" 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 9321056454; Sun, 28 Jan 2024 16:12:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706458362; cv=none; b=s4DieHyYxp1/ZirbXGh6a6WdxuX1JsvVYxhXWvfGkVlWwNKzmCXOfyhojlyPl3JGDmYVgBQrkM07jS7PedJi8KgPUpDoMY1qqJqlkeMmshgyLC+qOB/g7zrkNeablPqqIFSlGmZ6AZTbj1QhouHvLvGCZPxbWn5ebMpiSdlMX7o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706458362; c=relaxed/simple; bh=jRuelF6orccHsBwwAdGxa2vDDoeavvFfxMPnSe9WWQU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p/wJjJzNE41YucmJ2eSZ3YtsCm+iXsdmwFh4HsOai0ZVJquAswGga5gKLBzHFX/zB0SIs4nDtDZF/sRbVml+Hzq6ZP9rpCBd4zuG28PWX37aK4w9tvxLwGJbtWTpo6urVvRUokHWgizvlyLbznO4AM2u3XEU3Z2sWxUuthxTufM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lK1g+hyl; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 851D9C43390; Sun, 28 Jan 2024 16:12:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706458362; bh=jRuelF6orccHsBwwAdGxa2vDDoeavvFfxMPnSe9WWQU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lK1g+hyltIahJYmjwKinayXWL8TO5yKcGZY7WtcceAWUwHrbi9JCPKec+Eb0OoRGp B4vBzxscCSwnLeiKs5M83QNq80ul/e8+7mOP21hapB+UK7vcFDMCbIRq5EbeF4As+j wqPciZw+rlJxl0+gtYe4iezzZN+PTxZnYeyPtyLD2vETeohU+Al4OUfmkJ7dxU3xEc W8JA+8+1c9cx5eoSoRBB+ocn8DmscozXzjfjk3kDR6Ad+K7I4EUtNgkGHXkI3yXJbx tS0wnnHLRG0u1na0QWLNtH14zUZl1K/hQZG/Yo9FkNeBDajXwFl6+sqLPkgwdJcuFH 5M+LmbJCo15Pg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Xiubo Li , Al Viro , Jeff Layton , Ilya Dryomov , Sasha Levin , ceph-devel@vger.kernel.org Subject: [PATCH AUTOSEL 6.7 32/39] ceph: fix deadlock or deadcode of misusing dget() Date: Sun, 28 Jan 2024 11:10:52 -0500 Message-ID: <20240128161130.200783-32-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240128161130.200783-1-sashal@kernel.org> References: <20240128161130.200783-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.7.2 Content-Transfer-Encoding: 8bit From: Xiubo Li [ Upstream commit b493ad718b1f0357394d2cdecbf00a44a36fa085 ] The lock order is incorrect between denty and its parent, we should always make sure that the parent get the lock first. But since this deadcode is never used and the parent dir will always be set from the callers, let's just remove it. Link: https://lore.kernel.org/r/20231116081919.GZ1957730@ZenIV Reported-by: Al Viro Signed-off-by: Xiubo Li Reviewed-by: Jeff Layton Signed-off-by: Ilya Dryomov Signed-off-by: Sasha Levin --- fs/ceph/caps.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index 2c0b8dc3dd0d..9c02f328c966 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c @@ -4887,13 +4887,15 @@ int ceph_encode_dentry_release(void **p, struct dentry *dentry, struct inode *dir, int mds, int drop, int unless) { - struct dentry *parent = NULL; struct ceph_mds_request_release *rel = *p; struct ceph_dentry_info *di = ceph_dentry(dentry); struct ceph_client *cl; int force = 0; int ret; + /* This shouldn't happen */ + BUG_ON(!dir); + /* * force an record for the directory caps if we have a dentry lease. * this is racy (can't take i_ceph_lock and d_lock together), but it @@ -4903,14 +4905,9 @@ int ceph_encode_dentry_release(void **p, struct dentry *dentry, spin_lock(&dentry->d_lock); if (di->lease_session && di->lease_session->s_mds == mds) force = 1; - if (!dir) { - parent = dget(dentry->d_parent); - dir = d_inode(parent); - } spin_unlock(&dentry->d_lock); ret = ceph_encode_inode_release(p, dir, mds, drop, unless, force); - dput(parent); cl = ceph_inode_to_client(dir); spin_lock(&dentry->d_lock); -- 2.43.0