linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: salyzyn@android.com (Mark Salyzyn)
To: linux-arm-kernel@lists.infradead.org
Subject: RESEND [PATCH 5/6] arm64: compat: 32-bit vDSO setup
Date: Mon, 18 Jun 2018 08:06:08 -0700	[thread overview]
Message-ID: <20180618150613.10322-23-salyzyn@android.com> (raw)
In-Reply-To: <20180618150613.10322-1-salyzyn@android.com>

From: Kevin Brodsky <kevin.brodsky@arm.com>

If the compat vDSO is enabled, install it in compat processes. In this
case, the compat vDSO replaces the sigreturn page (it provides its own
sigreturn trampolines).

Signed-off-by: Kevin Brodsky <kevin.brodsky@arm.com>
Signed-off-by: Mark Salyzyn <salyzyn@android.com>
Cc: James Morse <james.morse@arm.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Dmitry Safonov <dsafonov@virtuozzo.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Laura Abbott <labbott@redhat.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Andy Gross <andy.gross@linaro.org>
Cc: Andrew Pinski <apinski@cavium.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: Jeremy Linton <Jeremy.Linton@arm.com>
---
 arch/arm64/kernel/vdso.c | 55 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
index 8529e85a521f..9fb1e0d380ab 100644
--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -58,6 +58,7 @@ struct vdso_data *vdso_data = &vdso_data_store.data;
 /*
  * Create and map the vectors page for AArch32 tasks.
  */
+#if !defined(CONFIG_VDSO32) || defined(CONFIG_KUSER_HELPERS)
 static struct page *vectors_page[] __ro_after_init;
 static const struct vm_special_mapping compat_vdso_spec[] = {
 	{
@@ -73,6 +74,7 @@ static const struct vm_special_mapping compat_vdso_spec[] = {
 #endif
 };
 static struct page *vectors_page[ARRAY_SIZE(compat_vdso_spec)] __ro_after_init;
+#endif
 
 static int __init alloc_vectors_page(void)
 {
@@ -82,6 +84,7 @@ static int __init alloc_vectors_page(void)
 	unsigned long kuser_vpage;
 #endif
 
+#ifndef CONFIG_VDSO32
 	extern char __aarch32_sigret_code_start[], __aarch32_sigret_code_end[];
 	size_t sigret_sz =
 		__aarch32_sigret_code_end - __aarch32_sigret_code_start;
@@ -90,19 +93,24 @@ static int __init alloc_vectors_page(void)
 	sigret_vpage = get_zeroed_page(GFP_ATOMIC);
 	if (!sigret_vpage)
 		return -ENOMEM;
+#endif
 
 #ifdef CONFIG_KUSER_HELPERS
 	kuser_vpage = get_zeroed_page(GFP_ATOMIC);
 	if (!kuser_vpage) {
+#ifndef CONFIG_VDSO32
 		free_page(sigret_vpage);
+#endif
 		return -ENOMEM;
 	}
 #endif
 
+#ifndef CONFIG_VDSO32
 	/* sigreturn code */
 	memcpy((void *)sigret_vpage, __aarch32_sigret_code_start, sigret_sz);
 	flush_icache_range(sigret_vpage, sigret_vpage + PAGE_SIZE);
 	vectors_page[0] = virt_to_page(sigret_vpage);
+#endif
 
 #ifdef CONFIG_KUSER_HELPERS
 	/* kuser helpers */
@@ -116,6 +124,7 @@ static int __init alloc_vectors_page(void)
 }
 arch_initcall(alloc_vectors_page);
 
+#ifndef CONFIG_VDSO32
 int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp)
 {
 	struct mm_struct *mm = current->mm;
@@ -151,6 +160,7 @@ int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp)
 
 	return PTR_ERR_OR_ZERO(ret);
 }
