[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200819051945.1797088-1-hch@lst.de>
Date: Wed, 19 Aug 2020 07:19:45 +0200
From: Christoph Hellwig <hch@....de>
To: davem@...emloft.net, kuba@...nel.org
Cc: colyli@...e.de, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] net: bypass ->sendpage for slab pages
Sending Slab or tail pages into ->sendpage will cause really strange
delayed oops. Prevent it right in the networking code instead of
requiring drivers to guess the exact conditions where sendpage works.
Based on a patch from Coly Li <colyli@...e.de>.
Signed-off-by: Christoph Hellwig <hch@....de>
---
net/socket.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/net/socket.c b/net/socket.c
index dbbe8ea7d395da..b4e65688915fe3 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -3638,7 +3638,11 @@ EXPORT_SYMBOL(kernel_getpeername);
int kernel_sendpage(struct socket *sock, struct page *page, int offset,
size_t size, int flags)
{
- if (sock->ops->sendpage)
+ /* sendpage does manipulates the refcount of the sent in page, which
+ * does not work for Slab pages, or for tails of non-__GFP_COMP
+ * high order pages.
+ */
+ if (sock->ops->sendpage && !PageSlab(page) && page_count(page) > 0)
return sock->ops->sendpage(sock, page, offset, size, flags);
return sock_no_sendpage(sock, page, offset, size, flags);
--
2.28.0
Powered by blists - more mailing lists