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,
quic_qiancai@quicinc.com, ardb@kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, gshan@redhat.com,
justin.he@arm.com, nd@arm.com
Subject: Re: [PATCH v3] arm64/mm: avoid fixmap race condition when create pud mapping
Date: Wed, 5 Jan 2022 18:03:57 +0000 [thread overview]
Message-ID: <YdXdjcJ7jbnkFsqp@arm.com> (raw)
In-Reply-To: <20211216082812.165387-1-jianyong.wu@arm.com>
On Thu, Dec 16, 2021 at 04:28:12PM +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().
>
> Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
I tried to queue this patch but with certain configurations it doesn't
boot under Qemu. Starting from defconfig, update .config with (I had
this in one of my build scripts):
$ ./scripts/config \
-e DEBUG_KERNEL \
-e DEBUG_PAGEALLOC \
-e DEBUG_PAGEALLOC_ENABLE_DEFAULT \
-e DEBUG_WX \
-e DEBUG_SET_MODULE_RONX \
-e DEBUG_ALIGN_RODATA \
-e ARM64_PTDUMP_DEBUGFS \
-e DEBUG_OBJECTS \
-e DEBUG_OBJECTS_FREE \
-e DEBUG_OBJECTS_TIMERS \
-e DEBUG_KOBJECT_RELEASE \
-e DEBUG_LOCKING_API_SELFTESTS \
-e DEBUG_PREEMPT \
-e DEBUG_TIMEKEEPING \
-e DEBUG_VM \
-e DEBUG_VM_VMACACHE \
-e DEBUG_VM_RB \
-e DEBUG_VM_PGFLAGS \
-e DEBUG_VIRTUAL \
-e DEBUG_LIST \
-e DEBUG_PI_LIST \
-e DEBUG_SG \
-e PROVE_LOCKING \
-e DEBUG_RT_MUTEXES \
-e DEBUG_ATOMIC_SLEEP \
-e ATOMIC64_SELFTEST
It stop after exiting the EFI boot services. I did not have time to
debug.
--
Catalin
next prev parent reply other threads:[~2022-01-05 18:04 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-16 8:28 [PATCH v3] arm64/mm: avoid fixmap race condition when create pud mapping Jianyong Wu
2021-12-16 15:19 ` David Hildenbrand
2021-12-17 9:30 ` Mark Rutland
2021-12-17 10:09 ` Jianyong Wu
2022-01-05 18:03 ` Catalin Marinas [this message]
2022-01-06 10:13 ` Jianyong Wu
2022-01-06 15:56 ` Catalin Marinas
2022-01-07 9:10 ` Jianyong Wu
2022-01-07 10:42 ` Catalin Marinas
2022-01-26 4:20 ` Justin He
2022-01-26 8:36 ` Ard Biesheuvel
2022-01-26 10:09 ` Jianyong Wu
2022-01-26 10:12 ` Ard Biesheuvel
2022-01-26 10:17 ` David Hildenbrand
2022-01-26 10:28 ` Jianyong Wu
2022-01-26 10:30 ` David Hildenbrand
2022-01-26 10:31 ` David Hildenbrand
2022-01-27 6:24 ` Jianyong Wu
2022-01-27 12:22 ` David Hildenbrand
2022-01-27 12:34 ` Catalin Marinas
2022-01-31 8:13 ` Jianyong Wu
2022-01-31 8:10 ` Jianyong Wu
2022-01-27 1:31 ` Justin He
2022-01-07 10:53 ` Catalin Marinas
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=YdXdjcJ7jbnkFsqp@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;
as well as URLs for NNTP newsgroup(s).