From: NeilBrown <neilb@suse.com>
To: Olga Kornievskaia <aglo@umich.edu>
Cc: Trond Myklebust <trond.myklebust@primarydata.com>,
Anna Schumaker <anna.schumaker@netapp.com>,
linux-nfs <linux-nfs@vger.kernel.org>,
Olga Kornievskaia <kolga@netapp.com>
Subject: Re: [PATCH] SUNRPC: fix refcounting problems with auth_gss messages.
Date: Wed, 07 Dec 2016 09:12:59 +1100 [thread overview]
Message-ID: <87wpfc4sgk.fsf@notabene.neil.brown.name> (raw)
In-Reply-To: <CAN-5tyHT9X9ULCDT0iPkMtgo4eMiRLVGVuzabmZXMePv8FwXFw@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1551 bytes --]
On Wed, Dec 07 2016, Olga Kornievskaia wrote:
>>>
>>> Agreed. This is a problem.
>>>
>>> Doesn't the problem still exist even with this patch because
>>> gss_add_msg() adds the msg onto the in_downcall() list? So gssd in
>>> __gss_fin_upcall() can find the 2nd upcall even before the 2nd msg is
>>> added to the pipe->pipe()?
>>
>> The use-after-free problem is solved I think. It doesn't really make
>> any difference if the down-call arrives before or after
>> rpc_queue_upcall() is called. The msg will still not be freed before it
>> is removed from both lists.
>>
>
> Sorry I don't see it.
Maybe we are looking at different code?
>
> Thread 1 adds an upcall and it's getting processed by gssd.
> Thread 2 executes gss_add_msg() which puts the message on the
> in_downcall list. Context switch (before the atomic_inc()!).
gss_add_msg(), as of 4.9-rc8, is
spin_lock(&pipe->lock);
old = __gss_find_upcall(pipe, gss_msg->uid, gss_msg->auth);
if (old == NULL) {
atomic_inc(&gss_msg->count);
list_add(&gss_msg->list, &pipe->in_downcall);
} else
gss_msg = old;
spin_unlock(&pipe->lock);
so the gss_msg is added to in_downcall *after* the atomic_inc(), and the
whole is protected by pipe->lock anyway so even if the atomic_inc() were
delayed by the CPU reordering things, there would be no risk of
gss_pipe_downcall() finding a gss_msg which didn't have the ->count
elevated.
NeilBrown
> Upcall comes back from the gssd, finds msg from Thread2 in_downcall
> list. gss_release_msg() will dec the counter to 0 and will remove the
> msg.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
next prev parent reply other threads:[~2016-12-06 22:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-05 4:10 [PATCH] SUNRPC: fix refcounting problems with auth_gss messages NeilBrown
2016-12-05 17:29 ` Olga Kornievskaia
2016-12-05 22:04 ` NeilBrown
2016-12-06 18:07 ` Olga Kornievskaia
2016-12-06 22:12 ` NeilBrown [this message]
2016-12-07 14:58 ` Olga Kornievskaia
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=87wpfc4sgk.fsf@notabene.neil.brown.name \
--to=neilb@suse.com \
--cc=aglo@umich.edu \
--cc=anna.schumaker@netapp.com \
--cc=kolga@netapp.com \
--cc=linux-nfs@vger.kernel.org \
--cc=trond.myklebust@primarydata.com \
/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).