Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1470628

[PATCH v2 4/9] arm64: alternative: Disallow patching instructions using literals

From Suzuki K Poulose <suzuki.poulose@arm.com>
Newsgroups linux.kernel
Subject [PATCH v2 4/9] arm64: alternative: Disallow patching instructions using literals
Date 2016-08-26 11:40 +0200
Message-ID <salMe-5aQ-27@gated-at.bofh.it> (permalink)
References <salCx-57G-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


The alternative code patching doesn't check if the replaced instruction
uses a pc relative literal. This could cause silent corruption in the
instruction stream as the instruction will be executed from a different
address than what it was compiled for. Catch all such cases.

Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Andre Przywara <andre.przywara@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Suggested-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 arch/arm64/kernel/alternative.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm64/kernel/alternative.c b/arch/arm64/kernel/alternative.c
index d2ee1b2..6b269a9 100644
--- a/arch/arm64/kernel/alternative.c
+++ b/arch/arm64/kernel/alternative.c
@@ -80,6 +80,12 @@ static u32 get_alt_insn(struct alt_instr *alt, u32 *insnptr, u32 *altinsnptr)
 			offset = target - (unsigned long)insnptr;
 			insn = aarch64_set_branch_offset(insn, offset);
 		}
+	} else if (aarch64_insn_uses_literal(insn)) {
+		/*
+		 * Disallow patching unhandled instructions using PC relative
+		 * literal addresses
+		 */
+		BUG();
 	}
 
 	return insn;
-- 
2.7.4

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH v2 0/9] arm64: Work around for mismatched cache line size Suzuki K Poulose <suzuki.poulose@arm.com> - 2016-08-26 11:40 +0200
  [PATCH v2 2/9] arm64: Use consistent naming for errata handling Suzuki K Poulose <suzuki.poulose@arm.com> - 2016-08-26 11:40 +0200
  [PATCH v2 4/9] arm64: alternative: Disallow patching instructions using literals Suzuki K Poulose <suzuki.poulose@arm.com> - 2016-08-26 11:40 +0200

csiph-web