From patchwork Sun Jun 17 11:23:31 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: 10468807 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 418D96029B for ; Sun, 17 Jun 2018 11:36:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3326928874 for ; Sun, 17 Jun 2018 11:36:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 27F1528A1B; Sun, 17 Jun 2018 11:36: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 89F7B28874 for ; Sun, 17 Jun 2018 11:36:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7997A6B0266; Sun, 17 Jun 2018 07:36:23 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 745A26B0269; Sun, 17 Jun 2018 07:36:23 -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 4B12B6B026A; Sun, 17 Jun 2018 07:36:23 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f72.google.com (mail-pl0-f72.google.com [209.85.160.72]) by kanga.kvack.org (Postfix) with ESMTP id 0B1206B0266 for ; Sun, 17 Jun 2018 07:36:23 -0400 (EDT) Received: by mail-pl0-f72.google.com with SMTP id d6-v6so5302995plo.15 for ; Sun, 17 Jun 2018 04:36:23 -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=S83s7M5laFv5NT1OftWMzry5ApY5O7YyA83f02dSOA8=; b=AdJqg/XvFrk/gP660pPBCss0uUNFYkkztGe8C7gXXFwylbWWEOZ6X4Tpqh+mC6ewWa feKC6FjRXbbbxlBV4lNqvBDuBMftUr/zrW3tFl97rS2UJQybGzQ2g3HD040SAFhy84De kE2ChAMvR5T/MMrIgItSUWbVh+76JUTg2JNlXe/xtAVofyWlER4n69KcowxJC1aNSuBe p1sBuT+NgdpuJL+p30wmjOXlWdZPCFG5Eb46CGPAkuqgoxJg9rE2xiiTYaCZTRXvDw4H ctTwveDnrbp5Y1I+899tGo3Z1bVPN7Paw+MZHy53fg69pX4Ijo9oOj/C7Sgafx4YyC3c nkuQ== X-Gm-Message-State: APt69E3bjHIun7lMF+bca/XiDnXmG0gF2Y5GaiXsauyfcChHZR+1vSxI FAuzxX3cD50cSX/FMw4iBJS8SHUvv8nYMNBkDzERcfKBCA5ne0hB9jT5iPB3lbfqcwgEJzEVDsb g3PGJxSuGqNtBztRt4TzzxION3rcdm71LKLgZNEU7jbbvU/OJB5uryUKD6lc1NHU= X-Received: by 2002:a17:902:48c8:: with SMTP id u8-v6mr9809010plh.152.1529235382714; Sun, 17 Jun 2018 04:36:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLH774QtBki7a+r42onA4D357j3DIqCpW8ZYgpFphsmfbziD5ppt41D4+KoU/TKLOUakaw4 X-Received: by 2002:a17:902:48c8:: with SMTP id u8-v6mr9808976plh.152.1529235381904; Sun, 17 Jun 2018 04:36:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529235381; cv=none; d=google.com; s=arc-20160816; b=CXPP8+yXCvoKuTAoP9/veNWnSj3iH7bFAvQtx/jNfpH75/UbuZ+pyN61FfRkQPrHGo rSuB/9a7OdfJZAxs2d939Mb7pnmXLCvqKb6Fopat7ZTTTXNVearqNntbTDS9jp9U3XVk 6HuPq6JMvclGqqSN4ouzbfmn323b9g+ml2qSFnCQdxEdETGvBs3ZZIkg1xMvTwgpq8CU YbWJ9QO9Gzx9Jeg6SJ3uW4Ot8eJswdj9cgYDY1wv4CByf0qOk3Q+cxoGD/1yIDQkv9YU X5h0Cr7KzW5b5IZWQB5oz0EXSQG0IHROt1qRmCFXKyq1zVnnm3DCbzycERoK2kojH366 tTzA== 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=S83s7M5laFv5NT1OftWMzry5ApY5O7YyA83f02dSOA8=; b=oYgVeeSq0WE5eBD4a2HkgqFq2x/cCJqy9U4kvnjEHxcO/XM3MZuxghcqfzBa8JXgX4 flmR0ggsxDyBwHebtt2in6RyTLA+OF2RUAJS9dSPLRiojXoR5bv3noWu782moMixfVCw bjEH5/WssUqGbeCNtX9JsJCLaTJCmo3AhGOeIn7+ngDo1c8eO0Yhvylc3Rj3e7xtho5C y6+oJbKAh19xB3mR5CmLRLvpN62u6GHMbL6c+ZQEjrzBnVi0yP55H4C25k/K2zCkRY4/ 03GpZKrPWS+4Nns2whsZcGD1pfflGpyYTzYJYNfmF8L++3If5Zh4Nfd9uVZtffAHUvZW h04A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Gd+dc7V4; 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 e37-v6si12275450plb.400.2018.06.17.04.36.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Jun 2018 04:36:21 -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=Gd+dc7V4; 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 0E0F820989; Sun, 17 Jun 2018 11:36:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1529235381; bh=/FAmOfftG3itJVfjr4Z2qzr2S0ISbt0NNjrmrqCk2BU=; h=Subject:To:Cc:From:Date:From; b=Gd+dc7V4jni5W3uKOUndeNH1XNsWKYXKeoNK/s4iS319UtnrOvs2g7atYIIxmsxqM 1SKobSQ26U5Gk4uS5oA0V/CZTQOC/CMqicDMM9G1S3cEIuAQHHNANs0QEwZCK6oNkU ON3VzjTWxCwxUZnARTbWPY/IU6Y0ovWsUjZtUR3M= Subject: Patch "x86/pkeys/selftests: Factor out "instruction page"" has been added to the 4.14-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:31 +0200 Message-ID: <152923461115132@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.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-factor-out-instruction-page.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: 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.14/x86-pkeys-selftests-factor-out-instruction-page.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/x86-pkeys-selftests-add-a-test-for-pkey-0.patch queue-4.14/x86-pkeys-selftests-stop-using-assert.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-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/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/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);