Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drbd: fix null-pointer dereference on local read error

In drbd_request_endio(), READ_COMPLETED_WITH_ERROR is passed to
__req_mod() with a NULL peer_device:

__req_mod(req, what, NULL, &m);

The READ_COMPLETED_WITH_ERROR handler then unconditionally passes this
NULL peer_device to drbd_set_out_of_sync(), which dereferences it,
causing a null-pointer dereference.

Fix this by obtaining the peer_device via first_peer_device(device),
matching how drbd_req_destroy() handles the same situation.

Cc: stable@vger.kernel.org
Reported-by: Tuo Li <islituo@gmail.com>
Link: https://lore.kernel.org/linux-block/20260104165355.151864-1-islituo@gmail.com
Signed-off-by: Christoph Böhmwalder <christoph.boehmwalder@linbit.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Christoph Böhmwalder and committed by
Jens Axboe
0d195d3b 81b1f046

+2 -1
+2 -1
drivers/block/drbd/drbd_req.c
··· 621 621 break; 622 622 623 623 case READ_COMPLETED_WITH_ERROR: 624 - drbd_set_out_of_sync(peer_device, req->i.sector, req->i.size); 624 + drbd_set_out_of_sync(first_peer_device(device), 625 + req->i.sector, req->i.size); 625 626 drbd_report_io_error(device, req); 626 627 __drbd_chk_io_error(device, DRBD_READ_ERROR); 627 628 fallthrough;