Commit bb72d1b1 authored by Doug Berger's avatar Doug Berger Committed by Kleber Sacilotto de Souza

ARM: 8874/1: mm: only adjust sections of valid mm structures

BugLink: https://bugs.launchpad.net/bugs/1845405

[ Upstream commit c51bc12d ]

A timing hazard exists when an early fork/exec thread begins
exiting and sets its mm pointer to NULL while a separate core
tries to update the section information.

This commit ensures that the mm pointer is not NULL before
setting its section parameters. The arguments provided by
commit 11ce4b33 ("ARM: 8672/1: mm: remove tasklist locking
from update_sections_early()") are equally valid for not
requiring grabbing the task_lock around this check.

Fixes: 08925c2f ("ARM: 8464/1: Update all mm structures with section adjustments")
Signed-off-by: default avatarDoug Berger <opendmb@gmail.com>
Acked-by: default avatarLaura Abbott <labbott@redhat.com>
Cc: Mike Rapoport <rppt@linux.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Rob Herring <robh@kernel.org>
Cc: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarConnor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 0018a878
...@@ -691,7 +691,8 @@ static void update_sections_early(struct section_perm perms[], int n) ...@@ -691,7 +691,8 @@ static void update_sections_early(struct section_perm perms[], int n)
if (t->flags & PF_KTHREAD) if (t->flags & PF_KTHREAD)
continue; continue;
for_each_thread(t, s) for_each_thread(t, s)
set_section_perms(perms, n, true, s->mm); if (s->mm)
set_section_perms(perms, n, true, s->mm);
} }
read_unlock(&tasklist_lock); read_unlock(&tasklist_lock);
set_section_perms(perms, n, true, current->active_mm); set_section_perms(perms, n, true, current->active_mm);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment