Skip to content

Commit

Permalink
ARM: 9431/1: mm: Pair atomic_set_release() with _read_acquire()
Browse files Browse the repository at this point in the history
commit 93ee385 upstream.

The code for syncing vmalloc memory PGD pointers is using
atomic_read() in pair with atomic_set_release() but the
proper pairing is atomic_read_acquire() paired with
atomic_set_release().

This is done to clearly instruct the compiler to not
reorder the memcpy() or similar calls inside the section
so that we do not observe changes to init_mm. memcpy()
calls should be identified by the compiler as having
unpredictable side effects, but let's try to be on the
safe side.

Cc: stable@vger.kernel.org
Fixes: d31e23a ("ARM: mm: make vmalloc_seq handling SMP safe")
Suggested-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
linusw authored and gregkh committed Dec 9, 2024
1 parent ef21187 commit 2c932d5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion arch/arm/mm/ioremap.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void __check_vmalloc_seq(struct mm_struct *mm)
int seq;

do {
seq = atomic_read(&init_mm.context.vmalloc_seq);
seq = atomic_read_acquire(&init_mm.context.vmalloc_seq);
memcpy_pgd(mm, VMALLOC_START, VMALLOC_END);
if (IS_ENABLED(CONFIG_KASAN_VMALLOC)) {
unsigned long start =
Expand Down

0 comments on commit 2c932d5

Please sign in to comment.