public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Jarek Poplawski <jarkao2@gmail•com>
To: Peter Zijlstra <a.p.zijlstra@chello•nl>
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:08:46 +0000	[thread overview]
Message-ID: <20090127090846.GD4197@ff.dom.local> (raw)
In-Reply-To: <1233046369.4984.5.camel@laptop>

On Tue, Jan 27, 2009 at 09:52:49AM +0100, Peter Zijlstra wrote:
> 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?
> 

Since it's really needed, and Vegard started doing it like this, I
guess he will try to add the missing pieces.

Thanks again,
Jarek P.

  reply	other threads:[~2009-01-27  9:08 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
2009-01-27  9:08         ` Jarek Poplawski [this message]
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=20090127090846.GD4197@ff.dom.local \
    --to=jarkao2@gmail$(echo .)com \
    --cc=a.p.zijlstra@chello$(echo .)nl \
    --cc=davem@davemloft$(echo .)net \
    --cc=mmokrejs@ribosome$(echo .)natur.cuni.cz \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=vegard.nossum@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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