[PATCH] libceph: fix 32-bit object_base overflow in ceph_osdc_new_request()
From: zhangdaolong
Date: Mon Nov 16 2026 - 01:23:50 EST
In ceph_osdc_new_request(), both 'off' and 'objoff' are 64-bit file
offsets (u64), and 'truncate_size' is also a 64-bit file size (u64).
However, commit 864e9197f10c ("libceph: add CREATE osd operation
support") inadvertently changed 'object_base' from u64 to u32 when
moving its declaration into the extent op branch.
When accessing a file at offset >= 4 GiB (0x100000000ULL), 'object_base'
wraps around modulo 4 GiB. If the file has ever been truncated
(truncate_seq > 1), the per-object truncate_size calculation becomes
corrupted:
1. If truncate_size >= 4 GiB and falls inside the target object,
'truncate_size - object_base' exceeds 4 GiB (> object_size), so the
per-object truncate_size is erroneously clamped to object_size
(e.g. 4 MiB) instead of the intra-object truncate offset. On a write,
this causes the OSD to truncate the object to object_size while
bumping oi.truncate_seq, causing subsequent MDS TRIMTRUNC operations
to be ignored as no-ops and leaving stale post-truncate data intact.
2. If the file was previously truncated below 4 GiB and later extended
past 4 GiB via writes, 'truncate_size <= object_base' can evaluate to
false for objects at >= 4 GiB whose 32-bit wrapped object_base is
smaller than truncate_size, passing a bogus non-zero truncate_size to
those objects.
Change 'object_base' back to u64 to fix the 32-bit truncation overflow.
Fixes: 864e9197f10c ("libceph: add CREATE osd operation support")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: zhangdaolong <dlzhangak@xxxxxxxxxxxxxx>
---
net/ceph/osd_client.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 2ff00070c181..7dfac7aa93e3 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -1090,7 +1090,7 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
osd_req_op_init(req, which, opcode, 0);
} else {
u32 object_size = layout->object_size;
- u32 object_base = off - objoff;
+ u64 object_base = off - objoff;
if (!(truncate_seq == 1 && truncate_size == -1ULL)) {
if (truncate_size <= object_base) {
truncate_size = 0;
--
2.48.1