[RHEL7,COMMIT] tcp: sendpage should not handle Slab objects

Submitted by Konstantin Khorenko on March 4, 2019, 2:18 p.m.

Details

Message ID 201903041418.x24EIqie002221@finist-ce7.sw.ru
State New
Series "tcp: sendpage should not handle Slab objects"
Headers show

Commit Message

Konstantin Khorenko March 4, 2019, 2:18 p.m.
The commit is pushed to "branch-rh7-3.10.0-957.5.1.vz7.84.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.5.1.vz7.84.2
------>
commit 6c05ade2b7ac2a01139a35d4bef3e838f741368f
Author: Vasily Averin <vvs@virtuozzo.com>
Date:   Mon Mar 4 17:18:52 2019 +0300

    tcp: sendpage should not handle Slab objects
    
    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>
---
 net/ipv4/tcp.c | 7 +++++++
 1 file changed, 7 insertions(+)

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);