Skip to content

Commit

Permalink
tcp: detecting the misuse of .sendpage for Slab objects
Browse files Browse the repository at this point in the history
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@virtuozzo.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Vasily Averin authored and David S. Miller committed Mar 6, 2019
1 parent 7b83762 commit a10674b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions net/ipv4/tcp.c
Original file line number Diff line number Diff line change
@@ -943,6 +943,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.

0 comments on commit a10674b

Please sign in to comment.