From patchwork Sun Jun 17 11:23:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 10468857 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 9F9AD6028E for ; Sun, 17 Jun 2018 11:49:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E688287AD for ; Sun, 17 Jun 2018 11:49:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81CCE287BD; Sun, 17 Jun 2018 11:49:52 +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 D6B36287AD for ; Sun, 17 Jun 2018 11:49:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 25DE16B028A; Sun, 17 Jun 2018 07:49:50 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1E4566B028C; Sun, 17 Jun 2018 07:49:50 -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 0D4B66B028D; Sun, 17 Jun 2018 07:49:50 -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 C00EA6B028A for ; Sun, 17 Jun 2018 07:49:49 -0400 (EDT) Received: by mail-pl0-f71.google.com with SMTP id f5-v6so1688045plf.18 for ; Sun, 17 Jun 2018 04:49:49 -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=8Z1HSXP9JVFq++UGeaS0C68kuqeDEJg3uDLstOGiAnE=; b=A4apE9Va7x0JZ2GJbAitQrViMr4RQYUh88KH2B+dmdGKZMUvOQvjLckJfmQop58muJ E5FfBzmfE+n94A77RdyogFpCngKWPPJsAG9+53n+0+LUoqWt5ppvZ5uOOf51eStkfcqz nnvmZdMyOFRHtag8Tyyw24WHGHpCricyxX5QV/v/x9Fy1lSYECAMwxFUIUNPxrgzr4Sc gQmB3A3Ma4/sPBLKw9n35UnFS/Zs0X4ASb3QEFU5ZBcCNnwVZZjICrY3FIW4MxSbUEwa S+deuN0Nzoxz8V9p8qr/aT2JjXzPTFJdYWgzqxvyZBQCoRPcSMzaYShOhLd7uuKTH6FE GcLg== X-Gm-Message-State: APt69E3xE/GQCJvbp7kKCpzU6p0jyaoWp8e8Q48FWzSRKKgZkCp+0QCq u3IUTV3f7Z4EE62hB68oMcntyTR/B7TVsF9WTZ/gAcSCWy3gGyW3wsAuqv+Ked3GvsKEVMhh1fr f1B9bRX9yqq54t+YYF0VLo9mI+IlZSlW7fg/wxXigV5c37tqwv4nafQQSVftaPNE= X-Received: by 2002:a17:902:981:: with SMTP id 1-v6mr9901538pln.11.1529236189469; Sun, 17 Jun 2018 04:49:49 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJm6qTvXDwr2cJc+8rnoGSWy4Nq+QtyoAtFrCy3OOJl8GLZVSNuRSBOxKL0TgDTrNrcjZOD X-Received: by 2002:a17:902:981:: with SMTP id 1-v6mr9901497pln.11.1529236188629; Sun, 17 Jun 2018 04:49:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529236188; cv=none; d=google.com; s=arc-20160816; b=zYfMSbkAXEOYnrXIGrmwj+wQ0B1ZqyIOrf6tVgYZ87f2+6zCQhx177wPW4LfKL4WeN 94MFL47SfGWePOIoYFlt1lfkapslU3q0HE10HAzP69aAouNuIorSX4G5I1W01PQVYe/8 1bP7kN98pMhlcK60pNWb4waofAbCtHmpLfnbHQ/fFeHMGW7djerhQ9Q0wQ4YL4hcJ1Nh U61gaYXzjFc/KUBK+nIES1rH8SLTyanCZ0+XP4t5RxeNj/LQzbG6tWqKYlDtGPRf16aV /TCCGW+2Yh/shLwDaZmkP3XCfPjsjsKrbk1grFJ3uSY5PhmA9JUjRcdCp3D4hM3R32qw 6n7Q== 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=8Z1HSXP9JVFq++UGeaS0C68kuqeDEJg3uDLstOGiAnE=; b=kVQ4p7WpNaRAQNKkFD38yly+mq/K/rsR9al/tGRFxGt/arW4u1DrVHIDwfaeEhV5Yn AekiR3fDWHsVDBXzma6NT8DUx/Va0Q3kVEC3CtsPl3tED8VWE4hP0UadJx2JG1Cu0IaK 7BVuqX1nXOdOd4Cv0D7ZHSBT9wxSLQu0WTTF4cSips6SwLuqLHRusoYYY6ahkbwD+qrv 52lcCo5Q1LhWL78SumJMG1f+CBw4bsMMlFkeoUld0P8KVRqZURAIlapo064gRjDwexU4 hguc2/PrJ3rCT8+pEIPVfFG+5vsuU3MyvPcIQcdUa2CjReby9LFKDQ03mfkNpo7hkqJF 51Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cJIdjCyj; 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 r11-v6si12119253pfe.145.2018.06.17.04.49.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Jun 2018 04:49:48 -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=cJIdjCyj; 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 C024220896; Sun, 17 Jun 2018 11:49:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1529236188; bh=N4cKVaHxPAJdK3UabM3rU4V4dbcvd0GKbVQLdZCpKIU=; h=Subject:To:Cc:From:Date:From; b=cJIdjCyjdihnv3K/Pprrq0RKqkkVjPHITTkN4UrOr9z05S+EjUM4bHkADFHkq8nDP mTrfr7N53UafkS+aEkWwom0FrPqLUJVqX/e4FLlkImfmnvPmbpW8Pxe7bASAL5MSfa 81z+AcdZ1wy/ZdNTsyjBr4MxxLUbZ8unKurq9kX8= Subject: Patch "x86/pkeys/selftests: Save off 'prot' for allocations" has been added to the 4.16-stable tree To: 20180509171354.AA23E228@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:54 +0200 Message-ID: <1529234634205237@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: Save off 'prot' for allocations 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-save-off-prot-for-allocations.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:54 -0700 Subject: x86/pkeys/selftests: Save off 'prot' for allocations From: Dave Hansen [ Upstream commit acb25d761d6f2f64e785ccefc71e54f244f1eda4 ] This makes it possible to to tell what 'prot' a given allocation is supposed to have. That way, if we want to change just the pkey, we know what 'prot' to pass to mprotect_pkey(). Also, keep a record of the most recent allocation so the tests can easily find it. 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/20180509171354.AA23E228@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 | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 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 @@ -677,10 +677,12 @@ int mprotect_pkey(void *ptr, size_t size struct pkey_malloc_record { void *ptr; long size; + int prot; }; struct pkey_malloc_record *pkey_malloc_records; +struct pkey_malloc_record *pkey_last_malloc_record; long nr_pkey_malloc_records; -void record_pkey_malloc(void *ptr, long size) +void record_pkey_malloc(void *ptr, long size, int prot) { long i; struct pkey_malloc_record *rec = NULL; @@ -712,6 +714,8 @@ void record_pkey_malloc(void *ptr, long (int)(rec - pkey_malloc_records), rec, ptr, size); rec->ptr = ptr; rec->size = size; + rec->prot = prot; + pkey_last_malloc_record = rec; nr_pkey_malloc_records++; } @@ -756,7 +760,7 @@ void *malloc_pkey_with_mprotect(long siz pkey_assert(ptr != (void *)-1); ret = mprotect_pkey((void *)ptr, PAGE_SIZE, prot, pkey); pkey_assert(!ret); - record_pkey_malloc(ptr, size); + record_pkey_malloc(ptr, size, prot); rdpkru(); dprintf1("%s() for pkey %d @ %p\n", __func__, pkey, ptr); @@ -777,7 +781,7 @@ void *malloc_pkey_anon_huge(long size, i size = ALIGN_UP(size, HPAGE_SIZE * 2); ptr = mmap(NULL, size, PROT_NONE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); pkey_assert(ptr != (void *)-1); - record_pkey_malloc(ptr, size); + record_pkey_malloc(ptr, size, prot); mprotect_pkey(ptr, size, prot, pkey); dprintf1("unaligned ptr: %p\n", ptr); @@ -850,7 +854,7 @@ void *malloc_pkey_hugetlb(long size, int pkey_assert(ptr != (void *)-1); mprotect_pkey(ptr, size, prot, pkey); - record_pkey_malloc(ptr, size); + record_pkey_malloc(ptr, size, prot); dprintf1("mmap()'d hugetlbfs for pkey %d @ %p\n", pkey, ptr); return ptr; @@ -872,7 +876,7 @@ void *malloc_pkey_mmap_dax(long size, in mprotect_pkey(ptr, size, prot, pkey); - record_pkey_malloc(ptr, size); + record_pkey_malloc(ptr, size, prot); dprintf1("mmap()'d for pkey %d @ %p\n", pkey, ptr); close(fd);