arm64: alternatives: apply boot time fixups via the linear mapping
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Thu, 9 Mar 2017 20:52:01 +0000 (21:52 +0100)
committerHaibo Chen <haibo.chen@nxp.com>
Thu, 12 Apr 2018 10:46:16 +0000 (18:46 +0800)
commit65e34707fd32e43ed16ccb9465c4e9094a3e9703
tree3e5f0b9a4768f4b62309758fe8f43b56a4285ca7
parenta14810370215a9be32f4475b576253fda6580ae9
arm64: alternatives: apply boot time fixups via the linear mapping

commit 5ea5306c323 upstream.

One important rule of thumb when desiging a secure software system is
that memory should never be writable and executable at the same time.
We mostly adhere to this rule in the kernel, except at boot time, when
regions may be mapped RWX until after we are done applying alternatives
or making other one-off changes.

For the alternative patching, we can improve the situation by applying
the fixups via the linear mapping, which is never mapped with executable
permissions. So map the linear alias of .text with RW- permissions
initially, and remove the write permissions as soon as alternative
patching has completed.

Reviewed-by: Laura Abbott <labbott@redhat.com>
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Alex Shi <alex.shi@linaro.org>
Conflicts:
replace update_mapping_prot with old create_mapping_late
arch/arm64/mm/mmu.c
arch/arm64/include/asm/mmu.h
arch/arm64/kernel/alternative.c
arch/arm64/kernel/smp.c
arch/arm64/mm/mmu.c