public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: Jianyong Wu <jianyong.wu@arm.com>
Cc: will@kernel.org, anshuman.khandual@arm.com,
	akpm@linux-foundation.org, david@redhat.com, ardb@kernel.org,
	quic_qiancai@quicinc.com, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, gshan@redhat.com,
	justin.he@arm.com, nd@arm.com
Subject: Re: [PATCH] [PATCH v4] arm64/mm: avoid fixmap race condition when create pud mapping
Date: Fri, 4 Feb 2022 18:44:11 +0000	[thread overview]
Message-ID: <Yf1z+54GEtF6yxvX@arm.com> (raw)
In-Reply-To: <20220201114400.56885-1-jianyong.wu@arm.com>

On Tue, Feb 01, 2022 at 07:44:00PM +0800, Jianyong Wu wrote:
> The 'fixmap' is a global resource and is used recursively by
> create pud mapping(), leading to a potential race condition in the
> presence of a concurrent call to alloc_init_pud():
> 
> kernel_init thread                          virtio-mem workqueue thread
> ==================                          ===========================
> 
>   alloc_init_pud(...)                       alloc_init_pud(...)
>   pudp = pud_set_fixmap_offset(...)         pudp = pud_set_fixmap_offset(...)
>   READ_ONCE(*pudp)
>   pud_clear_fixmap(...)
>                                             READ_ONCE(*pudp) // CRASH!
> 
> As kernel may sleep during creating pud mapping, introduce a mutex lock to
> serialise use of the fixmap entries by alloc_init_pud(). However, there is
> no need for locking in early boot stage and it doesn't work well with
> KASLR enabled when early boot. So, enable lock when system_state doesn't
> equal to "SYSTEM_BOOTING".
> 
> Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>

This looks fine to me but I'd rather leave it in -next for a bit given
that we attempted to fix it a couple of times and got it wrong.

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>

  reply	other threads:[~2022-02-04 18:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-01 11:44 [PATCH] [PATCH v4] arm64/mm: avoid fixmap race condition when create pud mapping Jianyong Wu
2022-02-04 18:44 ` Catalin Marinas [this message]
2022-02-15 23:18 ` Will Deacon

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=Yf1z+54GEtF6yxvX@arm.com \
    --to=catalin.marinas@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=anshuman.khandual@arm.com \
    --cc=ardb@kernel.org \
    --cc=david@redhat.com \
    --cc=gshan@redhat.com \
    --cc=jianyong.wu@arm.com \
    --cc=justin.he@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nd@arm.com \
    --cc=quic_qiancai@quicinc.com \
    --cc=will@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