From: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Subject: [RFC] [PATCH] net: account for possible negative frag_mem_limit
Date: Thu, 2 Mar 2017 12:37:52 +0500 [thread overview]
Message-ID: <1488440272-10915-1-git-send-email-valentine.sinitsyn@gmail.com> (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
reply other threads:[~2017-03-02 7:38 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1488440272-10915-1-git-send-email-valentine.sinitsyn@gmail.com \
--to=valentine.sinitsyn@gmail.com \
--cc=linux-kernel@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).