All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Vincenzo Frascino <Vincenzo.Frascino@arm.com>,
	Will Deacon <will@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>
Cc: Mark Brown <broonie@kernel.org>,
	Kees Cook <keescook@chromium.org>,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH 10/10] arm64: vdso: Map the vDSO text with guarded pages when built for BTI
Date: Wed, 15 Apr 2020 14:07:49 +0100	[thread overview]
Message-ID: <20200415130750.18645-11-broonie@kernel.org> (raw)
In-Reply-To: <20200415130750.18645-1-broonie@kernel.org>

The kernel is responsible for mapping the vDSO into userspace processes,
including mapping the text section as executable. Handle the mapping of
the vDSO for BTI similarly, mapping the text section as guarded pages so
the BTI annotations in the vDSO become effective when they are present.

This will mean that we can have BTI active for the vDSO in processes that
do not otherwise support BTI. This should not be an issue for any expected
use of the vDSO.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 arch/arm64/kernel/vdso.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
index 354b11e27c07..9271b7774df0 100644
--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -142,6 +142,7 @@ static int __setup_additional_pages(enum arch_vdso_type arch_index,
 				    int uses_interp)
 {
 	unsigned long vdso_base, vdso_text_len, vdso_mapping_len;
+	unsigned long gp_flags = 0;
 	void *ret;
 
 	vdso_text_len = vdso_lookup[arch_index].vdso_pages << PAGE_SHIFT;
@@ -160,10 +161,13 @@ static int __setup_additional_pages(enum arch_vdso_type arch_index,
 	if (IS_ERR(ret))
 		goto up_fail;
 
+	if (IS_ENABLED(CONFIG_ARM64_BTI_KERNEL) && system_supports_bti())
+		gp_flags = VM_ARM64_BTI;
+
 	vdso_base += PAGE_SIZE;
 	mm->context.vdso = (void *)vdso_base;
 	ret = _install_special_mapping(mm, vdso_base, vdso_text_len,
-				       VM_READ|VM_EXEC|
+				       VM_READ|VM_EXEC|gp_flags|
 				       VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
 				       vdso_lookup[arch_index].cm);
 	if (IS_ERR(ret))
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2020-04-15 13:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-15 13:07 [PATCH 00/10] arm64: BTI kernel and vDSO support Mark Brown
2020-04-15 13:07 ` [PATCH 01/10] arm64: kernel: Convert to modern annotations for assembly functions Mark Brown
2020-04-15 13:07 ` [PATCH 02/10] arm64: bti: Support building kernel C code using BTI Mark Brown
2020-04-15 13:07 ` [PATCH 03/10] arm64: asm: Override SYM_FUNC_START when building the kernel with BTI Mark Brown
2020-04-15 13:07 ` [PATCH 04/10] arm64: Set GP bit in kernel page tables to enable BTI for the kernel Mark Brown
2020-04-28 17:24   ` Catalin Marinas
2020-04-28 18:03     ` Mark Brown
2020-04-29  7:40       ` Will Deacon
2020-04-29 10:10         ` Mark Brown
2020-04-15 13:07 ` [PATCH 05/10] arm64: mm: Mark module text as guarded pages Mark Brown
2020-04-27 15:07   ` Mark Brown
2020-04-15 13:07 ` [PATCH 06/10] arm64: bti: Provide Kconfig for kernel mode BTI Mark Brown
2020-04-15 13:07 ` [PATCH 07/10] arm64: asm: Provide a mechanism for generating ELF note for BTI Mark Brown
2020-04-15 13:07 ` [PATCH 08/10] arm64: vdso: Annotate " Mark Brown
2020-04-15 13:07 ` [PATCH 09/10] arm64: vdso: Force the vDSO to be linked as BTI when built " Mark Brown
2020-04-15 13:07 ` Mark Brown [this message]
2020-04-15 13:07 ` [PATCH 10/10] arm64: vdso: Map the VDSO text with guarded pages " Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200415130750.18645-11-broonie@kernel.org \
    --to=broonie@kernel.org \
    --cc=Vincenzo.Frascino@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=keescook@chromium.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.