Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1590897

[RFC] [PATCH] net: account for possible negative frag_mem_limit

Path csiph.com!goblin3!goblin1!goblin.stu.neva.ru!news.mixmin.net!aioe.org!bofh.it!news.nic.it!robomod
From Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Newsgroups linux.kernel
Subject [RFC] [PATCH] net: account for possible negative frag_mem_limit
Date Thu, 02 Mar 2017 08:40:01 +0100
Message-ID <tgtvb-7o3-7@gated-at.bofh.it> (permalink)
X-Original-To linux-kernel@vger.kernel.org
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=KqA4bY+S/0FtdEPSc+/tn1gfJraw4TToT2+exUzam+k=; b=TTYZSG+aj+FMvP+6cyo8Mq1SUKMMro7F8rVkpN+SVSDq7pPWgbGvd5Nc0mkV9HtdzM 4zxGEntq4Fd+q7cophmFSe91KDmHWbn8WM8RTS9uppNPMzhOWy7oPlzlwHUBhmOegrhn PDVOoXt8yccWyhXiHAcHKskVQWwrXwELX4eiM6NqMncuJZAI1XpqJMZWe/6QeD73B2jf F/Ktyi8Kf5F/fCJyq9os1ccxw5NLOuWpa3QLJ+UmC+Wa31gySw9IxgsrEzDR62iEf57w yIXMFL1lwhqShTKmJXZlvwJEkZ8yczs7eN9oB628XYDJHQjU8IfpS9VxS2Uga/N/ZJg7 lfJQ==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=KqA4bY+S/0FtdEPSc+/tn1gfJraw4TToT2+exUzam+k=; b=j+DkZzJNuSJ1OymBh25SvvAkB3fgV8bSp/ug25sBRZwaQUaaLJ2meN6LnRucD42cFG T3C0mu9nro5kWljx7jHpPuw+bJWg7b/yPG32/hDQTJ5TQmNRPH83qY2AZzay3ObMPcLu gBNpZKetLDuT54SkHf4+d3BRbNdPW9abRZE9ISmEyZy1x4HGi7t5IomWAZIKpmpWZdsJ 5HS7CxSok4hyoM5NK4uN2pdVOw1WQUCFCNaZm/obE8JW1u738rWAeGUOwpL/hgvAjqsU 8zf211ZJGMxK1xfbeqLhRKC4EYtM+jE3kS5BaXbyIB5YSAcn/h4YWL/z0AyjiAiNzWvw GDJw==
X-Gm-Message-State AMke39k/HSOqFWFLfNCJXz/w5+9AX/I39LZ95voLjydBR004JZRovoTWi31DUU10/h93Rg==
X-Received by 10.25.229.156 with SMTP id i28mr3913156lfk.11.1488440287278; Wed, 01 Mar 2017 23:38:07 -0800 (PST)
X-Mailer git-send-email 2.7.4
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 36
Organization linux.* mail to news gateway
X-Original-Cc Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
X-Original-Date Thu, 2 Mar 2017 12:37:52 +0500
X-Original-Message-ID <1488440272-10915-1-git-send-email-valentine.sinitsyn@gmail.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1590897

Show key headers only | View raw


I'm also not sure if we'd better disable bottom halves before
calculating the counter sum, as sum_frag_mem_limit() does.

--- 8< ---

On SMP systems, percpu_counter_sum() is permitted to return negative
values. However, inet_frag_exit_net() function is following the
assumption that its return value is either positive or zero.

If a negative value is returned, the code loops forever, possibly
keeping net_mutex locked. This could break many things, including
unshare(CLONE_NEWNET) system call which would hang forever.

Fix this by explicitly asking for a positive return value from the
percpu counter.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
---
 net/ipv4/inet_fragment.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c
index b5e9317..0a63c9e 100644
--- a/net/ipv4/inet_fragment.c
+++ b/net/ipv4/inet_fragment.c
@@ -234,7 +234,7 @@ void inet_frags_exit_net(struct netns_frags *nf, struct inet_frags *f)
 	cond_resched();
 
 	if (read_seqretry(&f->rnd_seqlock, seq) ||
-	    percpu_counter_sum(&nf->mem))
+	    percpu_counter_sum_positive(&nf->mem))
 		goto evict_again;
 
 	percpu_counter_destroy(&nf->mem);
-- 
2.7.4

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[RFC] [PATCH] net: account for possible negative frag_mem_limit Valentine Sinitsyn <valentine.sinitsyn@gmail.com> - 2017-03-02 08:40 +0100

csiph-web