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 601504C6E; Mon, 23 Jun 2025 13:33:51 +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=1750685631; cv=none; b=I+lv5PEmHc3fO6L8VSYGnIWE5aUEo0k7CtKoA71mY4uv6OGxVq7P6h5PsOcckj73kWxqy7b90C1g6cqELfL323lfP3a07rrVjWBWikIZC5ExCY6eyDhvEFIvcLyWgwWIzt3C9AJ2goC8XaQ86JK4DfaZgcqBCty5sYasMCS84R4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750685631; c=relaxed/simple; bh=xAkdDISWyMgQwWE1nAclAhbiYEAdQbRRjYArRi//S9A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bb9gVwuKme8EbFuUC7AP3i2Jv6PnTwwdMH6hutPntsSqD7QIfUxmwzJTuFjsDXKgRzfNghJtNSoHAc4t3RotOVQL6ccEwLB9O7RZfM+uRPbpfvewS7x/qFPv3QNjwCG95lZTrHnqlKEYqu2NtzRpuSfxSr54M8V8d+z9j/bU4L4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=QS/qDEGk; 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="QS/qDEGk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8765C4CEEA; Mon, 23 Jun 2025 13:33:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750685631; bh=xAkdDISWyMgQwWE1nAclAhbiYEAdQbRRjYArRi//S9A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QS/qDEGkh7238/AJdsJF72NfTWI7OJALCVjqR2JqDl3hKQWMDNKlshiJLQGy7ZNCG 8pCMqL/0+KpfVxB8TJ9s7/Z9NkE0L3YYnBGvFhGyBHGWdjtEd3JpXQbHDLu4k5QOTx lYLas6bDGbGTmfN1j5GVOHXdUE0NspuOB91+vLRc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Wentao Liang , Ryusuke Konishi , Andrew Morton , Sasha Levin Subject: [PATCH 5.10 064/355] nilfs2: add pointer check for nilfs_direct_propagate() Date: Mon, 23 Jun 2025 15:04:25 +0200 Message-ID: <20250623130628.754027634@linuxfoundation.org> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250623130626.716971725@linuxfoundation.org> References: <20250623130626.716971725@linuxfoundation.org> User-Agent: quilt/0.68 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 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Wentao Liang [ Upstream commit f43f02429295486059605997bc43803527d69791 ] Patch series "nilfs2: improve sanity checks in dirty state propagation". This fixes one missed check for block mapping anomalies and one improper return of an error code during a preparation step for log writing, thereby improving checking for filesystem corruption on writeback. This patch (of 2): In nilfs_direct_propagate(), the printer get from nilfs_direct_get_ptr() need to be checked to ensure it is not an invalid pointer. If the pointer value obtained by nilfs_direct_get_ptr() is NILFS_BMAP_INVALID_PTR, means that the metadata (in this case, i_bmap in the nilfs_inode_info struct) that should point to the data block at the buffer head of the argument is corrupted and the data block is orphaned, meaning that the file system has lost consistency. Add a value check and return -EINVAL when it is an invalid pointer. Link: https://lkml.kernel.org/r/20250428173808.6452-1-konishi.ryusuke@gmail.com Link: https://lkml.kernel.org/r/20250428173808.6452-2-konishi.ryusuke@gmail.com Fixes: 36a580eb489f ("nilfs2: direct block mapping") Signed-off-by: Wentao Liang Signed-off-by: Ryusuke Konishi Signed-off-by: Andrew Morton Signed-off-by: Sasha Levin --- fs/nilfs2/direct.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/nilfs2/direct.c b/fs/nilfs2/direct.c index 7faf8c285d6c9..a72371cd6b956 100644 --- a/fs/nilfs2/direct.c +++ b/fs/nilfs2/direct.c @@ -273,6 +273,9 @@ static int nilfs_direct_propagate(struct nilfs_bmap *bmap, dat = nilfs_bmap_get_dat(bmap); key = nilfs_bmap_data_get_key(bmap, bh); ptr = nilfs_direct_get_ptr(bmap, key); + if (ptr == NILFS_BMAP_INVALID_PTR) + return -EINVAL; + if (!buffer_nilfs_volatile(bh)) { oldreq.pr_entry_nr = ptr; newreq.pr_entry_nr = ptr; -- 2.39.5