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 CBBB076C70; Wed, 21 Feb 2024 13:18:14 +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=1708521494; cv=none; b=gVkZRBd/dr9McZ/OoPVJu8CjxicRlrhYRkLDRQ9fZrksYlR8pgQnl3qb/AV2rNcxn8DpD4t2m3mXE6aVO84lsdBA22PfHQ4ORUsFLQ8aRlmuFQPR2XyvoMAiBW6EakJHQwUng3293BQEqHeL2TL7Xu0GmjTs7HxZGP/BltBlKFs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708521494; c=relaxed/simple; bh=m3iVq532Ay4FQ8ypfOTBhTNlv8dF5EUOOhfBR27s0To=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X7dq7QGzF0B66XjGzNcc+KjEr1hosdCne2f4t8Hx98GubdTBjcr28qHv+3lNy6iKe0XCr2Dq+DenDg0aXEZ6Ly4YvZV5O7CCjesPye2pkV9LhixxwoNIdByhbnxPowdHSI1YQdPrRN/fDX6TGUhs+BH8nm36I11vw/p2VyIrEcE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=2ty6cHpl; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="2ty6cHpl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39441C433C7; Wed, 21 Feb 2024 13:18:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1708521494; bh=m3iVq532Ay4FQ8ypfOTBhTNlv8dF5EUOOhfBR27s0To=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2ty6cHpl5aU9oI3K2JDa99QgB3rRPGT4mxLr9elebcAlXbm5h0sbNFYkHSUpvJYSN 3ywWrl5avQArkZYvEHWmkS1J6akpkJKw9mF5Cvc8ByN/RDReROgWCoUKsuHV9ydJk6 uE0iIMJuoNFUFHzudQIJ8fpWvC0n0djge2003sbg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Al Viro , Xiubo Li , Jeff Layton , Ilya Dryomov , Sasha Levin Subject: [PATCH 4.19 127/202] ceph: fix deadlock or deadcode of misusing dget() Date: Wed, 21 Feb 2024 14:07:08 +0100 Message-ID: <20240221125935.806996812@linuxfoundation.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240221125931.742034354@linuxfoundation.org> References: <20240221125931.742034354@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ 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 fcfba2af5f98..729a67700a4f 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c @@ -4216,12 +4216,14 @@ 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); 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 @@ -4231,14 +4233,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); spin_lock(&dentry->d_lock); if (ret && di->lease_session && di->lease_session->s_mds == mds) { -- 2.43.0