]> git.baikalelectronics.ru Git - kernel.git/commitdiff
tcp: correctly handle increased zerocopy args struct size
authorArjun Roy <arjunroy@google.com>
Thu, 10 Dec 2020 19:16:03 +0000 (11:16 -0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 10 Dec 2020 21:10:32 +0000 (13:10 -0800)
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.")
Signed-off-by: Arjun Roy <arjunroy@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/tcp.c

index 3c99d48b65d8d77989972176dadb7284d5c31ef3..ed42d2193c5c76bc9d48f36c13e72ca5be8aee1f 100644 (file)
@@ -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):