Thread (12 messages) 12 messages, 1 author, 2020-07-01
STALE2162d

[PATCH v2 06/11] arm64: vdso: Document and verify alignment of vDSO text

From: Mark Brown <broonie@kernel.org>
Date: 2020-07-01 20:30:48
Subsystem: arm64 port (aarch64 architecture), the rest · Maintainers: Catalin Marinas, Will Deacon, Linus Torvalds

We do no rounding when working out the number of vDSO text pages because
we ensure in vdso.S that the vDSO text is an exact number of pages long.
This is not immediately apparent when looking at the code that does the
vDSO mapping in vdso.c so add a comment explaining what's going on and
check that this assumption is true.

Ideally we'd have a BUILD_BUG_ON() but since the start and end come from
another compilation unit it needs to be a runtime check, add one which
prints a warning and errors out similarly to the existing check for the
vDSO not being an ELF object.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 arch/arm64/kernel/vdso.c | 9 +++++++++
 1 file changed, 9 insertions(+)
diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
index b05e4d5880af..95e69df42141 100644
--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -99,6 +99,15 @@ static int __vdso_init(enum vdso_abi abi)
 		return -EINVAL;
 	}
 
+	/*
+	 * We ensure that the vDSO text is page aligned and an exact
+	 * number of pages in vdso.S so don't need to round here.
+	 */
+	if (!PAGE_ALIGNED(vdso_info[abi].vdso_code_start) ||
+	    !PAGE_ALIGNED(vdso_info[abi].vdso_code_end)) {
+		pr_err("vDSO is not page aligned\n");
+		return -EINVAL;
+	}
 	vdso_info[abi].vdso_pages = (
 			vdso_info[abi].vdso_code_end -
 			vdso_info[abi].vdso_code_start) >>
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help