[Devel] [PATCH RH8 5/7] tcp: detecting the misuse of .sendpage for Slab objects
Andrey Zhadchenko
andrey.zhadchenko at virtuozzo.com
Tue Jun 8 20:01:18 MSK 2021
From: Vasily Averin <vvs at virtuozzo.com>
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>
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 4196685..538d63c 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.
--
1.8.3.1
More information about the Devel
mailing list