Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4039586imm; Mon, 18 Jun 2018 08:11:46 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLqttFNDEv2GbdncpuJrVSXD5fJXOSV/q3+iVe+r08Y1y0BWBR1m1kPiVfh66dp8XZqttiK X-Received: by 2002:a17:902:8b86:: with SMTP id ay6-v6mr14636970plb.295.1529334706470; Mon, 18 Jun 2018 08:11:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529334706; cv=none; d=google.com; s=arc-20160816; b=v2URSSc58XY+4OMRVfHiTFlwc+Pw2fxOw3nPYtB6lTa6tVaUlUhscTtSy1opzFcv8k T71tfl+qLn6o3bLieE2diTdWGdIwLqqV8qGuYJ9xmzIM0Os02Oem+HqhgKsuke+JIoWq EcBPQUJFx1CN27XrBxd7yWnRFH7rxkbnHV4a13ajAITnitY6x0XGMfSNVZ9XWJglimv+ XGCAoah5rXKat4Z11rS/ZzkMiai5FTnrU7Qhl+DjjcFqjpB2iJOkVlZ+CtdVuSE2cNcB efqt7zioqkad+Fs5Lsk2GGsgJiyxmfxS/C8cs6/Ei6U6WhewiCIKL6pnbR1RlWjN0hjv e8pQ== 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=2pfESoiXW7kZE4xChCGGKPZSQMnBX5sI3eDemQAvvzk=; b=AggMBuVWqzX+TV9iPUgJFn01v5Iwl7enCojidm4yGOUUlA4S72IVHVoyU796Tz3i7M pY+gD4g4L3pLVB1YPPtLcROzaj1y04BiM4gWhdT8JISozhC6JtfYosf5pdJe0/8iF1m9 Xiju3krQ8icwrD5L3ZPObre8WkD6lraZtIVgpL5qSGi15tyq8HmfhokQXaaFKW+rQiQh h5Y/8p4y6Nmqa4j4ZvhWOTff+4wqjL/zu6LSIe0QXbDCwqr0Flr29kecXiXNcj9si7JJ yvJNXegfeggXb9MbJ32nQ0ZUZ6qL5GU6XVKYMY9pkbBbfM0teCm3kkXeNbGQ8HyhLo9Q Zo1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=EHsBfzvL; 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 i65-v6si14689021pfg.218.2018.06.18.08.11.32; Mon, 18 Jun 2018 08:11:46 -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=EHsBfzvL; 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 S935868AbeFRPKr (ORCPT + 99 others); Mon, 18 Jun 2018 11:10:47 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:34707 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935444AbeFRPKV (ORCPT ); Mon, 18 Jun 2018 11:10:21 -0400 Received: by mail-pl0-f65.google.com with SMTP id g20-v6so9207174plq.1 for ; Mon, 18 Jun 2018 08:10:21 -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=2pfESoiXW7kZE4xChCGGKPZSQMnBX5sI3eDemQAvvzk=; b=EHsBfzvL8GWOY24pk8dwcVmsQX2cOQ0pKwpoxENUIb++3Ak+5K7M2P9wT3WE8RLgrh YLmDCFUWV+dJSQillLfx/BlCDG8Ut250QNQEXyQ8hsXfVefFraX44rgAwco9OvUMKIlF 1apURrqENPQRF9vCL6ezGMfBoG2MfOQrx2QuhKIIzokNvMzYkQTunfK7t2wDs463ND2/ mKQyaodXlYp+E1t8PUQgFGYwa29m/EU9g3SDmGzic1u7TuMkpHqidK6ZFgIT/D1CUUH7 nAXfLnjzGOAAF7ykD4wlhJ9ZQyBTKbp4RB4ee7R0LxUDJqR333ZjZmxCnQUnP7h3uLiy q97Q== 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=2pfESoiXW7kZE4xChCGGKPZSQMnBX5sI3eDemQAvvzk=; b=esMtQyngpeo+G8K9k+of1LU7siHueaO9hTinGOGVYrtkunxOpmA/RaCXYmK/tmzDAJ HAvbDcqNcjDg6pEtVtk+l28MNe9CZnnDDL3nv1PVA3UVoVJpEAifhy4JHXHMvFcXhnZB 57rZQbgsPk954ePV0ruwrx15pNlew9aSii1L3oG53oAI93hrPXydelWg9wZBTrcxcBUX A0m0LySy73wJPkrJk5Fw68AwWCi5Za3X70yjXthn6WJhqnrX0lzqOLTNyawAph1Mi/kl E0PcSC+nkHlVsX9iP5HU65mHVTJZ+I7X1/c0ZZL0S6cBOK6Qo5rciIdt9d2pTAbhywI2 Hx9w== X-Gm-Message-State: APt69E1CSBfyC34BRLRueg7xyyLO90odb1lbBx4Xokaapzal22cNnUeO SNlQR3ZUCcCogjNLxkWKVynRq0uoCyI= X-Received: by 2002:a17:902:7105:: with SMTP id a5-v6mr14448095pll.171.1529334620971; Mon, 18 Jun 2018 08:10:20 -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.10.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Jun 2018 08:10:20 -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 Subject: RESEND [PATCH 5/6] arm64: compat: 32-bit vDSO setup Date: Mon, 18 Jun 2018 08:06:08 -0700 Message-Id: <20180618150613.10322-23-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 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 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 --- 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