From nobody Wed Oct 8 09:28:28 2025
Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172])
(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 AA9721A76DE;
Mon, 30 Jun 2025 10:15:19 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
arc=none smtp.client-ip=80.241.56.172
ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
t=1751278521; cv=none;
b=AHOxwNQdOaYgAH9ZKNGywN2nRWhpkIWi30bNCI2QGPY+TIdOxapn3go+fT2FuRGg1CY1QW6U1dWc00Ue+VO7IeHmRPv0ClEDPJyzg1iwFItmB+NKI1OR4siJjg6oIL91LLNMPFQO7M7J/hIe3VQ3UF7SATdbf1+nY6jsVG/y/uY=
ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
s=arc-20240116; t=1751278521; c=relaxed/simple;
bh=y/4YjTLWuIy0IC8lYRZeKfAEdR7HI1gNocKw3PUC0G4=;
h=From:To:Cc:Subject:Date:Message-ID:MIME-Version;
b=uQY791xGa1q8vYfRYl7t+vlrxxPEweusCgbwgakkbXXBij6CNi6QwX+6F+FI8z1UTavOdvWs+To2ecAJDlvhOUujsxOyZVDT6ff6pVlM7fIojS4e1h86qwXUPy8o1rzuUyAjsv/WNFB9aXnbi8c2vvJ/6/OcC2vEsLdkHgHYEJQ=
ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=fail (p=none dis=none) header.from=samsung.com;
spf=pass smtp.mailfrom=pankajraghav.com;
arc=none smtp.client-ip=80.241.56.172
Authentication-Results: smtp.subspace.kernel.org;
dmarc=fail (p=none dis=none) header.from=samsung.com
Authentication-Results: smtp.subspace.kernel.org;
spf=pass smtp.mailfrom=pankajraghav.com
Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest
SHA256)
(No client certificate requested)
by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4bW28z4SQ0z9syT;
Mon, 30 Jun 2025 12:15:15 +0200 (CEST)
From: Pankaj Raghav
To: Alexander Viro ,
Jan Kara ,
mcgrof@kernel.org,
Christian Brauner
Cc: Baokun Li ,
linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org,
gost.dev@samsung.com,
kernel@pankajraghav.com,
Zhang Yi ,
Pankaj Raghav
Subject: [PATCH] fs/libfs: don't assume blocksize <= PAGE_SIZE in
generic_check_addressable
Date: Mon, 30 Jun 2025 12:15:09 +0200
Message-ID: <20250630101509.212291-1-p.raghav@samsung.com>
Precedence: bulk
X-Mailing-List: linux-kernel@vger.kernel.org
List-Id:
List-Subscribe:
List-Unsubscribe:
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="utf-8"
Since [1], it is possible for filesystems to have blocksize > PAGE_SIZE
of the system.
Remove the assumption and make the check generic for all blocksizes in
generic_check_addressable().
[1] https://lore.kernel.org/linux-xfs/20240822135018.1931258-1-kernel@panka=
jraghav.com/
Signed-off-by: Pankaj Raghav
Reviewed-by: Jan Kara
---
fs/libfs.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/fs/libfs.c b/fs/libfs.c
index 4d1862f589e8..81756dc0be6d 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -1584,13 +1584,17 @@ EXPORT_SYMBOL(generic_file_fsync);
int generic_check_addressable(unsigned blocksize_bits, u64 num_blocks)
{
u64 last_fs_block =3D num_blocks - 1;
- u64 last_fs_page =3D
- last_fs_block >> (PAGE_SHIFT - blocksize_bits);
+ u64 last_fs_page, max_bytes;
+
+ if (check_shl_overflow(num_blocks, blocksize_bits, &max_bytes))
+ return -EFBIG;
+
+ last_fs_page =3D (max_bytes >> PAGE_SHIFT) - 1;
=20
if (unlikely(num_blocks =3D=3D 0))
return 0;
=20
- if ((blocksize_bits < 9) || (blocksize_bits > PAGE_SHIFT))
+ if ((blocksize_bits < 9))
return -EINVAL;
=20
if ((last_fs_block > (sector_t)(~0ULL) >> (blocksize_bits - 9)) ||
base-commit: b39f7d75dc41b5f5d028192cd5d66cff71179f35
--=20
2.49.0