All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Aleksa Sarai <cyphar@cyphar.com>
Cc: Li Zefan <lizefan@huawei.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] cgroup: pids: use {READ,WRITE}_ONCE for pids->limit operations
Date: Mon, 14 Oct 2019 09:33:07 -0700	[thread overview]
Message-ID: <20191014163307.GG18794@devbig004.ftw2.facebook.com> (raw)
In-Reply-To: <20191014155931.jl7idjebhqxb3ck3@yavin.dot.cyphar.com>

Hello, Aleksa.

On Tue, Oct 15, 2019 at 02:59:31AM +1100, Aleksa Sarai wrote:
> On 2019-10-14, Tejun Heo <tj@kernel.org> wrote:
> > On Sat, Oct 12, 2019 at 12:05:39PM +1100, Aleksa Sarai wrote:
> > > Because pids->limit can be changed concurrently (but we don't want to
> > > take a lock because it would be needlessly expensive), use the
> > > appropriate memory barriers.
> > 
> > I can't quite tell what problem it's fixing.  Can you elaborate a
> > scenario where the current code would break that your patch fixes?
> 
> As far as I can tell, not using *_ONCE() here means that if you had a
> process changing pids->limit from A to B, a process might be able to
> temporarily exceed pids->limit -- because pids->limit accesses are not
> protected by mutexes and the C compiler can produce confusing
> intermediate values for pids->limit[1].
>
> But this is more of a correctness fix than one fixing an actually
> exploitable bug -- given the kernel memory model work, it seems like a
> good idea to just use READ_ONCE() and WRITE_ONCE() for shared memory
> access.

READ/WRITE_ONCE provides protection against compiler generating
multiple accesses for a single operation.  It won't prevent split
writes / reads of 64bit variables on 32bit machines.  For that, you'd
have to switch them to atomic64_t's.

Thanks.

-- 
tejun

  reply	other threads:[~2019-10-14 16:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-12  1:05 [PATCH] cgroup: pids: use {READ,WRITE}_ONCE for pids->limit operations Aleksa Sarai
2019-10-14 15:41 ` Tejun Heo
2019-10-14 15:59   ` Aleksa Sarai
2019-10-14 16:33     ` Tejun Heo [this message]
2019-10-16  8:32       ` Aleksa Sarai
2019-10-16 14:27         ` Tejun Heo
2019-10-16 15:29           ` Aleksa Sarai
2019-10-16 15:32             ` Tejun Heo
2019-10-16 15:35             ` Aleksa Sarai
2019-10-16 15:54               ` Tejun Heo

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=20191014163307.GG18794@devbig004.ftw2.facebook.com \
    --to=tj@kernel.org \
    --cc=cgroups@vger.kernel.org \
    --cc=cyphar@cyphar.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=stable@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 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.