From: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
To: Nir Muchtar <nirm-smomgflXvOZWk0Htik3J/w@public.gmane.org>
Cc: rolandd-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Moni Shoua <monis-smomgflXvOZWk0Htik3J/w@public.gmane.org>,
Or Gerlitz <ogerlitz-smomgflXvOZWk0Htik3J/w@public.gmane.org>
Subject: Re: [PATCH V2 5/5] RDMA CM: Netlink Client
Date: Wed, 8 Dec 2010 11:23:56 -0700 [thread overview]
Message-ID: <20101208182356.GK16788@obsidianresearch.com> (raw)
In-Reply-To: <1291820122.4715.96.camel@nirm-desktop>
On Wed, Dec 08, 2010 at 04:55:22PM +0200, Nir Muchtar wrote:
> On Tue, 2010-12-07 at 14:29 -0700, Jason Gunthorpe wrote:
>
> > What you've done in your v2 patch won't work if the table you are
> > dumping is too large, once you pass sk_rmem_alloc for the netlink
> > socket it will deadlock. The purpose of dump_start is to avoid that
> > deadlock. (review my past messages on the subject)
> >
> > Your v1 patch wouldn't deadlock, but it would fail to dump with
> > ENOMEM, and provides an avenue to build an unprivileged kernel OOM
> > DOS.
> >
> > The places in the kernel that don't use dump_start have to stay under
> > sk_rmem_alloc.
> >
> > Jason
>
> Sorry, I still need some clarifications...
> When you say deadlocks, do you mean when calling malloc with a lock or
> when overflowing a socket receive buffer?
> For the second case, when we use netlink_unicast, the skbuff is sent and
> freed. It is transferred to the userspace's socket using netlink_sendskb
> and accumulated in its recv buff.
>
> Are you referring to a deadlock there? I still fail to see the issue.
> Why would the kernel socket recv buff reach a limit? Could you please
> elaborate?
Netlink is all driven from user space syscalls.. so it looks like
sendmsg()
[..]
ibnl_rcv_msg
cma_get_stats
[..]
ibnl_unicast
[..]
netlink_attachskb
(now we block on the socket recv queue once it fills)
The deadlock is that userspace is sitting in sendmsg() while the
kernel is sleeping in netlink_attachskb waiting for the recvbuf to
empty.
User space cannot call recvmsg() while it is in blocked in sendmsg()
so it all goes boom.
Even if cma_get_stats was executed from a kernel thread and
ibnl_rcv_msg returned back to userspace you still hold the dev_list
mutex while calling ibnl_unicast, which can sleep waiting on
userspace, which creates an easy DOS against the RDMA CM (I can write
a program that causes the kernel the hold the mutx indefinitely).
You can't hold the mutex while sleeping for userspace, so you have to
unlock it. If you unlock it you have to fixup your position when you
re-lock it. If you can fixup your position then you can use
dump_start.
I don't see malloc being a concern anywhere in what you've done...
Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2010-12-08 18:23 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-29 16:16 [PATCH V2 0/5] IB Netlink Interface and RDMA CM exports Nir Muchtar
[not found] ` <1291047399-430-1-git-send-email-nirm-smomgflXvOZWk0Htik3J/w@public.gmane.org>
2010-11-29 16:16 ` [PATCH V2 1/5] IB Netlink Infrastructure Nir Muchtar
[not found] ` <1291047399-430-2-git-send-email-nirm-smomgflXvOZWk0Htik3J/w@public.gmane.org>
2010-11-29 18:21 ` Jason Gunthorpe
[not found] ` <20101129182159.GB16788-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2010-11-30 12:56 ` Nir Muchtar
2010-11-30 17:51 ` Jason Gunthorpe
[not found] ` <20101130175152.GH16788-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2010-12-01 16:05 ` Nir Muchtar
2010-11-29 16:16 ` [PATCH V2 2/5] IB Core: Error Handler Nir Muchtar
2010-11-29 16:16 ` [PATCH V2 3/5] IB Core: Run Netlink Nir Muchtar
2010-11-29 16:16 ` [PATCH V2 4/5] RDMA CM: Export State Enum Nir Muchtar
2010-11-29 16:16 ` [PATCH V2 5/5] RDMA CM: Netlink Client Nir Muchtar
[not found] ` <1291047399-430-6-git-send-email-nirm-smomgflXvOZWk0Htik3J/w@public.gmane.org>
2010-11-29 19:11 ` Jason Gunthorpe
[not found] ` <20101129191136.GC16788-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2010-11-30 12:34 ` Or Gerlitz
[not found] ` <4CF4EF73.6060406-hKgKHo2Ms0FWk0Htik3J/w@public.gmane.org>
2010-11-30 17:50 ` Jason Gunthorpe
2010-11-30 14:09 ` Nir Muchtar
2010-11-30 18:19 ` Jason Gunthorpe
[not found] ` <20101130181944.GI16788-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2010-12-01 15:58 ` Nir Muchtar
2010-12-01 18:35 ` Jason Gunthorpe
[not found] ` <20101201183538.GQ16788-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2010-12-07 15:40 ` Nir Muchtar
2010-12-07 18:54 ` Jason Gunthorpe
2010-12-07 20:53 ` Nir Muchtar
[not found] ` <7E95F01E94AB484F83061FCFA35B39F8794E3B-QfUkFaTmzUSUvQqKE/ONIwC/G2K4zDHf@public.gmane.org>
2010-12-07 21:29 ` Jason Gunthorpe
[not found] ` <20101207212924.GG16788-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2010-12-08 14:55 ` Nir Muchtar
2010-12-08 18:23 ` Jason Gunthorpe [this message]
[not found] ` <20101208182356.GK16788-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2010-12-09 8:47 ` Nir Muchtar
2010-12-09 17:26 ` Jason Gunthorpe
2010-11-30 16:13 ` Hefty, Sean
[not found] ` <CF9C39F99A89134C9CF9C4CCB68B8DDF25B8924212-osO9UTpF0USkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2010-11-30 19:01 ` Jason Gunthorpe
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=20101208182356.GK16788@obsidianresearch.com \
--to=jgunthorpe-epgobjl8dl3ta4ec/59zmfatqe2ktcn/@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=monis-smomgflXvOZWk0Htik3J/w@public.gmane.org \
--cc=nirm-smomgflXvOZWk0Htik3J/w@public.gmane.org \
--cc=ogerlitz-smomgflXvOZWk0Htik3J/w@public.gmane.org \
--cc=rolandd-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.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