From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Jarek Poplawski <jarkao2@gmail.com>
Cc: "Martin MOKREJŠ" <mmokrejs@ribosome.natur.cuni.cz>,
"Vegard Nossum" <vegard.nossum@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org
Subject: Re: [PATCH] net: fix setsockopt() locking errors
Date: Tue, 27 Jan 2009 09:52:49 +0100 [thread overview]
Message-ID: <1233046369.4984.5.camel@laptop> (raw)
In-Reply-To: <20090127084525.GC4197@ff.dom.local>
On Tue, 2009-01-27 at 08:45 +0000, Jarek Poplawski wrote:
> On Mon, Jan 26, 2009 at 10:30:30PM +0100, Martin MOKREJŠ wrote:
> > The patch really did not help:
> > http://bugzilla.kernel.org/show_bug.cgi?id=12515#c5
> > Martin
>
> Actually, there is a little change: the warning triggerd in another
> place (sock_setsockopt() -> sk_attach_filter()). So we could go deeper
> with these changes, but I'm not sure this is the right way to fix.
>
> It looks like the scenario is very old, but probably wasn't reported
> (maybe there is some lockdep improvement):
Yes, they likely are very old, and yes we added a lockdep annotation to
copy_to/from_user() to catch these.
> A) sys_mmap2() -> mm->mmap_sem -> packet_mmap() -> sk_lock
> B) sock_setsockopt() -> sk_lock -> copy_from_user() -> mm->mmap_sem
>
> packet_mmap() (net/packet/af_packet.c) seems to be the only place in
> net to implement mmap method, and using this lock order btw. On the
> other hand copy_from_user() could be more popular under sk_lock, and
> I'm not sure these changes are necessary.
>
> Since I don't know enough neither sock/packet nor sys_mmap, I guess
> some advice would be precious. It looks like Peter Zijlstra solved
> similar problems in nfs, so I CC him.
The NFS/sunrpc case was special in that it did copy_to/from_kernel, that
is, it never actually touched user memory -- we taught the might_fault()
annotation about that.
Can't you simply do the copy_from_user() before you take the sk_lock?
next prev parent reply other threads:[~2009-01-27 8:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-24 22:49 [PATCH] net: fix setsockopt() locking errors Vegard Nossum
2009-01-26 11:50 ` Jarek Poplawski
2009-01-26 20:33 ` David Miller
2009-01-27 16:25 ` Vegard Nossum
2009-01-26 21:30 ` Martin MOKREJŠ
2009-01-27 8:45 ` Jarek Poplawski
2009-01-27 8:52 ` Peter Zijlstra [this message]
2009-01-27 9:08 ` Jarek Poplawski
2009-01-30 6:12 ` Herbert Xu
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=1233046369.4984.5.camel@laptop \
--to=a.p.zijlstra@chello.nl \
--cc=davem@davemloft.net \
--cc=jarkao2@gmail.com \
--cc=mmokrejs@ribosome.natur.cuni.cz \
--cc=netdev@vger.kernel.org \
--cc=vegard.nossum@gmail.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