From: Tejun Heo <tj@kernel.org>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Michal Hocko <mhocko@suse.cz>,
linux-mm@kvack.org, cgroups@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [patch 1/2] mm: memcontrol: fix lockless reclaim hierarchy iterator
Date: Wed, 5 Jun 2013 16:06:25 -0700 [thread overview]
Message-ID: <20130605230625.GN10693@mtj.dyndns.org> (raw)
In-Reply-To: <1370472826-29959-1-git-send-email-hannes@cmpxchg.org>
On Wed, Jun 05, 2013 at 06:53:45PM -0400, Johannes Weiner wrote:
> The lockless reclaim hierarchy iterator currently has a misplaced
> barrier that can lead to use-after-free crashes.
>
> The reclaim hierarchy iterator consist of a sequence count and a
> position pointer that are read and written locklessly, with memory
> barriers enforcing ordering.
>
> The write side sets the position pointer first, then updates the
> sequence count to "publish" the new position. Likewise, the read side
> must read the sequence count first, then the position. If the
> sequence count is up to date, it's guaranteed that the position is up
> to date as well:
>
> writer: reader:
> iter->position = position if iter->sequence == expected:
> smp_wmb() smp_rmb()
> iter->sequence = sequence position = iter->position
>
> However, the read side barrier is currently misplaced, which can lead
> to dereferencing stale position pointers that no longer point to valid
> memory. Fix this.
>
> Reported-by: Tejun Heo <tj@kernel.org>
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
> Cc: stable@kernel.org [3.10+]
Reviewed-by: Tejun Heo <tj@kernel.org>
Oops, right, the references were reversed too.
Thanks.
--
tejun
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2013-06-05 23:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-05 22:53 [patch 1/2] mm: memcontrol: fix lockless reclaim hierarchy iterator Johannes Weiner
2013-06-05 22:53 ` [patch 2/2] mm: memcontrol: factor out reclaim iterator loading and updating Johannes Weiner
2013-06-05 23:06 ` Tejun Heo
2013-06-06 8:29 ` Michal Hocko
2013-06-05 23:06 ` Tejun Heo [this message]
2013-06-06 8:28 ` [patch 1/2] mm: memcontrol: fix lockless reclaim hierarchy iterator Michal Hocko
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=20130605230625.GN10693@mtj.dyndns.org \
--to=tj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.cz \
/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).