[RH76,v2] tcp: sendpage should not handle Slab objects

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

Details

Message ID d93b832a-9ff1-9619-6a34-1d6229922887@virtuozzo.com
State New
Series "tcp: sendpage should not handle Slab objects"
Headers show

Commit Message

Vasily Averin March 4, 2019, 5:50 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.

v2: properly backported to rhel76 kernel

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..dcfaf4ff70e1 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1006,6 +1006,13 @@  int tcp_sendpage(struct sock *sk, struct page *page, int offset,
 		return sock_no_sendpage(sk->sk_socket, page, offset, size,
 					flags);
 
+	if (PageSlab(page)) {
+		WARN_ONCE(true, "sendpage should not handle Slab objects,"
+				" please fix callers\n");
+		return sock_no_sendpage(sk->sk_socket, page, offset, size,
+					flags);
+	}
+
 	lock_sock(sk);
 	res = do_tcp_sendpages(sk, page, offset, size, flags);
 	release_sock(sk);