Skip to contentSkip to conversation

tcp: correctly handle increased zerocopy args struct size

net-next Applied Arjun Roy 2 participants 2 messages Dec 10, 2020

Subsystems (3)
lore
Share & tools
lore

Arjun Roy

author
#0 lore raw

From: Arjun Roy <[email protected]>

A prior patch increased the size of struct tcp_zerocopy_receive but did not update do_tcp_getsockopt() handling to properly account for this.

This patch simply reintroduces content erroneously cut from the referenced prior patch that handles the new struct size.

Fixes 18fb76ed5386 ("net-zerocopy: Copy straggler unaligned data for TCP Rx. zerocopy.")
---
 net/ipv4/tcp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/ipv4/tcp.c +2 -2
index 3c99d48b65d8..ed42d2193c5c 100644
@@ -4082,7 +4082,7 @@ static int do_tcp_getsockopt(struct sock *sk, int level,
 	}
 #ifdef CONFIG_MMU
 	case TCP_ZEROCOPY_RECEIVE: {
-		struct tcp_zerocopy_receive zc;
+		struct tcp_zerocopy_receive zc = {};
 		int err;
 
 		if (get_user(len, optlen))
@@ -4099,7 +4099,7 @@ static int do_tcp_getsockopt(struct sock *sk, int level,
 		lock_sock(sk);
 		err = tcp_zerocopy_receive(sk, &zc);
 		release_sock(sk);
-		if (len == sizeof(zc))
+		if (len >= offsetofend(struct tcp_zerocopy_receive, err))
 			goto zerocopy_rcv_sk_err;
 		switch (len) {
 		case offsetofend(struct tcp_zerocopy_receive, err):
Signature · 1 line
2.29.2.576.ga3fc446d84-goog
maintainer Applied
#1 lore raw

From: Arjun Roy <[email protected]>
Date: Thu, 10 Dec 2020 11:16:03 -0800

Quoted 6 lines

From: Arjun Roy <[email protected]>

A prior patch increased the size of struct tcp_zerocopy_receive but did not update do_tcp_getsockopt() handling to properly account for this.

Quoted 7 lines

This patch simply reintroduces content erroneously cut from the referenced prior patch that handles the new struct size.

Fixes 18fb76ed5386 ("net-zerocopy: Copy straggler unaligned data for TCP Rx. zerocopy.")

Applied.