[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200818131227.37020-4-colyli@suse.de>
Date: Tue, 18 Aug 2020 21:12:24 +0800
From: Coly Li <colyli@...e.de>
To: linux-block@...r.kernel.org, linux-nvme@...ts.infradead.org,
netdev@...r.kernel.org, open-iscsi@...glegroups.com,
linux-scsi@...r.kernel.org, ceph-devel@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, Coly Li <colyli@...e.de>,
Eric Dumazet <eric.dumazet@...il.com>,
Vasily Averin <vvs@...tuozzo.com>,
"David S . Miller" <davem@...emloft.net>, stable@...r.kernel.org
Subject: [PATCH v7 3/6] tcp: use sendpage_ok() to detect misused .sendpage
commit a10674bf2406 ("tcp: detecting the misuse of .sendpage for Slab
objects") adds the checks for Slab pages, but the pages don't have
page_count are still missing from the check.
Network layer's sendpage method is not designed to send page_count 0
pages neither, therefore both PageSlab() and page_count() should be
both checked for the sending page. This is exactly what sendpage_ok()
does.
This patch uses sendpage_ok() in do_tcp_sendpages() to detect misused
.sendpage, to make the code more robust.
Fixes: a10674bf2406 ("tcp: detecting the misuse of .sendpage for Slab objects")
Suggested-by: Eric Dumazet <eric.dumazet@...il.com>
Signed-off-by: Coly Li <colyli@...e.de>
Cc: Vasily Averin <vvs@...tuozzo.com>
Cc: David S. Miller <davem@...emloft.net>
Cc: stable@...r.kernel.org
---
net/ipv4/tcp.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 31f3b858db81..2135ee7c806d 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -970,7 +970,8 @@ ssize_t do_tcp_sendpages(struct sock *sk, struct page *page, int offset,
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"))
+ WARN_ONCE(!sendpage_ok(page),
+ "page must not be a Slab one and have page_count > 0"))
return -EINVAL;
/* Wait for a connection to finish. One exception is TCP Fast Open
--
2.26.2
Powered by blists - more mailing lists