Skip to contentSkip to conversation

drbd: reject oversized DataReply before signed conversion

PATCH In review Tianchu Chen 2 participants 2 messages Jun 30 – Jul 10

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drbd: reject oversized DataReply before signed conversion

From: Tianchu Chen <[email protected]>

Discovered by Atuin - Automated Vulnerability Discovery Engine.

Reject DataReply payload lengths that cannot fit in recv_dless_read()'s signed size argument so a bogus remote peer cannot wrap the length negative and turn it into a huge heap OOB-write.

Fixes b411b3637fa7 ("The DRBD driver")
---
 drivers/block/drbd/drbd_receiver.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/block/drbd/drbd_receiver.c +4 -0
index 58b95bf4b..5bd3df483 100644
@@ -24,6 +24,7 @@
 #include <linux/memcontrol.h>
 #include <linux/mm_inline.h>
 #include <linux/slab.h>
+#include <linux/limits.h>
 #include <uapi/linux/sched/types.h>
 #include <linux/sched/signal.h>
 #include <linux/pkt_sched.h>
@@ -1947,6 +1948,9 @@ static int receive_DataReply(struct drbd_connection *connection, struct packet_i
 	if (unlikely(!req))
 		return -EIO;
 
+	if (pi->size > INT_MAX)
+		return -EINVAL;
+
 	err = recv_dless_read(peer_device, req, sector, pi->size);
 	if (!err)
 		req_mod(req, DATA_RECEIVED, peer_device);
Signature · 1 line
2.51.0
#1 lore raw
Quoted 11 lines · Tianchu Chen

From: Tianchu Chen <[email protected]>

Discovered by Atuin - Automated Vulnerability Discovery Engine.

Reject DataReply payload lengths that cannot fit in recv_dless_read()'s signed size argument so a bogus remote peer cannot wrap the length negative and turn it into a huge heap OOB-write.

Fixes b411b3637fa7 ("The DRBD driver")

This is similar to [0], but the mentioned patch is a more complete fix. There is also a case in recv_dless_read where data_size can underflow when a data-integrity-alg is configured.

The other patch catches this case as well by placing the guard later, so I would prefer to apply that one instead of this.

Thanks,
Christoph

[0] https://lore.kernel.org/all/[email protected]/