[Devel] [PATCH RH76] tcp: sendpage should not handle Slab objects

Vasily Averin vvs at virtuozzo.com
Mon Mar 4 08:40:07 MSK 2019


According to network guru .sendpage should not handle Slab objects.
The patch helps to detects such incidents, generates warning
and switch processing to safe .sendmsg callback.

https://jira.sw.ru/browse/PSBM-90529
Signed-off-by: Vasily Averin <vvs at virtuozo.com>
-------------- next part --------------
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index e74c83789279..d22300e025d8 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -887,6 +887,11 @@ static 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 (PageSlab(page)) {
+		WARN_ONCE(true, "sendpage should not handle Slab objects,"
+				" please fix callers\n");
+		return sock_no_sendpage_locked(sk, page, offset, size, flags);
+	}
 	/* 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