[RH76] tcp: sendpage should not handle Slab objects

Submitted by Vasily Averin on March 4, 2019, 5:40 a.m.

Details

Message ID 9099c0a1-2aba-71d0-7124-78b975b8b7d6@virtuozzo.com
State New
Series "tcp: sendpage should not handle Slab objects"
Headers show

Commit Message

Vasily Averin March 4, 2019, 5:40 a.m.
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@virtuozo.com>

Patch hide | download patch | download mbox

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.