Netdev Archive on lore.kernel.org
 help / color / Atom feed
From: Vasily Averin <vvs@virtuozzo.com>
To: Eric Dumazet <edumazet@google.com>, netdev@vger.kernel.org
Subject: [PATCH] tcp: detect use sendpage for slab-based objects
Date: Thu, 21 Feb 2019 18:30:17 +0300
Message-ID: <a8655149-80b9-c75d-6528-0b851ea85de8@virtuozzo.com> (raw)

There was few incidents when XFS over network block device generates
IO requests with slab-based metadata. If these requests are processed
via sendpage path tcp_sendpage() calls skb_can_coalesce() and merges
neighbour slab objects into one skb fragment.

If receiving side is located on the same host tcp_recvmsg() can trigger
following BUG_ON
usercopy: kernel memory exposure attempt detected
		from XXXXXX (kmalloc-512) (1024 bytes)

This patch helps to detect the reason of similar incidents on sending side.

Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
---
 net/ipv4/tcp.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 2079145a3b7c..cf9572f4fc0f 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -996,6 +996,7 @@ ssize_t do_tcp_sendpages(struct sock *sk, struct page *page, int offset,
 			goto wait_for_memory;
 
 		if (can_coalesce) {
+			WARN_ON_ONCE(PageSlab(page));
 			skb_frag_size_add(&skb_shinfo(skb)->frags[i - 1], copy);
 		} else {
 			get_page(page);
-- 
2.17.1


             reply index

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-21 15:30 Vasily Averin [this message]
2019-02-21 16:00 ` Eric Dumazet
2019-02-22 14:02   ` Vasily Averin
2019-02-22 16:39     ` Eric Dumazet
2019-02-25  9:15       ` Vasily Averin
2019-02-25  9:32         ` Vasily Averin
2019-03-04 12:58   ` Vasily Averin
2019-03-04 15:51     ` Eric Dumazet
2019-03-05 14:24       ` Vasily Averin
     [not found]         ` <CANn89iKss+mzwbeZgy3Bzct6sBe3UeyezXXGocAYtOe9pP8a9w@mail.gmail.com>
2019-03-05 15:11           ` Eric Dumazet
2019-03-05 16:44             ` Eric Dumazet
2019-03-05 18:35               ` Vasily Averin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a8655149-80b9-c75d-6528-0b851ea85de8@virtuozzo.com \
    --to=vvs@virtuozzo.com \
    --cc=edumazet@google.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Netdev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/netdev/0 netdev/git/0.git
	git clone --mirror https://lore.kernel.org/netdev/1 netdev/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 netdev netdev/ https://lore.kernel.org/netdev \
		netdev@vger.kernel.org
	public-inbox-index netdev

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.netdev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git