From patchwork Mon Jun 18 08:13:42 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: 10469817 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 22F606029B for ; Mon, 18 Jun 2018 08:26:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 13A5728861 for ; Mon, 18 Jun 2018 08:26:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07DB728889; Mon, 18 Jun 2018 08:26:32 +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, 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 83A7E28861 for ; Mon, 18 Jun 2018 08:26:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 74B346B000D; Mon, 18 Jun 2018 04:26:30 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6D1F76B000E; Mon, 18 Jun 2018 04:26:30 -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 5726D6B0010; Mon, 18 Jun 2018 04:26:30 -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 0F5196B000D for ; Mon, 18 Jun 2018 04:26:30 -0400 (EDT) Received: by mail-pl0-f69.google.com with SMTP id x2-v6so9783342plv.0 for ; Mon, 18 Jun 2018 01:26:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:user-agent :mime-version; bh=EA38PbAYuMNdqXkJZkIKercjtjJqVqhKkcKESuQ+OXQ=; b=frdVBq41DNwn1j+pFPqZDhRaoQiozrjLPmUYfE8SQ8LSf4kfdiASaOxRgdEw5kGBvB qP8jzuWyp3vszjhQaJQE7QUQ2yg848JT8D+B3IvUaldzICREK2SrZp3K5GlFv1pP6Sus btWI45KHJpfiObNlN5Jg1Uznijcu4ya7d3JgKdlCo5efIT1yJnJsSQI9S0IOjyTF9IyY vm45SsNSWPX/QQY9yV0AuqtVk4y9+wV57qjam4AGRwgTiTmlORlj1ekGvEpx9L+XsPAf t3Dp2gM23CUclDcs7KZKqmHIUtdrpSQqce8cYUlxTecHB0B6IIZGSGzjv49PqGCeJ0GK 9Pkw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of gregkh@linuxfoundation.org designates 140.211.169.12 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org X-Gm-Message-State: APt69E0QoqXk0glNvJBJ9GTAW2AcB4PkyrwFz8TO6ZPUDW2WoJk3oVVJ A9xHQgOvLBhBXX6KP4JvBQA/AFWxnhY6h24HyD9OzgCboX1E876gatliIUyBuwQH1VdqwRi3bNy AZmkMT23neroPxzFeGLtXjacnKyKF0I04AY7HcVPw+3cW6tY25yhlkXASpBuuB1fsLQ== X-Received: by 2002:a63:755d:: with SMTP id f29-v6mr10115658pgn.278.1529310389724; Mon, 18 Jun 2018 01:26:29 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJPYZ4k8kQkoZAamOhBaYvP7qk5ujLDepdF+B6lepMunhDdnQYH7L4zgrnYteVV/Xau9qrB X-Received: by 2002:a63:755d:: with SMTP id f29-v6mr10115616pgn.278.1529310388879; Mon, 18 Jun 2018 01:26:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529310388; cv=none; d=google.com; s=arc-20160816; b=RHoC6NnorWvF4jC+L/drZugfck+8NSUhyF8Eik81sv2urwzxbdrIGl1AxzV/rVn1tk fck4HpVsYOwE/UPmIC/60xXY3v7pEkQlFym9//1t9NZedo9v3FGn+jIOT2ESi+hZ0cTK gGT8ys7EukJ16GlowsJ+wC+l75WWrV7NoyjzOunBAXI1vALgS+rtGiFGIHGrdG5ZY4dl 184ZBD5qpK7sSAiBs4sKu4R7cST2+0fyB2zm1kR2JsYiKEaSspBF/mrZYnN4H6QRtf5L PrWltuHV2bjpLbXzbDgbXgOzY1DOcrHg6SI5NnD1ZP0vmkrA6D6wRwc9RQXPjxGjBoZX hC8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=EA38PbAYuMNdqXkJZkIKercjtjJqVqhKkcKESuQ+OXQ=; b=WfM2IiLlOWXaOujmpdt0WhQso5NlK3RkEGX6/3N52Gw6Q96XCtngPllKUGXsRKWHrI zp3NZyiVGfTfLwUfkA5j7OAWdG2AigIl/f+iItyKgWScFvDUTY/n5W0MnMYdrygdnuFu K7ubpIv05VHCtYGqMPmkxu4vRxKezZRH5Y4qyUBaB1N6pSuWW2zdiaMqIXYbj+8HSXln dbJqMWdOqEz+bkzinx7Kokg+E/U/pJjM2K4WMdxVbe2pgBVGM5o/GkmSMNnaPrlxVS5+ g3Uj36t7LXt+DNTpwbdTAX29+SJeNBr0mp4coL/wTdgfizSU8MumTPuj/+HMZRpaXnLY ls/g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gregkh@linuxfoundation.org designates 140.211.169.12 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org. [140.211.169.12]) by mx.google.com with ESMTPS id f97-v6si12281900plb.291.2018.06.18.01.26.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Jun 2018 01:26:28 -0700 (PDT) Received-SPF: pass (google.com: domain of gregkh@linuxfoundation.org designates 140.211.169.12 as permitted sender) client-ip=140.211.169.12; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gregkh@linuxfoundation.org designates 140.211.169.12 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 02413C8D; Mon, 18 Jun 2018 08:26:28 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dave Hansen , Andrew Morton , Dave Hansen , Linus Torvalds , Michael Ellermen , Peter Zijlstra , Ram Pai , Shuah Khan , Thomas Gleixner , linux-mm@kvack.org, Ingo Molnar , Sasha Levin Subject: [PATCH 4.16 237/279] x86/pkeys/selftests: Give better unexpected fault error messages Date: Mon, 18 Jun 2018 10:13:42 +0200 Message-Id: <20180618080618.608268254@linuxfoundation.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618080608.851973560@linuxfoundation.org> References: <20180618080608.851973560@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 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 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dave Hansen [ Upstream commit 55556b0b2016806b2e16a20b62d143383983a34a ] do_not_expect_pk_fault() is a helper that we call when we do not expect a PK fault to have occurred. But, it is a function, which means that it obscures the line numbers from pkey_assert(). It also gives no details. Replace it with an implementation that gives nice line numbers and also lets callers pass in a more descriptive message about what happened that caused the unexpected fault. 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/20180509171338.55D13B64@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 | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) --- a/tools/testing/selftests/x86/protection_keys.c +++ b/tools/testing/selftests/x86/protection_keys.c @@ -954,10 +954,11 @@ void expected_pk_fault(int pkey) last_si_pkey = -1; } -void do_not_expect_pk_fault(void) -{ - pkey_assert(last_pkru_faults == pkru_faults); -} +#define do_not_expect_pk_fault(msg) do { \ + if (last_pkru_faults != pkru_faults) \ + dprintf0("unexpected PK fault: %s\n", msg); \ + pkey_assert(last_pkru_faults == pkru_faults); \ +} while (0) int test_fds[10] = { -1 }; int nr_test_fds; @@ -1243,7 +1244,7 @@ void test_ptrace_of_child(int *ptr, u16 pkey_assert(ret != -1); /* Now access from the current task, and expect NO exception: */ peek_result = read_ptr(plain_ptr); - do_not_expect_pk_fault(); + do_not_expect_pk_fault("read plain pointer after ptrace"); ret = ptrace(PTRACE_DETACH, child_pid, ignored, 0); pkey_assert(ret != -1); @@ -1287,7 +1288,7 @@ void test_executing_on_unreadable_memory */ madvise(p1, PAGE_SIZE, MADV_DONTNEED); lots_o_noops_around_write(&scratch); - do_not_expect_pk_fault(); + do_not_expect_pk_fault("executing on PROT_EXEC memory"); ptr_contents = read_ptr(p1); dprintf2("ptr (%p) contents@%d: %x\n", p1, __LINE__, ptr_contents); expected_pk_fault(pkey);