Skip to content

drbd: validate payload sizes received from the peer - #1452

Open
ghost wants to merge 2 commits into
linus-master_basefrom
series/1186806=>linus-master
Open

ghost wants to merge 2 commits into
linus-master_basefrom
series/1186806=>linus-master

Conversation

@ghost

@ghost ghost commented Oct 15, 2026

Copy link
Copy Markdown

Pull request for series with
subject: drbd: validate payload sizes received from the peer
version: 1
url: https://patchwork.kernel.org/series/1186806/

@ghost

ghost commented Oct 15, 2026

Copy link
Copy Markdown
Author

Upstream branch: 0fcb05b
series: https://patchwork.kernel.org/series/1186806/
version: 1

@ghost

ghost commented Oct 17, 2026

Copy link
Copy Markdown
Author

Upstream branch: 58161ea
series: https://patchwork.kernel.org/series/1186806/
version: 1

@ghost
ghost force-pushed the series/1186806=>linus-master branch from 820dcd2 to be05164 Compare October 17, 2026 03:50
@ghost
ghost force-pushed the linus-master_base branch from 3d027d5 to 90ea7e4 Compare October 19, 2026 00:00
@ghost

ghost commented Oct 19, 2026

Copy link
Copy Markdown
Author

Upstream branch: c03c1a1
series: https://patchwork.kernel.org/series/1186806/
version: 1

@ghost
ghost force-pushed the series/1186806=>linus-master branch from be05164 to b90aea2 Compare October 19, 2026 00:32
@ghost
ghost force-pushed the linus-master_base branch from 90ea7e4 to 435b194 Compare October 22, 2026 07:21
@ghost

ghost commented Oct 22, 2026

Copy link
Copy Markdown
Author

Upstream branch: 7be4bc5
series: https://patchwork.kernel.org/series/1186806/
version: 1

@ghost
ghost force-pushed the series/1186806=>linus-master branch from b90aea2 to 6e1bff8 Compare October 22, 2026 07:51
@ghost
ghost force-pushed the linus-master_base branch from 435b194 to fd67522 Compare October 24, 2026 03:36
@ghost

ghost commented Oct 24, 2026

Copy link
Copy Markdown
Author

Upstream branch: 17bb0e2
series: https://patchwork.kernel.org/series/1186806/
version: 1

@ghost
ghost force-pushed the series/1186806=>linus-master branch from 6e1bff8 to 60d06c1 Compare October 24, 2026 03:56
@ghost
ghost force-pushed the linus-master_base branch from fd67522 to 3b53a63 Compare October 26, 2026 01:52
@ghost

ghost commented Oct 26, 2026

Copy link
Copy Markdown
Author

Upstream branch: 21a7f44
series: https://patchwork.kernel.org/series/1186806/
version: 1

@ghost
ghost force-pushed the series/1186806=>linus-master branch from 60d06c1 to c96b068 Compare October 26, 2026 02:21
@ghost
ghost force-pushed the linus-master_base branch from 3b53a63 to 5d84576 Compare October 26, 2026 07:01
@ghost

ghost commented Oct 26, 2026

Copy link
Copy Markdown
Author

Upstream branch: 6b4b543
series: https://patchwork.kernel.org/series/1186806/
version: 1

@ghost
ghost force-pushed the series/1186806=>linus-master branch from c96b068 to 71bf901 Compare October 26, 2026 07:25
@ghost
ghost force-pushed the linus-master_base branch from 5d84576 to 6582ed2 Compare October 26, 2026 18:11
@ghost

ghost commented Oct 26, 2026

Copy link
Copy Markdown
Author

Upstream branch: fb2c3f4
series: https://patchwork.kernel.org/series/1186806/
version: 1

@ghost
ghost force-pushed the series/1186806=>linus-master branch from 71bf901 to 5cab3e4 Compare October 26, 2026 18:53
@ghost
ghost force-pushed the linus-master_base branch from 6582ed2 to b3a1abc Compare October 26, 2026 23:55
@ghost

ghost commented Oct 27, 2026

Copy link
Copy Markdown
Author

Upstream branch: d135ab4
series: https://patchwork.kernel.org/series/1186806/
version: 1

@ghost
ghost force-pushed the series/1186806=>linus-master branch from 5cab3e4 to 83fe410 Compare October 27, 2026 00:15
@ghost
ghost force-pushed the linus-master_base branch from b3a1abc to 712496f Compare October 28, 2026 23:34
@ghost

ghost commented Oct 28, 2026

Copy link
Copy Markdown
Author

Upstream branch: c339f40
series: https://patchwork.kernel.org/series/1186806/
version: 1

@ghost
ghost force-pushed the series/1186806=>linus-master branch from 83fe410 to 2a399e4 Compare October 28, 2026 23:55
@ghost
ghost force-pushed the linus-master_base branch from 712496f to a186880 Compare October 30, 2026 13:52
@ghost

ghost commented Oct 30, 2026

Copy link
Copy Markdown
Author

Upstream branch: d89e1d1
series: https://patchwork.kernel.org/series/1186806/
version: 1

