From patchwork Sun Jun 17 11:23:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 10468849 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 AF8BD6028E for ; Sun, 17 Jun 2018 11:49:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E122287AD for ; Sun, 17 Jun 2018 11:49:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 926E4287BD; Sun, 17 Jun 2018 11:49:38 +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 00EC6287AD for ; Sun, 17 Jun 2018 11:49:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 14DD66B0282; Sun, 17 Jun 2018 07:49:36 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0FB766B0284; Sun, 17 Jun 2018 07:49:36 -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 F32D26B0285; Sun, 17 Jun 2018 07:49:35 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f71.google.com (mail-pl0-f71.google.com [209.85.160.71]) by kanga.kvack.org (Postfix) with ESMTP id 907F76B0282 for ; Sun, 17 Jun 2018 07:49:35 -0400 (EDT) Received: by mail-pl0-f71.google.com with SMTP id e1-v6so8217370pld.23 for ; Sun, 17 Jun 2018 04:49:35 -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=qH5g7Gs3FSzbijD3VQLteqPrqvjzv7SP38Gb+tstnWA=; b=DFRpOdygQpjcNYgThO/a2bY9Xvr53nIJFVtuU/CtBP9cHyigy42f2gAiDlgPESqMMb 8ta0zQI8phzEmte2vUgfOiTp28ucbIXywjdKjYcEzsTp1n2Gag5ooAt2bebsM5gyCNBK RN2M7c/s4mhntbdRRsTA6h30Z5NdoR1nEN/PRGPXJ8sJ5wAtkx50+GQ9euLlAfawzevd WZdF3scGiVyV3QtAAJmYkLyFXLhjthcp/2xMEtmRCpf+GgQnRY5ZsB5KGJwve1mPXeOQ 4dmFvxg5tbzzDgHzKaXUGMgVpLzmi96qxqzYaLx+y5b4EfGApl46fz5ZJ42HGlJ1U0Nx YBgg== X-Gm-Message-State: APt69E3QcUt8+2IvGiTh0C0cyh9w6twybRdnoPP+qnhHd2dPg6KE0kIU i1MC/MWAgPw1JmkMZXU5b3YKzg6MTDiEuD2shVyZdU0nYQhT+AhuyBPXEnfEb71Fwz/O7XZBKUv IGjsT4WZf8Xy+rDvx+oVzsL9sPypgQknyebuV9bqFS5Dp2tywJgw/G4NP9Bdyqt4= X-Received: by 2002:a63:4701:: with SMTP id u1-v6mr7751912pga.34.1529236175235; Sun, 17 Jun 2018 04:49:35 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLzoZWlxXhggYuxALCDdOaoCVHrJn8tCDrWxc6DlEuazvhV8K2P+YHkNiw2zHhcvD3uB8zS X-Received: by 2002:a63:4701:: with SMTP id u1-v6mr7751884pga.34.1529236174376; Sun, 17 Jun 2018 04:49:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529236174; cv=none; d=google.com; s=arc-20160816; b=LVS2/rhsG4cf8kx6msYqyi+MRDrFL80fm+RCM1O0oH0bZ5dYSa0BYr7CI5bgwk2+R4 zwa9DujkrUgbktWyJ0iunyIkDzDGmwiLFwpAPjcXtshc4HcIiYJrrrTsgspQTI3JtTJy FAwfQLgk7lBKk8h8gjuqwzTOiqD6eJE6rCO59MFTinhtLLhFIh9ihkC9QRP8n4lZHE58 E38Go8TmSKUaT4lPhXzIzFus+1DnjPCu++jNkeleq1jC2rcxXhJVWQHddH83C5leW3EN zSAsYTe9EmbVMbWqw+5XPzoGZQgE0G7EDV1KGifWvhplX9qhEWfXBw9J00xYmfj/JJPG Dqow== 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=qH5g7Gs3FSzbijD3VQLteqPrqvjzv7SP38Gb+tstnWA=; b=zqD+s8YB7Bqz+IftdEcuIaDNuldmf8IRGPpFrpJAXBc1h0lO2mxkAtoqZPb+0EyJnr /CA9Grd2/SFDO9CeoxSLvq0dE737P2wIUaXPiF9uLNbpm7a3Qd/trTvcIDextEFH4z+C AgrD/pijmYswRV7XyM4BTbIaTMTmDnCrDkgtzYSjCzM8F42b4dDSLq+GXYqgvTsCVUrI i/G1VxsrDN4uG17x6nc+zWXO2WCJIIKcCUQEv79C0kbjYSKi1tipZi6hcF/HrKmtmroG F3991Pkhugts0go7BWnR+jNor6CB6oSPVVNrdUtM3ePghXF5GTFjithWIE/5IAbfHne8 X9/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ypUjkpTS; 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 33-v6si13434627plf.133.2018.06.17.04.49.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Jun 2018 04:49:34 -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=ypUjkpTS; 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 804C020863; Sun, 17 Jun 2018 11:49:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1529236174; bh=i2s1O0yZxGDBbi7EzIeAS9YTu7okZXpNFLVRH/j+Q6A=; h=Subject:To:Cc:From:Date:From; b=ypUjkpTS9g1FYXQhrv0p64FE4VgoA69AjTGuMNtBIiN4b0lyh4589L7UwrTnXo03j lIE3NDWo+fh4X3L3a+9BNyIKfqboEhNODwDQaai6e68U8ZaEdt46Hnz2ORFLs/NqXo r+ZP0K3wgKoHXpN/59WiDHgN2HSaGCEjyg/mJQ00= Subject: Patch "x86/pkeys/selftests: Factor out "instruction page"" has been added to the 4.16-stable tree To: 20180509171347.C64AB733@viggo.jf.intel.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, shuah@kernel.org, tglx@linutronix.de, torvalds@linux-foundation.org Cc: From: Date: Sun, 17 Jun 2018 13:23:53 +0200 Message-ID: <1529234633176112@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: Factor out "instruction page" 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-factor-out-instruction-page.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: Dave Hansen Date: Wed, 9 May 2018 10:13:47 -0700 Subject: x86/pkeys/selftests: Factor out "instruction page" From: Dave Hansen [ Upstream commit 3fcd2b2d928904cbf30b01e2c5e4f1dd2f9ab262 ] We currently have an execute-only test, but it is for the explicit mprotect_pkey() interface. We will soon add a test for the implicit mprotect(PROT_EXEC) enterface. We need this code in both tests. Signed-off-by: Dave Hansen Cc: Andrew Morton Cc: Dave Hansen Cc: Linus Torvalds Cc: Michael Ellermen Cc: Peter Zijlstra Cc: Ram Pai Cc: Shuah Khan Cc: Thomas Gleixner Cc: linux-mm@kvack.org Link: http://lkml.kernel.org/r/20180509171347.C64AB733@viggo.jf.intel.com Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- tools/testing/selftests/x86/protection_keys.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) Patches currently in stable-queue which might be from dave.hansen@linux.intel.com are queue-4.16/x86-pkeys-selftests-factor-out-instruction-page.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/x86-pkeys-selftests-add-a-test-for-pkey-0.patch queue-4.16/x86-pkeys-selftests-stop-using-assert.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-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/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/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 @@ -1253,12 +1253,9 @@ void test_ptrace_of_child(int *ptr, u16 free(plain_ptr_unaligned); } -void test_executing_on_unreadable_memory(int *ptr, u16 pkey) +void *get_pointer_to_instructions(void) { void *p1; - int scratch; - int ptr_contents; - int ret; p1 = ALIGN_PTR_UP(&lots_o_noops_around_write, PAGE_SIZE); dprintf3("&lots_o_noops: %p\n", &lots_o_noops_around_write); @@ -1268,7 +1265,23 @@ void test_executing_on_unreadable_memory /* Point 'p1' at the *second* page of the function: */ p1 += PAGE_SIZE; + /* + * Try to ensure we fault this in on next touch to ensure + * we get an instruction fault as opposed to a data one + */ madvise(p1, PAGE_SIZE, MADV_DONTNEED); + + return p1; +} + +void test_executing_on_unreadable_memory(int *ptr, u16 pkey) +{ + void *p1; + int scratch; + int ptr_contents; + int ret; + + p1 = get_pointer_to_instructions(); lots_o_noops_around_write(&scratch); ptr_contents = read_ptr(p1); dprintf2("ptr (%p) contents@%d: %x\n", p1, __LINE__, ptr_contents);