From patchwork Sun Jun 17 11:23:53 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: 10468843 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 C1EE76028E for ; Sun, 17 Jun 2018 11:49:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0244287AD for ; Sun, 17 Jun 2018 11:49:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A4640287BD; Sun, 17 Jun 2018 11:49:29 +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 C4A91287BA for ; Sun, 17 Jun 2018 11:49:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1267C6B027C; Sun, 17 Jun 2018 07:49:27 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0867E6B027E; Sun, 17 Jun 2018 07:49:26 -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 E4A076B027F; Sun, 17 Jun 2018 07:49:26 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f70.google.com (mail-pl0-f70.google.com [209.85.160.70]) by kanga.kvack.org (Postfix) with ESMTP id 9DB356B027C for ; Sun, 17 Jun 2018 07:49:26 -0400 (EDT) Received: by mail-pl0-f70.google.com with SMTP id 31-v6so8291163plf.19 for ; Sun, 17 Jun 2018 04:49:26 -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=17IJ8ufDSIOAw/+8WbfmU15XD0ulFm9Am/rp2YsVlWg=; b=IlNAIs0ywquRjKkBSCT4I7OcOMweFRz+TJEboAVX3fS3jrpf+r18pjDQAHl962MaUY vejAryaMpc3jrniTENpIr1kdjMv0KAn7zSpG6OM1vvX8wHDXQaa3HsjsM/IbOzesUhlE tjS8R4DVSU4qZgdMIQphLSukEV5HhQERAsOShbcApHWWIQsDnKad0cp1cexO8hWWCoSh lyJRYfkKkGrjDHNLi71+4zfkCZ7zxJ3y4GAMvJ4AP9WgmBCfz46ReiUNltid6wkRiWci kIZRqJ4nGgCgdQeeGk44QCFgOx3C3TKnd3vVvIAqnALUsDlvC/wtv0csXBee4NH3+ejI CLLw== X-Gm-Message-State: APt69E3yZKEZZpYTAfDjhzumBbKlPabxQxuwFZ6tzCc8k3MKJiWVB4EN u1xqZ6uVov4ZFtGXK6109wkf1wsjq0rES9CXpMCCYB7tUiyRev5cQElq4u37sGUV+6ZoAvWpS7/ Lgif81BCErIcBV7hKZtqJ/WUly7BZ61DBsOBkJYNl1BNIB3du+Yw3S+bx8mDtEm8= X-Received: by 2002:a17:902:8d86:: with SMTP id v6-v6mr6362708plo.325.1529236166301; Sun, 17 Jun 2018 04:49:26 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKDtcsir5PDFIGS+pXglqJAFth/luelEr+L9iZ9aUMXvlP6d1q8sXnlw2mC5+8mgKFWM1jU X-Received: by 2002:a17:902:8d86:: with SMTP id v6-v6mr6362673plo.325.1529236165463; Sun, 17 Jun 2018 04:49:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529236165; cv=none; d=google.com; s=arc-20160816; b=HX8+DsoxF7WJRmR+a7c+Fhfzy8xPkky5jejD3ml5WXKRlCXKShsmltxXjp4ZDSVqwF dgtott+kztvSaaMLlbVN8c0nCyCycxgEduHsqzpcOppZ/5oH0XYxMLLT06+U3lUBqe61 Pc8umKOxpKMnKf3JbQWHFpmM5cT5zx230p4YhQ1G6lVI/zYW1wougkghqtV7HQWifY8s oXMz0wFy4KGq7f7t+cp73CK74L8C1kAP++qHlhIuQFk/rjl8qOnSL5KKzRJmKgx8jK88 iMiLl3Vp6q+DzA+1OSTLzshZYIre/2DSpaAuIbhRI3C36CnibnyQBqu/HCnxO0zQy7NM IHGw== 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=17IJ8ufDSIOAw/+8WbfmU15XD0ulFm9Am/rp2YsVlWg=; b=m/fH+2foiUDCLLslzxxOF3W8jo1aI+D9lhBXVl5yaLeTbi2sZGatwdKp+mPgJXLJk6 ge5xrOzrvaedOe5IkgzcW9fkzx8+Xu8uzb9QqYom+cNZlfewcBYgAKhezNDUtXjsIsnd UAJNNeDFOX3Mucm4CAt5mLXQLNqbm/OTW7OajCDaGV6sl/BQ7JclVHjVC3BLvyWQBj9D yYDxs6+95PYOFIKZv364W6jyRFpTCfPZnPbaY48g3wQLKh81UR4flxx/ldWIoPy2HJcn PkAR+r+LwkQcjEy6REXsip4qxrg1m0UMw/1wJteGKSP39L6yHlDw4hgq6vFWC6xDfvMC 23Mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qu3LUXpy; 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 a76-v6si13510926pfk.35.2018.06.17.04.49.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Jun 2018 04:49:25 -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=qu3LUXpy; 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 916B0208E0; Sun, 17 Jun 2018 11:49:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1529236165; bh=CIZh5+n+yy6T5+B7YwESLwBaecRIs9odqGR0CCMCzgQ=; h=Subject:To:Cc:From:Date:From; b=qu3LUXpyhljevSxA4ZjeN9Yew1AaNBNKTFLj3C3uYf6jnKIJaySE4ytpXNPwHuI0C w9S3ihSSrI3k8wDJS8YYVPr6dQ4oTjj0qeOmbValmgnMEMnP+ZXst9ppPZaT9/AX+H aZBb4RMD0vVG/aF0uGi7JzP69pvYIPAe7vk2wh68= Subject: Patch "x86/pkeys/selftests: Adjust the self-test to fresh distros that export the pkeys ABI" has been added to the 4.16-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:53 +0200 Message-ID: <15292346334991@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.16-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.16 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:07:34 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.16/locking-rwsem-add-a-new-rwsem_anonymously_owned-flag.patch queue-4.16/x86-pkeys-selftests-factor-out-instruction-page.patch queue-4.16/kthread-sched-wait-fix-kthread_parkme-wait-loop.patch queue-4.16/proc-kcore-don-t-bounds-check-against-address-0.patch queue-4.16/stop_machine-sched-fix-migrate_swap-vs.-active_balance-deadlock.patch queue-4.16/kthread-sched-wait-fix-kthread_parkme-completion-issue.patch queue-4.16/init-fix-false-positives-in-w-x-checking.patch queue-4.16/x86-pkeys-selftests-fix-pointer-math.patch queue-4.16/x86-pkeys-selftests-adjust-the-self-test-to-fresh-distros-that-export-the-pkeys-abi.patch queue-4.16/locking-percpu-rwsem-annotate-rwsem-ownership-transfer-by-setting-rwsem_owner_unknown.patch queue-4.16/x86-pkeys-selftests-add-a-test-for-pkey-0.patch queue-4.16/x86-pkeys-selftests-stop-using-assert.patch queue-4.16/sched-core-introduce-set_special_state.patch queue-4.16/x86-pkeys-selftests-save-off-prot-for-allocations.patch queue-4.16/x86-pkeys-selftests-remove-dead-debugging-code-fix-dprint_in_signal.patch queue-4.16/x86-selftests-add-mov_to_ss-test.patch queue-4.16/sched-debug-move-the-print_rt_rq-and-print_dl_rq-declarations-to-kernel-sched-sched.h.patch queue-4.16/x86-mpx-selftests-adjust-the-self-test-to-fresh-distros-that-export-the-mpx-abi.patch queue-4.16/x86-pkeys-selftests-add-prot_exec-test.patch queue-4.16/sched-deadline-make-the-grub_reclaim-function-static.patch queue-4.16/objtool-kprobes-x86-sync-the-latest-asm-insn.h-header-with-tools-objtool-arch-x86-include-asm-insn.h.patch queue-4.16/x86-pkeys-selftests-allow-faults-on-unknown-keys.patch queue-4.16/x86-pkeys-selftests-give-better-unexpected-fault-error-messages.patch queue-4.16/x86-pkeys-selftests-avoid-printf-in-signal-deadlocks.patch queue-4.16/efi-libstub-arm64-handle-randomized-text_offset.patch queue-4.16/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());