+#endif /* !CONFIG_VDSO32 */
 #endif /* CONFIG_COMPAT */
 
 static int vdso_mremap(const struct vm_special_mapping *sm,
@@ -221,6 +231,23 @@ static int __init vdso_mappings_init(const char *name,
 	return 0;
 }
 
+#ifdef CONFIG_COMPAT
+#ifdef CONFIG_VDSO32
+
+static struct vdso_mappings vdso32_mappings __ro_after_init;
+
+static int __init vdso32_init(void)
+{
+	extern char vdso32_start[], vdso32_end[];
+
+	return vdso_mappings_init("vdso32", vdso32_start, vdso32_end,
+				  &vdso32_mappings);
+}
+arch_initcall(vdso32_init);
+
+#endif /* CONFIG_VDSO32 */
+#endif /* CONFIG_COMPAT */
+
 static struct vdso_mappings vdso_mappings __ro_after_init;
 
 static int __init vdso_init(void)
@@ -263,6 +290,34 @@ static int vdso_setup(struct mm_struct *mm,
 	return PTR_ERR_OR_ZERO(ret);
 }
 
+#ifdef CONFIG_COMPAT
+#ifdef CONFIG_VDSO32
+int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp)
+{
+	struct mm_struct *mm = current->mm;
+	void *ret;
+
+	if (down_write_killable(&mm->mmap_sem))
+		return -EINTR;
+
+	ret = ERR_PTR(vdso_setup(mm, &vdso32_mappings));
+#ifdef CONFIG_KUSER_HELPERS
+	if (!IS_ERR(ret))
+		/* Map the kuser helpers at the ABI-defined high address. */
+		ret = _install_special_mapping(mm, AARCH32_KUSER_HELPERS_BASE,
+					       PAGE_SIZE,
+					       VM_READ|VM_EXEC|
+					       VM_MAYREAD|VM_MAYEXEC,
+					       &compat_vdso_spec[1]);
+#endif
+
+	up_write(&mm->mmap_sem);
+
+	return PTR_ERR_OR_ZERO(ret);
+}
+#endif /* CONFIG_VDSO32 */
+#endif /* CONFIG_COMPAT */
+
 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
 {
 	struct mm_struct *mm = current->mm;
-- 
2.18.0.rc1.244.gcf134e6275-goog

  parent reply	other threads:[~2018-06-18 15:06 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-18 15:05 RESEND arm+arm64+aarch32 vdso rewrite Mark Salyzyn
2018-06-18 15:05 ` RESEND [PATCH v5 01/12] arm: vdso: rename vdso_datapage variables Mark Salyzyn
2018-06-18 15:05 ` RESEND [PATCH v5 02/12] arm: vdso: add include file defining __get_datapage() Mark Salyzyn
2018-06-18 15:05 ` RESEND [PATCH v5 03/12] arm: vdso: inline assembler operations to compiler.h Mark Salyzyn
2018-06-18 15:05 ` RESEND [PATCH v5 04/12] arm: vdso: do calculations outside reader loops Mark Salyzyn
2018-06-18 15:05 ` RESEND [PATCH v6 05/12] arm: vdso: Add support for CLOCK_MONOTONIC_RAW Mark Salyzyn
2018-06-18 15:05 ` RESEND [PATCH v5 06/12] arm: vdso: add support for clock_getres Mark Salyzyn
2018-06-18 15:05 ` RESEND [PATCH v5 07/12] arm: vdso: disable profiling Mark Salyzyn
2018-06-18 15:05 ` RESEND [PATCH v5 08/12] arm: vdso: Add ARCH_CLOCK_FIXED_MASK Mark Salyzyn
2018-06-18 15:05 ` RESEND [PATCH v5 09/12] arm: vdso: move vgettimeofday.c to lib/vdso/ Mark Salyzyn
2018-06-18 15:05 ` RESEND [PATCH v5 10/12] arm64: vdso: replace gettimeofday.S with global vgettimeofday.C Mark Salyzyn
2018-06-18 15:05 ` RESEND [PATCH v6 11/12] lib: vdso: Add support for CLOCK_BOOTTIME Mark Salyzyn
2018-06-18 15:05 ` RESEND [PATCH v5 12/12] lib: vdso: do not expose gettimeofday, if no arch supported timer Mark Salyzyn
2018-06-18 15:05 ` RESEND [PATCH] lib: vdso: add support for time Mark Salyzyn
2018-06-18 15:06 ` RESEND [PATCH v2 1/3] arm64: compat: Split the sigreturn trampolines and kuser helpers (C sources) Mark Salyzyn
2018-06-18 15:06 ` RESEND [PATCH v2 2/3] arm64: compat: Split the sigreturn trampolines and kuser helpers (assembler sources) Mark Salyzyn
2018-06-18 15:06 ` RESEND [PATCH v2 3/3] arm64: compat: Add CONFIG_KUSER_HELPERS Mark Salyzyn
2018-06-18 15:06 ` RESEND [PATCH] arm64: compat: Expose offset to registers in sigframes Mark Salyzyn
2018-06-18 15:06 ` RESEND [PATCH 1/6] arm64: compat: Use vDSO sigreturn trampolines if available Mark Salyzyn
2018-06-18 15:06 ` RESEND [PATCH 2/6] arm64: elf: Set AT_SYSINFO_EHDR in compat processes Mark Salyzyn
2018-06-18 15:06 ` RESEND [PATCH 3/6] arm64: Refactor vDSO init/setup Mark Salyzyn
2018-06-18 15:06 ` RESEND [PATCH v2 4/6] arm64: compat: Add a 32-bit vDSO Mark Salyzyn
2018-06-18 15:06 ` Mark Salyzyn [this message]
2018-06-18 15:06 ` RESEND [PATCH 6/6] arm64: Wire up and expose the new compat vDSO Mark Salyzyn
  -- strict thread matches above, loose matches on Subject: below --
2018-10-01 17:58 RESEND and REBASE arm+arm64+aarch32 vdso rewrite Mark Salyzyn
2018-10-01 17:58 ` RESEND [PATCH 5/6] arm64: compat: 32-bit vDSO setup Mark Salyzyn

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=20180618150613.10322-23-salyzyn@android.com \
    --to=salyzyn@android.com \
    --cc=linux-arm-kernel@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).