From patchwork Tue Mar 19 15:15:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincenzo Frascino X-Patchwork-Id: 10859765 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A5DCE17E9 for ; Tue, 19 Mar 2019 15:16:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83AE028CB8 for ; Tue, 19 Mar 2019 15:16:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7819629694; Tue, 19 Mar 2019 15:16:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B903A28CB8 for ; Tue, 19 Mar 2019 15:16:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=PmyE6+D4GHqqwv1AgY54ndcimaABz/EwOgJ04sCFA1k=; b=aiekSVcZEo3F5k jIuTWqyTSn1ZdTJnKAHaDZB3hZMZ/XVKG62qM/TFass+TQ3UurGgvkOxR/AqXRiJAkbTPgYPpbnix BpPwRD7SAycMHpo6PlPbD5fHcKuWG+07xGhsa0I/LIAFMUOVPLWQiqZDQtkDgHU1sw9GpX0FTRPR1 p65K0wAE1ng8G8PBCPwVDwCzVDAEe3Bfi4Tqko9Tdb9c7p34iUrmrGQiHJmkBliwh063HNf1wMXB4 axLsTQhtRktGPLh9Bf43JNpCXacEaZji3uSAu9muFUXB7rSeKm16OWyWfUxrQ43450oYkm9Uf38nl xxkbRx496Nf2NBxsCu5Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h6GTL-0005hg-2p; Tue, 19 Mar 2019 15:16:11 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h6GTH-0005gj-Ie for linux-arm-kernel@lists.infradead.org; Tue, 19 Mar 2019 15:16:08 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D2EA11650; Tue, 19 Mar 2019 08:16:06 -0700 (PDT) Received: from e119884-lin.cambridge.arm.com (e119884-lin.cambridge.arm.com [10.1.196.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9EEA93F614; Tue, 19 Mar 2019 08:16:05 -0700 (PDT) From: Vincenzo Frascino To: linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 0/5] arm64: compat: Reduce address limit Date: Tue, 19 Mar 2019 15:15:37 +0000 Message-Id: <20190319151542.19557-1-vincenzo.frascino@arm.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190319_081607_668430_E37F8FAB X-CRM114-Status: GOOD ( 10.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Catalin Marinas , Will Deacon , Jann Horn Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patchset reduces the size of the user-accessible address space for compat tasks by a page. Currently, compat tasks running on arm64 can allocate memory up to TASK_SIZE_32 (UL(0x100000000)). This means that mmap() allocations, if we treat them as returning an array, are not compliant with the sections 6.5.8 of the C standard (C99) which states that: "If the expression P points to an element of an array object and the expression Q points to the last element of the same array object, the pointer expression Q+1 compares greater than P". A solution to this problem is to reduce TASK_SIZE_32 of a page. But, in the current implementation, compat installs a special page called "[vectors]" that contains sigreturn trampolines and kuser helpers, and this is done at fixed address specified by the kuser helpers ABI (0xffff0000) which overlaps with the last page when 64K pages are enabled. This patchset address the issue creating separate pages for vectors and sigpage in a similar way to what happens today on arm and disabling kuser helpers when 64K pages are enabled. Cc: Catalin Marinas Cc: Will Deacon Cc: Jann Horn Cc: Mark Rutland Signed-off-by: Vincenzo Frascino Vincenzo Frascino (5): arm64: compat: Alloc separate pages for vectors and sigpage arm64: compat: Split kuser32 arm64: compat: Refactor aarch32_alloc_vdso_pages() arm64: compat: Add KUSER_HELPERS config option arm64: compat: Reduce address limit arch/arm64/Kconfig | 31 ++++++ arch/arm64/include/asm/elf.h | 6 +- arch/arm64/include/asm/processor.h | 6 +- arch/arm64/include/asm/signal32.h | 2 - arch/arm64/kernel/Makefile | 5 +- arch/arm64/kernel/kuser32.S | 65 +------------ arch/arm64/kernel/signal32.c | 5 +- arch/arm64/kernel/sigreturn32.S | 46 +++++++++ arch/arm64/kernel/vdso.c | 150 +++++++++++++++++++++++------ 9 files changed, 213 insertions(+), 103 deletions(-) create mode 100644 arch/arm64/kernel/sigreturn32.S