From: David Miller <davem@davemloft.net>
To: dhowells@redhat.com
Cc: netdev@vger.kernel.org, linux-afs@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] rxrpc: Fix net namespace cleanup
Date: Tue, 30 Apr 2019 10:53:06 -0400 (EDT) [thread overview]
Message-ID: <20190430.105306.1978317247998825768.davem@davemloft.net> (raw)
In-Reply-To: <155660964874.18872.7446174793302616529.stgit@warthog.procyon.org.uk>
From: David Howells <dhowells@redhat.com>
Date: Tue, 30 Apr 2019 08:34:08 +0100
> In rxrpc_destroy_all_calls(), there are two phases: (1) make sure the
> ->calls list is empty, emitting error messages if not, and (2) wait for the
> RCU cleanup to happen on outstanding calls (ie. ->nr_calls becomes 0).
>
> To avoid taking the call_lock, the function prechecks ->calls and if empty,
> it returns to avoid taking the lock - this is wrong, however: it still
> needs to go and do the second phase and wait for ->nr_calls to become 0.
>
> Without this, the rxrpc_net struct may get deallocated before we get to the
> RCU cleanup for the last calls. This can lead to:
>
> Slab corruption (Not tainted): kmalloc-16k start=ffff88802b178000, len=16384
> 050: 6b 6b 6b 6b 6b 6b 6b 6b 61 6b 6b 6b 6b 6b 6b 6b kkkkkkkkakkkkkkk
>
> Note the "61" at offset 0x58. This corresponds to the ->nr_calls member of
> struct rxrpc_net (which is >9k in size, and thus allocated out of the 16k
> slab).
>
>
> Fix this by flipping the condition on the if-statement, putting the locked
> section inside the if-body and dropping the return from there. The
> function will then always go on to wait for the RCU cleanup on outstanding
> calls.
>
> Fixes: 2baec2c3f854 ("rxrpc: Support network namespacing")
> Signed-off-by: David Howells <dhowells@redhat.com>
Applied and queued up for -stable, thanks.
next prev parent reply other threads:[~2019-04-30 14:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-30 7:34 [PATCH net] rxrpc: Fix net namespace cleanup David Howells
2019-04-30 14:53 ` David Miller [this message]
-- strict thread matches above, loose matches on Subject: below --
2019-04-29 21:57 David Howells
2019-04-30 7:34 ` David Howells
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=20190430.105306.1978317247998825768.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=dhowells@redhat.com \
--cc=linux-afs@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--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
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).