Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2473287lqp; Sun, 24 Mar 2024 22:17:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXZar9iLxMGKcqmRWg0rmvi+uN6Hd73SAAOaQForqA2W0dgGYN6V/JUZf9dhJWDIhjecE++gM8LFibjNiiq02xEMrQ+Tf3R7upREtJZzg== X-Google-Smtp-Source: AGHT+IF/GuOPYP7PH8zsvtMrtErMw0MfzzqxlVjNXA9OkimeXqsyNdma+KpE5y8ilU5oi9C0REPC X-Received: by 2002:a05:6214:258e:b0:691:4bdc:aa48 with SMTP id fq14-20020a056214258e00b006914bdcaa48mr5880795qvb.54.1711343868334; Sun, 24 Mar 2024 22:17:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711343868; cv=pass; d=google.com; s=arc-20160816; b=Mcl+wqSvETyARxZA74khoHybL8w/gOzR/opPHkh0p1LLZlh07zVKcsxeaqBr9sNgDl jXY3Af/wEf8RDgzVfmakv3RbyQJTUih9DSMdZ5Aq1BH9xkyly0UIOWg/ZrIx0Tf37YUo B/3iznv9hHO2yC5YmGKSftfOcl6xbCoQ3CKLpnGrDUszn+nIv8vKz4cfvLOq887F9L9W oBE9lWmvHsoFg+l7ho/zLyzNh+gIPRGbn+wfYeJYzqyF6ImmYmxqUjCOh11UWTuYAHYI iMNXD8W5v2lCQRJFeXE39WtWHRuLqS88IHCT2YYaINYX0vWAnuHhhRAg7/6wocIEEPqG 4FSA== 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=PpNIAgoP+OpUzDJmWaTHsfLj+QZbHvjS0ghkaY5lBJk=; fh=NVKc5ZZl6X0lYLMFsMlzIpqP/8TJzD/ivie5x3u1DGk=; b=gx1eC7wFaRjQY8IJ+fRdS7Ur2UBRA9eX5seAoGy93rCxW2CxhtQWwwqW+xdMpMK/I5 HwT/sWZEMFIr+f8w4gTSiALrlFsNzqqECCrF4g33ChG/Hi/YHmdqJWyl+FBlX82aT5+J ZITtmtEs+VGOBa4BSZt530f4EW4MerZ5PQx7nhZKRQ3141RJtEK0Brxn+L6KdMCDrRZO R96TCbt7/vCqdDIxdTd6UC9thOLZFJLWJck5HuS6mGE/Yy6DBSTVZPLjTsFqHeHGb8gP BdE+Q8f5bDi0i9iCJ7Jev1+rRiuGKKlP0SFFZnXB/kteAzXG+la1D7dFNxAu8i8kKwo0 ayww==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Xw/L3Nds"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113737-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113737-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id kc16-20020a056214411000b00690c93e36f9si7078526qvb.425.2024.03.24.22.17.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 22:17:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113737-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Xw/L3Nds"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113737-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113737-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 078FB1C2B0F9 for ; Mon, 25 Mar 2024 05:17:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3E70B12B14D; Sun, 24 Mar 2024 22:55:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Xw/L3Nds" 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 94E701DF116; Sun, 24 Mar 2024 22:52:26 +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=1711320746; cv=none; b=SohsFxRurIiN1LkNse/ODVNhitX9gcs228Yx2o01iz5aRl4APDGl3/2hcJGVtReLJUFqLPPWv1jMihFVnfBL+iuByD3snC93qZIcJ91vT0GDmVqGbhLO+FRyNYXvg9Ao5f07RFV3PPJC0q891OuqBKQ2a1WnwOGC+4OIz1EGslY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320746; c=relaxed/simple; bh=7eHIBbjxTnJNAvBe7y538hijttessdfvGCLOEmFqKzo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RhH6wPB0ZRzOzIt0eIpL3ipgbm+OjFLjjUfgfkScGEEcuSH0/14i3FWkWaKoo8B9/hmzuq5mFrqp+ozePcDlLTlmvoroz1Xt6WtvjIWCIy/pa/g4qUUmlTHx80+G3/e8608tkFFLQuUoX/SH7JDj99/yOQUzzTKgDv+Df+M7Q50= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Xw/L3Nds; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC128C433F1; Sun, 24 Mar 2024 22:52:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320746; bh=7eHIBbjxTnJNAvBe7y538hijttessdfvGCLOEmFqKzo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xw/L3NdsvnXbYLORT1fC4q2VRTKnCzw4UIAv/xTXVgw7hudzCuv5QGsGrkx3kRA9V zOZkZoGbAwsuUtevdELl2IdQYCVqbETBiAqv7lb84u3OEvAHvvgQ4eFSaXKOl1b/n/ kkINSv/zyhtSg1KjA1M78BJiCTWXPiJOyvu8YnwdQCqesu/sLAxZfS6JBISn6fNbEi 2xMgVdRTg0h2wRnnbszKj4adAAW1Ml4UXEZbPYzRiohaCq2lZHXjDAD3+JrLThb9Nm xlHZaCfzPCNEiJ8lhWBEM4nC3w48QFxNX9UFjGEvwlF1SG1kGxYbfuRxQ526P8NYtp hu9dKZCmq+QHw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kees Cook , Alexander Viro Subject: [PATCH 6.7 310/713] pstore: inode: Only d_invalidate() is needed Date: Sun, 24 Mar 2024 18:40:36 -0400 Message-ID: <20240324224720.1345309-311-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324224720.1345309-1-sashal@kernel.org> References: <20240324224720.1345309-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 Content-Transfer-Encoding: 8bit From: Kees Cook [ Upstream commit a43e0fc5e9134a46515de2f2f8d4100b74e50de3 ] Unloading a modular pstore backend with records in pstorefs would trigger the dput() double-drop warning: WARNING: CPU: 0 PID: 2569 at fs/dcache.c:762 dput.part.0+0x3f3/0x410 Using the combo of d_drop()/dput() (as mentioned in Documentation/filesystems/vfs.rst) isn't the right approach here, and leads to the reference counting problem seen above. Use d_invalidate() and update the code to not bother checking for error codes that can never happen. Suggested-by: Alexander Viro Fixes: 609e28bb139e ("pstore: Remove filesystem records when backend is unregistered") Signed-off-by: Kees Cook --- fs/pstore/inode.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c index 4b4686c593996..4ca72b08d919a 100644 --- a/fs/pstore/inode.c +++ b/fs/pstore/inode.c @@ -306,7 +306,6 @@ int pstore_put_backend_records(struct pstore_info *psi) { struct pstore_private *pos, *tmp; struct dentry *root; - int rc = 0; root = psinfo_lock_root(); if (!root) @@ -316,11 +315,8 @@ int pstore_put_backend_records(struct pstore_info *psi) list_for_each_entry_safe(pos, tmp, &records_list, list) { if (pos->record->psi == psi) { list_del_init(&pos->list); - rc = simple_unlink(d_inode(root), pos->dentry); - if (WARN_ON(rc)) - break; - d_drop(pos->dentry); - dput(pos->dentry); + d_invalidate(pos->dentry); + simple_unlink(d_inode(root), pos->dentry); pos->dentry = NULL; } } @@ -328,7 +324,7 @@ int pstore_put_backend_records(struct pstore_info *psi) inode_unlock(d_inode(root)); - return rc; + return 0; } /* -- 2.43.0