[PATCH 0/2] drbd: validate payload sizes received from the peer

From: Yibo Liu

Date: Thu Oct 15 2026 - 18:28:50 EST


Two places in the DRBD receive path take a payload size from the peer's
packet header and use it without comparing it to the size they expect.
Commit bd910a7660d2 ("drbd: reject data replies with an out-of-range
payload size") already rejects negative sizes in recv_dless_read();
these patches cover the remaining cases:

1/2 rejects a P_DATA_REPLY whose size differs from the read request.
A short reply currently completes the read successfully with part
of the bio never written.

2/2 rejects P_CSUM_RS_REQUEST and P_OV_REPLY packets whose digest
length does not match the configured algorithm, and makes the
worker compare digests only when their sizes match. A short digest
currently causes an out-of-bounds read in memcmp(), and a huge one
triggers a page allocator warning.

Like the earlier fixes, this only matters for a peer that does not
follow the protocol; a correct peer always sends the expected sizes.

The problems were found with the help of an AI coding assistant and
were reproduced on block-7.3 before posting (details below the "---" of
each patch). Testing:
- before/after runs of the reproducer in an arm64 virtme-ng KASAN guest
- a complete csums-alg resync and an online verify as regression tests
- each patch built with W=1 and sparse (C=2), arm64, gcc 13.3: no new
warnings
- checkpatch.pl --strict clean
Not built with clang or for other architectures.

Yibo Liu (2):
drbd: reject data replies whose size does not match the request
drbd: validate digest size in checksum resync and verify requests

drivers/block/drbd/drbd_receiver.c | 14 ++++++++++++--
drivers/block/drbd/drbd_worker.c | 8 ++++----
2 files changed, 16 insertions(+), 6 deletions(-)


base-commit: 41cab3a71dc7be62114d91cc849424879062d324
--
2.39.5 (Apple Git-154)