From: Al Viro <viro@ZenIV.linux.org.uk>
To: Patrick McHardy <kaber@trash.net>
Cc: netdev@vger.kernel.org
Subject: Re: buggy check in netlink_mmap_sendmsg()
Date: Fri, 19 Jul 2013 16:52:09 +0100 [thread overview]
Message-ID: <20130719155209.GG4165@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20130719153846.GB14764@macbook.localnet>
On Fri, Jul 19, 2013 at 05:38:46PM +0200, Patrick McHardy wrote:
> On Thu, Jul 18, 2013 at 01:13:58PM +0200, Patrick McHardy wrote:
> > On Sun, Jul 14, 2013 at 10:36:19AM +0100, Al Viro wrote:
> > > This
> > > /* Netlink messages are validated by the receiver before processing.
> > > * In order to avoid userspace changing the contents of the message
> > > * after validation, the socket and the ring may only be used by a
> > > * single process, otherwise we fall back to copying.
> > > */
> > > if (atomic_long_read(&sk->sk_socket->file->f_count) > 2 ||
> > > atomic_read(&nlk->mapped) > 1)
> > > excl = false;
> > > looks very odd. For one thing, descriptor table may be shared, with
> > > one thread calling sendmsg() (which gives f_count equal to 2), while
> > > another calls mmap() just as the first one gets past that check.
> >
> > Another thread calling mmap() should be fine since validation, processing
> > and mmap() all happen under the pg_vec_lock mutex.
Sorry, no. Thread A: calls sendmsg(), gets past the check, loses CPU1 on
e.g. preempt. Thread B on CPU2 calls mmap(2), returns to userland (having
dropped the mutex, of course) and proceeds to play with the mapped area.
Thread A regains CPU and moves on past that if (....), excl still being true.
See the problem?
prev parent reply other threads:[~2013-07-19 15:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-14 9:36 buggy check in netlink_mmap_sendmsg() Al Viro
2013-07-18 11:22 ` Patrick McHardy
2013-07-19 15:38 ` Patrick McHardy
2013-07-19 15:45 ` Al Viro
2013-07-19 15:52 ` Al Viro [this message]
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=20130719155209.GG4165@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=kaber@trash.net \
--cc=netdev@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).