From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Sumit Semwal <sumit.semwal@linaro.org>
Cc: NeilBrown <neilb@suse.com>,
stable@vger.kernel.org,
Trond Myklebust <trond.myklebust@primarydata.com>
Subject: Re: [v2 PATCH for-4.4 04/16] SUNRPC: fix refcounting problems with auth_gss messages.
Date: Sun, 16 Apr 2017 12:30:10 +0200 [thread overview]
Message-ID: <20170416103010.GA6117@kroah.com> (raw)
In-Reply-To: <CAO_48GHUULUtHcvhkvxOr_tQ=q1vu+EVK3Ed09Bu3OsJpvC_CA@mail.gmail.com>
On Sun, Apr 16, 2017 at 01:34:22PM +0530, Sumit Semwal wrote:
> Hi Greg,
>
>
>
> On Apr 16, 2017 13:29, "Greg KH" <gregkh@linuxfoundation.org> wrote:
>
> On Wed, Apr 12, 2017 at 11:13:38PM +0530, Sumit Semwal wrote:
> > From: NeilBrown <neilb@suse.com>
> >
> > [ Upstream commit 1cded9d2974fe4fe339fc0ccd6638b80d465ab2c ]
> >
> > There are two problems with refcounting of auth_gss messages.
> >
> > First, the reference on the pipe->pipe list (taken by a call
> > to rpc_queue_upcall()) is not counted.� It seems to be
> > assumed that a message in pipe->pipe will always also be in
> > pipe->in_downcall, where it is correctly reference counted.
> >
> > However there is no guaranty of this.� I have a report of a
> > NULL dereferences in rpc_pipe_read() which suggests a msg
> > that has been freed is still on the pipe->pipe list.
> >
> > One way I imagine this might happen is:
> > - message is queued for uid=U and auth->service=S1
> > - rpc.gssd reads this message and starts processing.
> >� �This removes the message from pipe->pipe
> > - message is queued for uid=U and auth->service=S2
> > - rpc.gssd replies to the first message. gss_pipe_downcall()
> >� �calls __gss_find_upcall(pipe, U, NULL) and it finds the
> >� �*second* message, as new messages are placed at the head
> >� �of ->in_downcall, and the service type is not checked.
> > - This second message is removed from ->in_downcall and freed
> >� �by gss_release_msg() (even though it is still on pipe->pipe)
> > - rpc.gssd tries to read another message, and dereferences a pointer
> >� �to this message that has just been freed.
> >
> > I fix this by incrementing the reference count before calling
> > rpc_queue_upcall(), and decrementing it if that fails, or normally in
> > gss_pipe_destroy_msg().
> >
> > It seems strange that the reply doesn't target the message more
> > precisely, but I don't know all the details.� In any case, I think the
> > reference counting irregularity became a measureable bug when the
> > extra arg was added to __gss_find_upcall(), hence the Fixes: line
> > below.
> >
> > The second problem is that if rpc_queue_upcall() fails, the new
> > message is not freed. gss_alloc_msg() set the ->count to 1,
> > gss_add_msg() increments this to 2, gss_unhash_msg() decrements to 1,
> > then the pointer is discarded so the memory never gets freed.
> >
> > Fixes: 9130b8dbc6ac ("SUNRPC: allow for upcalls for same uid but
> different gss service")
> > Cc: stable@vger.kernel.org
> > Link: https://bugzilla.opensuse.org/show_bug.cgi?id=1011250
> > Signed-off-by: NeilBrown <neilb@suse.com>
> > Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
> > Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
> > ---
> >� net/sunrpc/auth_gss/auth_gss.c | 7 ++++++-
> >� 1 file changed, 6 insertions(+), 1 deletion(-)
>
> This patch is already in 4.9.2!� Something went really wrong with your
> patch selection here, why are you sending patches I already have?
>
> That's true, it's there in 4.9.2, but this patch is marked for 4.4, right?
Doh, that's what I get for working on patches this early, sorry for the
noise...
I'll get to these after this next round of stable kernels go out.
thanks,
greg k-h
next prev parent reply other threads:[~2017-04-16 10:30 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-12 17:43 [v2 PATCH for-4.4 00/16] Stable commits from Ubuntu Xenial 4.4-lts Sumit Semwal
2017-04-12 17:43 ` [v2 PATCH for-4.4 01/16] net/mlx4_core: Fix when to save some qp context flags for dynamic VST to VGT transitions Sumit Semwal
2017-04-12 17:43 ` [v2 PATCH for-4.4 02/16] net/mlx4_core: Fix racy CQ (Completion Queue) free Sumit Semwal
2017-04-12 17:43 ` [v2 PATCH for-4.4 03/16] net/mlx4_en: Fix bad WQE issue Sumit Semwal
2017-04-12 17:43 ` [v2 PATCH for-4.4 04/16] SUNRPC: fix refcounting problems with auth_gss messages Sumit Semwal
2017-04-16 7:59 ` Greg KH
[not found] ` <CAO_48GHUULUtHcvhkvxOr_tQ=q1vu+EVK3Ed09Bu3OsJpvC_CA@mail.gmail.com>
2017-04-16 10:30 ` Greg Kroah-Hartman [this message]
2017-04-12 17:43 ` [v2 PATCH for-4.4 05/16] ibmveth: set correct gso_size and gso_type Sumit Semwal
2017-04-12 17:43 ` [v2 PATCH for-4.4 06/16] ibmveth: calculate gso_segs for large packets Sumit Semwal
2017-04-12 17:43 ` [v2 PATCH for-4.4 07/16] Drivers: hv: get rid of redundant messagecount in create_gpadl_header() Sumit Semwal
2017-04-16 8:00 ` Greg KH
2017-04-17 14:49 ` Sumit Semwal
2017-04-19 12:58 ` Greg KH
2017-04-20 5:34 ` Sumit Semwal
2017-04-12 17:43 ` [v2 PATCH for-4.4 08/16] Drivers: hv: don't leak memory in vmbus_establish_gpadl() Sumit Semwal
2017-04-12 17:43 ` [v2 PATCH for-4.4 09/16] Drivers: hv: get rid of timeout in vmbus_open() Sumit Semwal
2017-04-12 17:43 ` [v2 PATCH for-4.4 10/16] Drivers: hv: vmbus: Reduce the delay between retries in vmbus_post_msg() Sumit Semwal
2017-04-12 17:43 ` [v2 PATCH for-4.4 11/16] Tools: hv: kvp: ensure kvp device fd is closed on exec Sumit Semwal
2017-04-12 17:43 ` [v2 PATCH for-4.4 12/16] Drivers: hv: balloon: keep track of where ha_region starts Sumit Semwal
2017-04-12 17:43 ` [v2 PATCH for-4.4 13/16] Drivers: hv: balloon: account for gaps in hot add regions Sumit Semwal
2017-04-12 17:43 ` [v2 PATCH for-4.4 14/16] hv: don't reset hv_context.tsc_page on crash Sumit Semwal
2017-04-12 17:43 ` [v2 PATCH for-4.4 15/16] blk-mq: Avoid memory reclaim when remapping queues Sumit Semwal
2017-04-12 17:43 ` [v2 PATCH for-4.4 16/16] usb: hub: Wait for connection to be reestablished after port reset Sumit Semwal
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=20170416103010.GA6117@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=neilb@suse.com \
--cc=stable@vger.kernel.org \
--cc=sumit.semwal@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.