Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4038199imm; Mon, 18 Jun 2018 08:10:37 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL+fhRAuwRDeVO6w46RUXXb1W08WaEKPPn11sQLkSW0WPWt3hdj69hdDX3Xn9cMjbeZpRPn X-Received: by 2002:a17:902:8685:: with SMTP id g5-v6mr14499212plo.180.1529334637134; Mon, 18 Jun 2018 08:10:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529334637; cv=none; d=google.com; s=arc-20160816; b=XbKVrmTBw+YEJ2sYrKjvp36l85vuCrMMp/3x6Kd7z9EfS3UJ88T43O6hd0167qotcg lGMRgp9C64W8Al6YNwbeOISutQnM+JYZ+ysQTyNC6l6CzgWe4Xosz40v2K6/UFG2HGwq u88/Jf0tTucbcsct4mSWfbFz/rKFe+sCuvv6r6x2IOgjzSuFKLBKpH6gHr/bglq7lx+I ajyE2ZvQuBdFzzip2F9rup3tdx34i75LYzBCNmqPpLv2uVdbdAgkYVYyryr1n06hznuU Rvf5WZL3hVCvb68Bb6rUUA9n93bQPZ7c8ybmT34sjr41sLGzojSa8XuwOm9wpRZxdPda EhrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=aO2pedosvHfWhSeROznVJu9daxiAmY1tLnIo0E0UW7Q=; b=GIztYKChT7ascGRtp+x2u1+0dPcalv1+2DPvwf+CAsldNrdpJFxKwG7aZ54gfqIvJr 1gBqk0F65rw42O+2aNYwK0EuEmuLKUeoTJpxI34+WwcgWk/G4BAkU8W7iTlPuKX2z+jc Z0u7R9ISWPQmPUfaS3KPvYBCcvfaxHAd9N21+dHpghA8fP5ADh8FU08JI/0uRglHscXv M8iFocrkGBTntGUTggiZVKWsbjb5+X14jmlqrRqPQH6ZtRNbtNiuQ7RnaJ1JJ9VE9TcK 1aWe8vDLkGwYAZHwrSaJx06TBk0PXZQJhtDD9WA5oU17+5iTHIWXyutuUk+AASwQy01E vaSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=lOK+uwP2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=android.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z10-v6si10478211pgv.1.2018.06.18.08.10.23; Mon, 18 Jun 2018 08:10:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=lOK+uwP2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=android.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935735AbeFRPJW (ORCPT + 99 others); Mon, 18 Jun 2018 11:09:22 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:46511 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935442AbeFRPJU (ORCPT ); Mon, 18 Jun 2018 11:09:20 -0400 Received: by mail-pf0-f193.google.com with SMTP id q1-v6so8320547pff.13 for ; Mon, 18 Jun 2018 08:09:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=android.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aO2pedosvHfWhSeROznVJu9daxiAmY1tLnIo0E0UW7Q=; b=lOK+uwP2vQJ20UvC/Qi2dyI7Tnks1IUby/vIwUGED3dxTBT0PpyaW+DdK1NsepwyEM SdAaHBRzrfGNNLnhWedOYnn8eSRxg1XDkYo4EFPK2K7GklXyjPU7ZLTQqGJPq17NZNKU Py9VaWPXwv7Voh+VgE9Qk5EZo4yqWaz74f38BADDNu5vGhwq6jgJ4eRk6+Ffrw0l7U7/ xLKoHWefvxibU/Q2dtUAPV5GRd/g+tZzgPaKghm/xHZeAbJi98UqR6dXkOIqa3EV3jEL w3JX8cQ4wG19vB5yuh/GhUqUP3J6XdMCKPNc8PwEyEmMAXqoaA/qvhAYh9T8kYUfDF6a ygVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=aO2pedosvHfWhSeROznVJu9daxiAmY1tLnIo0E0UW7Q=; b=sACEiqdzf4m+tDEw82+Kcpo3QsMBQCBJciXYe1r0vith75U6ARIzX7fYPnvqsbl1tH m718rAmdptZbd2Tcf8yXyD9cUR8IhuJ7iooqFAoa7eflLQS9tl4QWVB1PENPVtYTnEOS G3PPO0Yb0SHvhbgta0dxdZlkV7AFE5Jojh1nIyVGHj6cZ6/Ew1il1/NQWjr2akl3XXMK 7hAoglIrf25fmEdSaiXQxLfAF6MF36rRlVaIgwbc/sUZfferBJFhJnCyLo1K/O2lnBWO kGBXIh7wqNjTto3Puiy8A/qgT8jk8XH6atuRcPKCwSdgbJtu30sVZcQ0flbwGVMoeR5B nCOQ== X-Gm-Message-State: APt69E2tXroekz7wkJUBuOhtWH3eiO3dQkHXrRXmRLovuwFpWJ+u2T/I ENbYnfjJC4mDjdkMm06NOB4oeuXHxuM= X-Received: by 2002:a62:df89:: with SMTP id d9-v6mr13879775pfl.147.1529334559896; Mon, 18 Jun 2018 08:09:19 -0700 (PDT) Received: from nebulus.mtv.corp.google.com ([2620:0:1000:1611:6077:8eec:bc7e:d0f4]) by smtp.gmail.com with ESMTPSA id i7-v6sm54830660pfa.34.2018.06.18.08.09.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Jun 2018 08:09:19 -0700 (PDT) From: Mark Salyzyn To: linux-kernel@vger.kernel.org Cc: Kevin Brodsky , Mark Salyzyn , James Morse , Russell King , Catalin Marinas , Will Deacon , Andy Lutomirski , Dmitry Safonov , John Stultz , Mark Rutland , Laura Abbott , Kees Cook , Ard Biesheuvel , Andy Gross , Andrew Pinski , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, Jeremy Linton , Marc Zyngier , Masahiro Yamada , Greg Kroah-Hartman Subject: RESEND [PATCH v2 2/3] arm64: compat: Split the sigreturn trampolines and kuser helpers (assembler sources) Date: Mon, 18 Jun 2018 08:06:01 -0700 Message-Id: <20180618150613.10322-16-salyzyn@android.com> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog In-Reply-To: <20180618150613.10322-1-salyzyn@android.com> References: <20180618150613.10322-1-salyzyn@android.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kevin Brodsky AArch32 processes are currently installed a special [vectors] page that contains the sigreturn trampolines and the kuser helpers, at the fixed address mandated by the kuser helpers ABI. Having both functionalities in the same page has become problematic, because: * It makes it impossible to disable the kuser helpers (the sigreturn trampolines cannot be removed), which is possible on arm. * A future 32-bit vDSO would provide the sigreturn trampolines itself, making those in [vectors] redundant. This patch addresses the problem by moving the sigreturn trampolines sources to its own file. Wrapped the comments to reduce the wrath of checkpatch.pl. Signed-off-by: Kevin Brodsky Signed-off-by: Mark Salyzyn Cc: James Morse Cc: Russell King Cc: Catalin Marinas Cc: Will Deacon Cc: Andy Lutomirski Cc: Dmitry Safonov Cc: John Stultz Cc: Mark Rutland Cc: Laura Abbott Cc: Kees Cook Cc: Ard Biesheuvel Cc: Andy Gross Cc: Andrew Pinski Cc: Thomas Gleixner Cc: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: Jeremy Linton v2: - split off from previous v1 'arm64: compat: Add CONFIG_KUSER_HELPERS' - adjust makefile so one line for each of the assembler source modules v3: - rebase --- arch/arm64/kernel/Makefile | 4 +- arch/arm64/kernel/kuser32.S | 48 ++--------------------- arch/arm64/kernel/sigreturn32.S | 67 +++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 46 deletions(-) create mode 100644 arch/arm64/kernel/sigreturn32.S diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index 0025f8691046..9851be3ef932 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -26,8 +26,10 @@ OBJCOPYFLAGS := --prefix-symbols=__efistub_ $(obj)/%.stub.o: $(obj)/%.o FORCE $(call if_changed,objcopy) -arm64-obj-$(CONFIG_COMPAT) += sys32.o kuser32.o signal32.o \ +arm64-obj-$(CONFIG_COMPAT) += sys32.o signal32.o \ sys_compat.o entry32.o +arm64-obj-$(CONFIG_COMPAT) += sigreturn32.o +arm64-obj-$(CONFIG_COMPAT) += kuser32.o arm64-obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o entry-ftrace.o arm64-obj-$(CONFIG_MODULES) += arm64ksyms.o module.o arm64-obj-$(CONFIG_ARM64_MODULE_PLTS) += module-plts.o diff --git a/arch/arm64/kernel/kuser32.S b/arch/arm64/kernel/kuser32.S index 997e6b27ff6a..d15b5c2935b3 100644 --- a/arch/arm64/kernel/kuser32.S +++ b/arch/arm64/kernel/kuser32.S @@ -20,16 +20,13 @@ * * AArch32 user helpers. * - * Each segment is 32-byte aligned and will be moved to the top of the high - * vector page. New segments (if ever needed) must be added in front of - * existing ones. This mechanism should be used only for things that are - * really small and justified, and not be abused freely. + * These helpers are provided for compatibility with AArch32 binaries that + * still need them. They are installed at a fixed address by + * aarch32_setup_additional_pages(). * * See Documentation/arm/kernel_user_helpers.txt for formal definitions. */ -#include - .align 5 .globl __kuser_helper_start __kuser_helper_start: @@ -77,42 +74,3 @@ __kuser_helper_version: // 0xffff0ffc .word ((__kuser_helper_end - __kuser_helper_start) >> 5) .globl __kuser_helper_end __kuser_helper_end: - -/* - * AArch32 sigreturn code - * - * For ARM syscalls, the syscall number has to be loaded into r7. - * We do not support an OABI userspace. - * - * For Thumb syscalls, we also pass the syscall number via r7. We therefore - * need two 16-bit instructions. - */ - .globl __aarch32_sigret_code_start -__aarch32_sigret_code_start: - - /* - * ARM Code - */ - .byte __NR_compat_sigreturn, 0x70, 0xa0, 0xe3 // mov r7, #__NR_compat_sigreturn - .byte __NR_compat_sigreturn, 0x00, 0x00, 0xef // svc #__NR_compat_sigreturn - - /* - * Thumb code - */ - .byte __NR_compat_sigreturn, 0x27 // svc #__NR_compat_sigreturn - .byte __NR_compat_sigreturn, 0xdf // mov r7, #__NR_compat_sigreturn - - /* - * ARM code - */ - .byte __NR_compat_rt_sigreturn, 0x70, 0xa0, 0xe3 // mov r7, #__NR_compat_rt_sigreturn - .byte __NR_compat_rt_sigreturn, 0x00, 0x00, 0xef // svc #__NR_compat_rt_sigreturn - - /* - * Thumb code - */ - .byte __NR_compat_rt_sigreturn, 0x27 // svc #__NR_compat_rt_sigreturn - .byte __NR_compat_rt_sigreturn, 0xdf // mov r7, #__NR_compat_rt_sigreturn - - .globl __aarch32_sigret_code_end -__aarch32_sigret_code_end: diff --git a/arch/arm64/kernel/sigreturn32.S b/arch/arm64/kernel/sigreturn32.S new file mode 100644 index 000000000000..6ecda4d84cd5 --- /dev/null +++ b/arch/arm64/kernel/sigreturn32.S @@ -0,0 +1,67 @@ +/* + * sigreturn trampolines for AArch32. + * + * Copyright (C) 2005-2011 Nicolas Pitre + * Copyright (C) 2012 ARM Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * + * AArch32 sigreturn code + * + * For ARM syscalls, the syscall number has to be loaded into r7. + * We do not support an OABI userspace. + * + * For Thumb syscalls, we also pass the syscall number via r7. We therefore + * need two 16-bit instructions. + */ + +#include + + .globl __aarch32_sigret_code_start +__aarch32_sigret_code_start: + + /* + * ARM Code + */ + // mov r7, #__NR_compat_sigreturn + .byte __NR_compat_sigreturn, 0x70, 0xa0, 0xe3 + // svc #__NR_compat_sigreturn + .byte __NR_compat_sigreturn, 0x00, 0x00, 0xef + + /* + * Thumb code + */ + // svc #__NR_compat_sigreturn + .byte __NR_compat_sigreturn, 0x27 + // mov r7, #__NR_compat_sigreturn + .byte __NR_compat_sigreturn, 0xdf + + /* + * ARM code + */ + // mov r7, #__NR_compat_rt_sigreturn + .byte __NR_compat_rt_sigreturn, 0x70, 0xa0, 0xe3 + // svc #__NR_compat_rt_sigreturn + .byte __NR_compat_rt_sigreturn, 0x00, 0x00, 0xef + + /* + * Thumb code + */ + // svc #__NR_compat_rt_sigreturn + .byte __NR_compat_rt_sigreturn, 0x27 + // mov r7, #__NR_compat_rt_sigreturn + .byte __NR_compat_rt_sigreturn, 0xdf + + .globl __aarch32_sigret_code_end +__aarch32_sigret_code_end: -- 2.18.0.rc1.244.gcf134e6275-goog