From: Miaohe Lin <linmiaohe@huawei.com>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: <linux-kernel@vger.kernel.org>, Michal Hocko <mhocko@suse.com>,
<linux-mm@kvack.org>, Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] mm: Use rcu_dereference in in_vfork
Date: Mon, 22 Feb 2021 09:44:39 +0800 [thread overview]
Message-ID: <28850db2-687d-e604-2bd3-3a72344c1e7d@huawei.com> (raw)
In-Reply-To: <20210221194207.1351703-1-willy@infradead.org>
On 2021/2/22 3:42, Matthew Wilcox (Oracle) wrote:
> Fix a sparse warning by using rcu_dereference(). Technically this is a
> bug and a sufficiently aggressive compiler could reload the `real_parent'
> pointer outside the protection of the rcu lock (and access freed memory),
> but I think it's pretty unlikely to happen.
>
> Fixes: b18dc5f291c0 ("mm, oom: skip vforked tasks from being selected")
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Looks good to me. Thanks!
Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
> include/linux/sched/mm.h | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h
> index 1ae08b8462a4..90b2a0bce11c 100644
> --- a/include/linux/sched/mm.h
> +++ b/include/linux/sched/mm.h
> @@ -140,7 +140,8 @@ static inline bool in_vfork(struct task_struct *tsk)
> * another oom-unkillable task does this it should blame itself.
> */
> rcu_read_lock();
> - ret = tsk->vfork_done && tsk->real_parent->mm == tsk->mm;
> + ret = tsk->vfork_done &&
> + rcu_dereference(tsk->real_parent)->mm == tsk->mm;
> rcu_read_unlock();
>
> return ret;
>
next prev parent reply other threads:[~2021-02-22 1:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-21 19:42 [PATCH] mm: Use rcu_dereference in in_vfork Matthew Wilcox (Oracle)
2021-02-22 1:44 ` Miaohe Lin [this message]
2021-02-22 8:30 ` 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=28850db2-687d-e604-2bd3-3a72344c1e7d@huawei.com \
--to=linmiaohe@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=willy@infradead.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).