stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Eric Dumazet <edumazet@google.com>,
	Jann Horn <jannh@google.com>, Florian Westphal <fw@strlen.de>,
	Peter Oskolkov <posk@google.com>, Paolo Abeni <pabeni@redhat.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: [PATCH 4.9 19/32] inet: frag: enforce memory limits earlier
Date: Sat,  4 Aug 2018 11:01:09 +0200	[thread overview]
Message-ID: <20180804082650.927952982@linuxfoundation.org> (raw)
In-Reply-To: <20180804082649.908295462@linuxfoundation.org>

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Eric Dumazet <edumazet@google.com>

[ Upstream commit 56e2c94f055d328f5f6b0a5c1721cca2f2d4e0a1 ]

We currently check current frags memory usage only when
a new frag queue is created. This allows attackers to first
consume the memory budget (default : 4 MB) creating thousands
of frag queues, then sending tiny skbs to exceed high_thresh
limit by 2 to 3 order of magnitude.

Note that before commit 648700f76b03 ("inet: frags: use rhashtables
for reassembly units"), work queue could be starved under DOS,
getting no cpu cycles.
After commit 648700f76b03, only the per frag queue timer can eventually
remove an incomplete frag queue and its skbs.

Fixes: b13d3cbfb8e8 ("inet: frag: move eviction of queues to work queue")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Jann Horn <jannh@google.com>
Cc: Florian Westphal <fw@strlen.de>
Cc: Peter Oskolkov <posk@google.com>
Cc: Paolo Abeni <pabeni@redhat.com>
Acked-by: Florian Westphal <fw@strlen.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/ipv4/inet_fragment.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

--- a/net/ipv4/inet_fragment.c
+++ b/net/ipv4/inet_fragment.c
@@ -356,11 +356,6 @@ static struct inet_frag_queue *inet_frag
 {
 	struct inet_frag_queue *q;
 
-	if (!nf->high_thresh || frag_mem_limit(nf) > nf->high_thresh) {
-		inet_frag_schedule_worker(f);
-		return NULL;
-	}
-
 	q = kmem_cache_zalloc(f->frags_cachep, GFP_ATOMIC);
 	if (!q)
 		return NULL;
@@ -397,6 +392,11 @@ struct inet_frag_queue *inet_frag_find(s
 	struct inet_frag_queue *q;
 	int depth = 0;
 
+	if (!nf->high_thresh || frag_mem_limit(nf) > nf->high_thresh) {
+		inet_frag_schedule_worker(f);
+		return NULL;
+	}
+
 	if (frag_mem_limit(nf) > nf->low_thresh)
 		inet_frag_schedule_worker(f);
 

  parent reply	other threads:[~2018-08-04  9:01 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-04  9:00 [PATCH 4.9 00/32] 4.9.118-stable review Greg Kroah-Hartman
2018-08-04  9:00 ` [PATCH 4.9 01/32] ipv4: remove BUG_ON() from fib_compute_spec_dst Greg Kroah-Hartman
2018-08-04  9:00 ` [PATCH 4.9 02/32] net: ena: Fix use of uninitialized DMA address bits field Greg Kroah-Hartman
2018-08-04  9:00 ` [PATCH 4.9 03/32] net: fix amd-xgbe flow-control issue Greg Kroah-Hartman
2018-08-04  9:00 ` [PATCH 4.9 04/32] net: lan78xx: fix rx handling before first packet is send Greg Kroah-Hartman
2018-08-04  9:00 ` [PATCH 4.9 05/32] net: mdio-mux: bcm-iproc: fix wrong getter and setter pair Greg Kroah-Hartman
2018-08-04  9:00 ` [PATCH 4.9 06/32] NET: stmmac: align DMA stuff to largest cache line length Greg Kroah-Hartman
2018-08-04  9:00 ` [PATCH 4.9 07/32] tcp_bbr: fix bw probing to raise in-flight data for very small BDPs Greg Kroah-Hartman
2018-08-04  9:00 ` [PATCH 4.9 08/32] xen-netfront: wait xenbus state change when load module manually Greg Kroah-Hartman
2018-08-04  9:00 ` [PATCH 4.9 09/32] netlink: Do not subscribe to non-existent groups Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.9 10/32] netlink: Dont shift with UB on nlk->ngroups Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.9 11/32] tcp: do not force quickack when receiving out-of-order packets Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.9 12/32] tcp: add max_quickacks param to tcp_incr_quickack and tcp_enter_quickack_mode Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.9 13/32] tcp: do not aggressively quick ack after ECN events Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.9 14/32] tcp: refactor tcp_ecn_check_ce to remove sk type cast Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.9 15/32] tcp: add one more quick ack after after ECN events Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.9 16/32] pinctrl: intel: Read back TX buffer state Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.9 17/32] sched/wait: Remove the lockless swait_active() check in swake_up*() Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.9 18/32] bonding: avoid lockdep confusion in bond_get_stats() Greg Kroah-Hartman
2018-08-04  9:01 ` Greg Kroah-Hartman [this message]
2018-08-04  9:01 ` [PATCH 4.9 20/32] ipv4: frags: handle possible skb truesize change Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.9 21/32] net: dsa: Do not suspend/resume closed slave_dev Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.9 22/32] netlink: Fix spectre v1 gadget in netlink_create() Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.9 23/32] net: stmmac: Fix WoL for PCI-based setups Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.9 24/32] squashfs: more metadata hardening Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.9 26/32] can: ems_usb: Fix memory leak on ems_usb_disconnect() Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.9 27/32] net: socket: fix potential spectre v1 gadget in socketcall Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.9 28/32] virtio_balloon: fix another race between migration and ballooning Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.9 29/32] kvm: x86: vmx: fix vpid leak Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.9 30/32] crypto: padlock-aes - Fix Nano workaround data corruption Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.9 31/32] drm/vc4: Reset ->{x, y}_scaling[1] when dealing with uniplanar formats Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.9 32/32] scsi: sg: fix minor memory leak in error path Greg Kroah-Hartman
2018-08-04  9:30 ` [PATCH 4.9 00/32] 4.9.118-stable review Nathan Chancellor
2018-08-04 12:44   ` Greg Kroah-Hartman
2018-08-04 14:47 ` Guenter Roeck
2018-08-05 11:53 ` Naresh Kamboju

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=20180804082650.927952982@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=fw@strlen.de \
    --cc=jannh@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=posk@google.com \
    --cc=stable@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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).