From patchwork Sun Jun 17 11:23:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 10468803 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A751E6029B for ; Sun, 17 Jun 2018 11:36:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9740128874 for ; Sun, 17 Jun 2018 11:36:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8BB0228A1B; Sun, 17 Jun 2018 11:36:21 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE91828874 for ; Sun, 17 Jun 2018 11:36:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 107876B000D; Sun, 17 Jun 2018 07:36:18 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0DDF66B000E; Sun, 17 Jun 2018 07:36:18 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F0C876B0010; Sun, 17 Jun 2018 07:36:17 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f69.google.com (mail-pl0-f69.google.com [209.85.160.69]) by kanga.kvack.org (Postfix) with ESMTP id B10376B000D for ; Sun, 17 Jun 2018 07:36:17 -0400 (EDT) Received: by mail-pl0-f69.google.com with SMTP id t19-v6so8283747plo.9 for ; Sun, 17 Jun 2018 04:36:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:subject:to:cc:from:date :message-id:mime-version:content-transfer-encoding; bh=JFCc5c2r7Wwp2XRevqn3MZl7gk64nsXgK0vlE+Yw7KM=; b=Q1cwLQ541e6mvFxGsYWYUBpOwyvdVTBND2LQpgWOS7BARsMhdYjYjzzrBhnVhH6qif YQvV0F5uSQY/Qz6k+fBOFemiiv1Qlvda/6ISm8xtz5tufDxBdQjitg+uvTbwelX6j07P z8fiWcL0NHMP3cuGoRiS+/pIDXtKKual3IB5+2jVFvJX5Ovrap8UW6eaO+SCymxQtUVc MB+Lvd3NWI5SRDdkRijyDZpUtJUUfh6W6UftU8TKdlxKbe5pqAp/AAg0s0baQb08BGAH knTT3NvMrrAD81coEGlrgcNFl0CIBQrepayr0cjdE2KjGAvcRey9tO4pxzlCBJkGc6MP EVpA== X-Gm-Message-State: APt69E3wym7Al12paentEdtVBzFBSo0693fOzvU7VeGRC52k3IYD4uCh 3Bu8fmsAuiepgS5ottdhRyFxH2XLwdem+dx1Y+JX+yNSgmWrvEqzzvmg38JLpCP7uqC4/C/1JWt ipK6xPRVIlqXDu/ighK4nOPf4R65iozwMWiIyKEQXVdXeiwOPZhQmJ5S9zwwXXTQ= X-Received: by 2002:a63:64c5:: with SMTP id y188-v6mr7804015pgb.37.1529235377367; Sun, 17 Jun 2018 04:36:17 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL1CdYM09e3yklvZDNi9y+Rd8uCUXQiDfMNFBZiLO+x3Iy+qvr4T9gD/R9hansO6c9W9HAj X-Received: by 2002:a63:64c5:: with SMTP id y188-v6mr7803972pgb.37.1529235376366; Sun, 17 Jun 2018 04:36:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529235376; cv=none; d=google.com; s=arc-20160816; b=IhgHkKyhc90BuX8Qlvb6juYnZxGat0xXg9Unsi0urayTcLLojW8pGW7/uiLxGXU1ei ZXr1XSR9UZ4oZY4DAQetXRb4ppNaiae37+luyNPEx8MSDA83n3jfDt316bvQrCI8Nd/+ v9iqOAKPM9RCqPYnjBIJVrd4n/G9xQfPOun1NnkHB/v7Jl1VHK+UhV4D3HpnHI4MhtkT egrW+N0gowEGcn/5UD5/+vndxVqyN6rPuMZSLDK2luRTNtcqVlbgdCleBLYepxEWu3Xv 3F14ltlLDsjTNHMXC4oawC4kFE8O4qtuJC9xewoo5J5PIYEKVEQEDpAI+svLc/RZ42+0 u7/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:from:cc:to :subject:dkim-signature:arc-authentication-results; bh=JFCc5c2r7Wwp2XRevqn3MZl7gk64nsXgK0vlE+Yw7KM=; b=KcKUrXxjTxaJJsBOmcYkTdb3mKtzYozoHpg776r74PE8ZlmK1BDrMUeN/ImDj1sgni cebCg5nnrd/ukCBH5BkI7yyUeu2ou7B2gg9TWsvhFik3k8le39DmsCu0Cmw9BdcENtuw vV3T8VYauqPHw4Rxafv9E6o4EJyOIZb9KEWwnwFSsXv0pDYFxm9H4qKDVaKsrjpgqksg zpN736uWPC4xFiDrDx41EKC2wSlvHOZMk3kp+I9inm+KeXv9jEd8VWXKC6K6x4zOYcYb mYxKtivgpA6zv+y+wbL5mvZSvbbRGVuKuunYURVDPdLQT74v8dQSd0qmMn5ydXqF15KH Hkyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tTas8aL8; spf=pass (google.com: domain of srs0=nxds=jd=linuxfoundation.org=gregkh@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom="SRS0=nXdS=JD=linuxfoundation.org=gregkh@kernel.org" Received: from mail.kernel.org (mail.kernel.org. [198.145.29.99]) by mx.google.com with ESMTPS id k5-v6si7471589plt.178.2018.06.17.04.36.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Jun 2018 04:36:16 -0700 (PDT) Received-SPF: pass (google.com: domain of srs0=nxds=jd=linuxfoundation.org=gregkh@kernel.org designates 198.145.29.99 as permitted sender) client-ip=198.145.29.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tTas8aL8; spf=pass (google.com: domain of srs0=nxds=jd=linuxfoundation.org=gregkh@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom="SRS0=nXdS=JD=linuxfoundation.org=gregkh@kernel.org" Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7DF4C208EA; Sun, 17 Jun 2018 11:36:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1529235376; bh=0ehkYDYNbssAyqn2XvWXAdD1mKyWeLsHxqfkfz4c0II=; h=Subject:To:Cc:From:Date:From; b=tTas8aL8cMDzkIZ1G/v7Zhx7aeMJIEAOz1izav98HlEHZV6Q2mI3PYu7rJ27Xd2jM JQTRua2/OmPYM4mbvZW/Nja03KHg7WqG9+6F+1ydnb46jaPApTX65tqkbgO0qzTXBh gCCDkMG6PXOZCRn1NP4GHjuPSiG5o6HcJMHaZ9gE= Subject: Patch "x86/pkeys/selftests: Adjust the self-test to fresh distros that export the pkeys ABI" has been added to the 4.14-stable tree To: 20180514085623.GB7094@gmail.com, akpm@linux-foundation.org, alexander.levin@microsoft.com, dave.hansen@intel.com, dave.hansen@linux.intel.com, gregkh@linuxfoundation.org, linux-mm@kvack.org, linuxram@us.ibm.com, mingo@kernel.org, mpe@ellerman.id.au, peterz@infradead.org, shakeelb@google.com, shuah@kernel.org, tglx@linutronix.de, torvalds@linux-foundation.org Cc: From: Date: Sun, 17 Jun 2018 13:23:31 +0200 Message-ID: <1529234611138121@kroah.com> MIME-Version: 1.0 X-stable: commit X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP This is a note to let you know that I've just added the patch titled x86/pkeys/selftests: Adjust the self-test to fresh distros that export the pkeys ABI to the 4.14-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: x86-pkeys-selftests-adjust-the-self-test-to-fresh-distros-that-export-the-pkeys-abi.patch and it can be found in the queue-4.14 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. From foo@baz Sun Jun 17 12:13:49 CEST 2018 From: Ingo Molnar Date: Mon, 14 May 2018 10:56:23 +0200 Subject: x86/pkeys/selftests: Adjust the self-test to fresh distros that export the pkeys ABI From: Ingo Molnar [ Upstream commit 0fb96620dce351608aa82eed5942e2f58b07beda ] Ubuntu 18.04 started exporting pkeys details in header files, resulting in build failures and warnings in the pkeys self-tests: protection_keys.c:232:0: warning: "SEGV_BNDERR" redefined protection_keys.c:387:5: error: conflicting types for ‘pkey_get’ protection_keys.c:409:5: error: conflicting types for ‘pkey_set’ ... Fix these namespace conflicts and double definitions, plus also clean up the ABI definitions to make it all a bit more readable ... Cc: Dave Hansen Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: akpm@linux-foundation.org Cc: dave.hansen@intel.com Cc: linux-mm@kvack.org Cc: linuxram@us.ibm.com Cc: mpe@ellerman.id.au Cc: shakeelb@google.com Cc: shuah@kernel.org Link: http://lkml.kernel.org/r/20180514085623.GB7094@gmail.com Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- tools/testing/selftests/x86/protection_keys.c | 67 +++++++++++++++----------- 1 file changed, 41 insertions(+), 26 deletions(-) Patches currently in stable-queue which might be from mingo@kernel.org are queue-4.14/locking-rwsem-add-a-new-rwsem_anonymously_owned-flag.patch queue-4.14/x86-pkeys-selftests-factor-out-instruction-page.patch queue-4.14/kthread-sched-wait-fix-kthread_parkme-wait-loop.patch queue-4.14/proc-kcore-don-t-bounds-check-against-address-0.patch queue-4.14/stop_machine-sched-fix-migrate_swap-vs.-active_balance-deadlock.patch queue-4.14/init-fix-false-positives-in-w-x-checking.patch queue-4.14/x86-pkeys-selftests-fix-pointer-math.patch queue-4.14/x86-pkeys-selftests-adjust-the-self-test-to-fresh-distros-that-export-the-pkeys-abi.patch queue-4.14/locking-percpu-rwsem-annotate-rwsem-ownership-transfer-by-setting-rwsem_owner_unknown.patch queue-4.14/x86-pkeys-selftests-add-a-test-for-pkey-0.patch queue-4.14/x86-pkeys-selftests-stop-using-assert.patch queue-4.14/sched-core-introduce-set_special_state.patch queue-4.14/x86-pkeys-selftests-save-off-prot-for-allocations.patch queue-4.14/x86-pkeys-selftests-remove-dead-debugging-code-fix-dprint_in_signal.patch queue-4.14/x86-selftests-add-mov_to_ss-test.patch queue-4.14/sched-debug-move-the-print_rt_rq-and-print_dl_rq-declarations-to-kernel-sched-sched.h.patch queue-4.14/x86-mpx-selftests-adjust-the-self-test-to-fresh-distros-that-export-the-mpx-abi.patch queue-4.14/x86-pkeys-selftests-add-prot_exec-test.patch queue-4.14/sched-deadline-make-the-grub_reclaim-function-static.patch queue-4.14/objtool-kprobes-x86-sync-the-latest-asm-insn.h-header-with-tools-objtool-arch-x86-include-asm-insn.h.patch queue-4.14/x86-pkeys-selftests-allow-faults-on-unknown-keys.patch queue-4.14/x86-pkeys-selftests-give-better-unexpected-fault-error-messages.patch queue-4.14/efi-libstub-arm64-handle-randomized-text_offset.patch queue-4.14/x86-pkeys-selftests-fix-pkey-exhaustion-test-off-by-one.patch --- a/tools/testing/selftests/x86/protection_keys.c +++ b/tools/testing/selftests/x86/protection_keys.c @@ -191,26 +191,30 @@ void lots_o_noops_around_write(int *writ #ifdef __i386__ #ifndef SYS_mprotect_key -# define SYS_mprotect_key 380 +# define SYS_mprotect_key 380 #endif + #ifndef SYS_pkey_alloc -# define SYS_pkey_alloc 381 -# define SYS_pkey_free 382 +# define SYS_pkey_alloc 381 +# define SYS_pkey_free 382 #endif -#define REG_IP_IDX REG_EIP -#define si_pkey_offset 0x14 + +#define REG_IP_IDX REG_EIP +#define si_pkey_offset 0x14 #else #ifndef SYS_mprotect_key -# define SYS_mprotect_key 329 +# define SYS_mprotect_key 329 #endif + #ifndef SYS_pkey_alloc -# define SYS_pkey_alloc 330 -# define SYS_pkey_free 331 +# define SYS_pkey_alloc 330 +# define SYS_pkey_free 331 #endif -#define REG_IP_IDX REG_RIP -#define si_pkey_offset 0x20 + +#define REG_IP_IDX REG_RIP +#define si_pkey_offset 0x20 #endif @@ -225,8 +229,14 @@ void dump_mem(void *dumpme, int len_byte } } -#define SEGV_BNDERR 3 /* failed address bound checks */ -#define SEGV_PKUERR 4 +/* Failed address bound checks: */ +#ifndef SEGV_BNDERR +# define SEGV_BNDERR 3 +#endif + +#ifndef SEGV_PKUERR +# define SEGV_PKUERR 4 +#endif static char *si_code_str(int si_code) { @@ -393,10 +403,15 @@ pid_t fork_lazy_child(void) return forkret; } -#define PKEY_DISABLE_ACCESS 0x1 -#define PKEY_DISABLE_WRITE 0x2 +#ifndef PKEY_DISABLE_ACCESS +# define PKEY_DISABLE_ACCESS 0x1 +#endif + +#ifndef PKEY_DISABLE_WRITE +# define PKEY_DISABLE_WRITE 0x2 +#endif -u32 pkey_get(int pkey, unsigned long flags) +static u32 hw_pkey_get(int pkey, unsigned long flags) { u32 mask = (PKEY_DISABLE_ACCESS|PKEY_DISABLE_WRITE); u32 pkru = __rdpkru(); @@ -418,7 +433,7 @@ u32 pkey_get(int pkey, unsigned long fla return masked_pkru; } -int pkey_set(int pkey, unsigned long rights, unsigned long flags) +static int hw_pkey_set(int pkey, unsigned long rights, unsigned long flags) { u32 mask = (PKEY_DISABLE_ACCESS|PKEY_DISABLE_WRITE); u32 old_pkru = __rdpkru(); @@ -452,15 +467,15 @@ void pkey_disable_set(int pkey, int flag pkey, flags); pkey_assert(flags & (PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE)); - pkey_rights = pkey_get(pkey, syscall_flags); + pkey_rights = hw_pkey_get(pkey, syscall_flags); - dprintf1("%s(%d) pkey_get(%d): %x\n", __func__, + dprintf1("%s(%d) hw_pkey_get(%d): %x\n", __func__, pkey, pkey, pkey_rights); pkey_assert(pkey_rights >= 0); pkey_rights |= flags; - ret = pkey_set(pkey, pkey_rights, syscall_flags); + ret = hw_pkey_set(pkey, pkey_rights, syscall_flags); assert(!ret); /*pkru and flags have the same format */ shadow_pkru |= flags << (pkey * 2); @@ -468,8 +483,8 @@ void pkey_disable_set(int pkey, int flag pkey_assert(ret >= 0); - pkey_rights = pkey_get(pkey, syscall_flags); - dprintf1("%s(%d) pkey_get(%d): %x\n", __func__, + pkey_rights = hw_pkey_get(pkey, syscall_flags); + dprintf1("%s(%d) hw_pkey_get(%d): %x\n", __func__, pkey, pkey, pkey_rights); dprintf1("%s(%d) pkru: 0x%x\n", __func__, pkey, rdpkru()); @@ -483,24 +498,24 @@ void pkey_disable_clear(int pkey, int fl { unsigned long syscall_flags = 0; int ret; - int pkey_rights = pkey_get(pkey, syscall_flags); + int pkey_rights = hw_pkey_get(pkey, syscall_flags); u32 orig_pkru = rdpkru(); pkey_assert(flags & (PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE)); - dprintf1("%s(%d) pkey_get(%d): %x\n", __func__, + dprintf1("%s(%d) hw_pkey_get(%d): %x\n", __func__, pkey, pkey, pkey_rights); pkey_assert(pkey_rights >= 0); pkey_rights |= flags; - ret = pkey_set(pkey, pkey_rights, 0); + ret = hw_pkey_set(pkey, pkey_rights, 0); /* pkru and flags have the same format */ shadow_pkru &= ~(flags << (pkey * 2)); pkey_assert(ret >= 0); - pkey_rights = pkey_get(pkey, syscall_flags); - dprintf1("%s(%d) pkey_get(%d): %x\n", __func__, + pkey_rights = hw_pkey_get(pkey, syscall_flags); + dprintf1("%s(%d) hw_pkey_get(%d): %x\n", __func__, pkey, pkey, pkey_rights); dprintf1("%s(%d) pkru: 0x%x\n", __func__, pkey, rdpkru());