@ghost
ghost force-pushed the series/1186806=>linus-master branch from 2a399e4 to 1d53022 Compare October 30, 2026 14:19
@ghost
ghost force-pushed the linus-master_base branch from a186880 to 46206a3 Compare November 2, 2026 17:14
@ghost

ghost commented Nov 2, 2026

Copy link
Copy Markdown
Author

Upstream branch: 6628e7d
series: https://patchwork.kernel.org/series/1186806/
version: 1

@ghost
ghost force-pushed the series/1186806=>linus-master branch from 1d53022 to 65b7443 Compare November 2, 2026 17:57
@ghost
ghost force-pushed the linus-master_base branch from 46206a3 to 220bd96 Compare November 3, 2026 23:41
@ghost

ghost commented Nov 4, 2026

Copy link
Copy Markdown
Author

Upstream branch: 05441d6
series: https://patchwork.kernel.org/series/1186806/
version: 1

@ghost
ghost force-pushed the series/1186806=>linus-master branch from 65b7443 to 986f16c Compare November 4, 2026 00:10
@ghost
ghost force-pushed the linus-master_base branch from 220bd96 to 6c4625e Compare November 6, 2026 08:02
@ghost

ghost commented Nov 6, 2026

Copy link
Copy Markdown
Author

Upstream branch: f66469d
series: https://patchwork.kernel.org/series/1186806/
version: 1

@ghost
ghost force-pushed the series/1186806=>linus-master branch from 986f16c to 93438f2 Compare November 6, 2026 08:50
@ghost
ghost force-pushed the linus-master_base branch from 6c4625e to c7f678d Compare November 7, 2026 03:08
@ghost

ghost commented Nov 7, 2026

Copy link
Copy Markdown
Author

Upstream branch: d487237
series: https://patchwork.kernel.org/series/1186806/
version: 1

@ghost
ghost force-pushed the series/1186806=>linus-master branch from 93438f2 to dbccb74 Compare November 7, 2026 03:47
@ghost
ghost force-pushed the linus-master_base branch from c7f678d to 6aa6cd1 Compare November 10, 2026 07:53
A node that reads from its peer (it has no local disk, the area is not
up to date locally, or read-balancing chose the peer) sends a
P_DATA_REQUEST for req->i.size bytes, and recv_dless_read() copies the
matching P_DATA_REPLY into the original bio. Commit bd910a7
("drbd: reject data replies with an out-of-range payload size") rejects
a negative payload size, but a reply that is shorter or longer than the
request is still accepted.

A shorter reply only fills the start of the bio. data_size still drops
to zero in the copy loop, so the final D_ASSERT() does not fire, and
the read completes successfully although the rest of the caller's
buffer was never written. With a proxy that cut one reply down to
1 KiB, a 4 KiB O_DIRECT read returned 4096 with the last 3 KiB of the
buffer unchanged and nothing in the kernel log. A longer reply leaves
the excess in the socket, where it is parsed as the next packet header.

A correct peer always replies with exactly the requested size. Reject
any other size, as is already done for negative sizes.

Fixes: b411b36 ("The DRBD driver")
Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Yibo Liu <yiboliume@gmail.com>
receive_DataRequest() takes the digest length of P_CSUM_RS_REQUEST and
P_OV_REPLY packets from the packet header and passes it to kmalloc()
without any check. The worker later compares the received digest with
one computed by the local csums or verify algorithm. A size mismatch is
only reported by D_ASSERT(), and memcmp() runs anyway.

A digest that is shorter than the algorithm's digest size therefore
makes w_e_end_csum_rs_req() and w_e_end_ov_reply() read past the end of
the digest_info allocation:

  BUG: KASAN: slab-out-of-bounds in memcmp+0x1b8/0x1d8
  Read of size 8 at addr ffff00000a638610 by task drbd_w_r1/212
  Call trace:
   memcmp
   w_e_end_csum_rs_req
   drbd_worker
  Allocated by task 240:
   __kmalloc_noprof
   receive_DataRequest
   drbd_receiver

A digest length larger than the page allocator can serve triggers the
WARN_ON_ONCE() for oversized allocations, as GFP_NOIO does not include
__GFP_NOWARN:

  WARNING: mm/page_alloc.c:5340 at __alloc_frozen_pages_noprof
  Call trace:
   ___kmalloc_large_node
   __kmalloc_noprof
   receive_DataRequest
   drbd_receiver

Reject these packets unless the digest length matches the digest size
of the configured csums or verify algorithm, and also reject them when
no such algorithm is configured. In the worker, only compare digests of
the same size: the peer can switch csums-alg or verify-alg with
P_SYNC_PARAM after the request was received, and a size mismatch is
then treated as "not in sync" instead of reading out of bounds.

Fixes: b411b36 ("The DRBD driver")
Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Yibo Liu <yiboliume@gmail.com>
@ghost

ghost commented Nov 10, 2026

Copy link
Copy Markdown
Author

Upstream branch: b3dfbde
series: https://patchwork.kernel.org/series/1186806/
version: 1

@ghost
ghost force-pushed the series/1186806=>linus-master branch from dbccb74 to 64d1f7b Compare November 10, 2026 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant