[Devel] [PATCH RHEL8 COMMIT] ms/tcp: detecting the misuse of .sendpage for Slab objects

Konstantin Khorenko khorenko at virtuozzo.com
Fri Jun 11 15:33:48 MSK 2021


The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.40
------>
commit 03b54cdf1b6808ee010c27d1b205e2800dc120a9
Author: Vasily Averin <vvs at virtuozzo.com>
Date:   Fri Jun 11 15:33:48 2021 +0300

    ms/tcp: detecting the misuse of .sendpage for Slab objects
    
    sendpage was not designed for processing of the Slab pages,
    in some situations it can trigger BUG_ON on receiving side.
    
    Signed-off-by: Vasily Averin <vvs at virtuozzo.com>
    
    Signed-off-by: Eric Dumazet <edumazet at google.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>
    
    (cherry-picked from ms a10674bf2406 ("tcp: detecting the misuse of .sendpage for
    Slab objects"))
    Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
---
 net/ipv4/tcp.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 419668569530..538d63ca58c5 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -961,6 +961,10 @@ ssize_t do_tcp_sendpages(struct sock *sk, struct page *page, int offset,
 	ssize_t copied;
 	long timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT);
 
+	if (IS_ENABLED(CONFIG_DEBUG_VM) &&
+	    WARN_ONCE(PageSlab(page), "page must not be a Slab one"))
+		return -EINVAL;
+
 	/* Wait for a connection to finish. One exception is TCP Fast Open
 	 * (passive side) where data is allowed to be sent before a connection
 	 * is fully established.


More information about the Devel mailing list