From patchwork Wed May 9 17:13:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Hansen X-Patchwork-Id: 10390261 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 7183560236 for ; Wed, 9 May 2018 17:19:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 628072851A for ; Wed, 9 May 2018 17:19:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 56C1028524; Wed, 9 May 2018 17:19:23 +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=unavailable 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 2E73C2851A for ; Wed, 9 May 2018 17:19:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AF02C6B0547; Wed, 9 May 2018 13:19:00 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A79836B0548; Wed, 9 May 2018 13:19:00 -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 915F76B0549; Wed, 9 May 2018 13:19:00 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f200.google.com (mail-pf0-f200.google.com [209.85.192.200]) by kanga.kvack.org (Postfix) with ESMTP id 483C66B0547 for ; Wed, 9 May 2018 13:19:00 -0400 (EDT) Received: by mail-pf0-f200.google.com with SMTP id c187so1913893pfa.20 for ; Wed, 09 May 2018 10:19:00 -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:subject:to:cc :from:date:references:in-reply-to:message-id; bh=qAopVq0gZNCQPsaVz64sjaatJ3W9nWKfHvoPEdNqxE4=; b=T943N8ZAd4nXHR1+GmvkvshVgcCDDRQr0D9Rp0TG1sQyFmu/RdO7NkMB/7MoXOIZKO udyZgt2BdwS1+gjMIbsC2db486rVx26CLZ3gZqBVx+N7RMHVGdpXIoh+mSlzNljXuBw0 Mlc1gv16iXkQXuhcm3HnKGZlbZF8threO+Zii44UrI4Q7wKmPNkdLZ3elgWPyiCkGKLz yQSdb8gPyax/ojZa+uwop3hBcZJbSC8C4xSg9D1I55arwH4Pi4hJWWjUWtHGkhoVDSKu wQvc7LZMZr/QLjgjnCkq9qx+kzfLvYBSc7QJt7b1pXq/SFjE+f+yRUiwJbO9Qxo3VCQB cT7A== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dave.hansen@linux.intel.com designates 134.134.136.20 as permitted sender) smtp.mailfrom=dave.hansen@linux.intel.com X-Gm-Message-State: ALQs6tBYNKu4ihA9zwJwM/hzP9ajGJane/5FgwwTgvuQgHeTwcai0bgb 3fiVRzocz/NqWfvBLh4SEh90nZ+QJODP+ot1RO3UsM/o8Uc2eUrPP+/xYDa29mOG4nsveL+IIhJ Q0KllXRI67rzezSDlwgXaMxE4jC3w8JmDAZu6PalgAuCe3GYnix/KrKtV3+qg3pOB0Q== X-Received: by 2002:a65:4d8f:: with SMTP id p15-v6mr32707219pgq.305.1525886339962; Wed, 09 May 2018 10:18:59 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqUco/mWQYmYRwlWoCVmcqUUkr15I0fAK+gcw8Thz4JfTvPFmfnm589ofX6wqHtUWwjj8eI X-Received: by 2002:a65:4d8f:: with SMTP id p15-v6mr32707198pgq.305.1525886339297; Wed, 09 May 2018 10:18:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525886339; cv=none; d=google.com; s=arc-20160816; b=1HUhCnQyyhZlQZ7mXdm7rfL3uIzb9/eYmLHPbw80N1rH74uK+Xy4zs5LZU7Gfp2+DH kazF3PvB6QfsrEKepcWjBdk6MOuIU/dFRCqlCF9n3EhhznwlCSlZFBdZClLfh+McfIAQ AcxuYwof1hqzlk6h6SM5ZUmr32VO8Gd4CeqJqlVxJVQza5KZhfIhVTeyPSg7qN+hyEfK 8WNkkgGB19y9r8Uy6bVxPJlc6C0XTMG5wsQEnwFECKcE+PebS1SNAsxka0xff+AEC7eO +/GQG8zdaTTLTdiqoQs75Eg84m7DlVFkUUpumJgVpKspOSRDpPg3gVbordv9s7I5u7ec J9jA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:in-reply-to:references:date:from:cc:to:subject :arc-authentication-results; bh=qAopVq0gZNCQPsaVz64sjaatJ3W9nWKfHvoPEdNqxE4=; b=uI9IdhfvOzptQCF+AqMZ/xJm6JHNLNMf3I+0EDLqb+ZttK8Pa9coslaOTcdwRoIMrD Bf+OuE3ooBCUWyTjdKRGju4dw//C4VelEIwEwVwq6qcyb1YZEWAMZYZEpxpIK6/S2jrV ellVpCFHips2mq6YNBt9tzDnxMwZEugBYeS7KhRJNta+H1netOgcHwdegyF6Dfo5LjFF 2GgYgKquar0tXL1h+ZFW3NzNk2YOkz0+umIvpX+yoln6n1g5pM/sZ22A37SKvfRr6406 84yFAGfvcNSau1xTErO23YckXUKo63X9cSATnUze4dcSf8pOrBa4V9XWsbGgYeQSIqQw ViWw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dave.hansen@linux.intel.com designates 134.134.136.20 as permitted sender) smtp.mailfrom=dave.hansen@linux.intel.com Received: from mga02.intel.com (mga02.intel.com. [134.134.136.20]) by mx.google.com with ESMTPS id t127-v6si1047914pgc.519.2018.05.09.10.18.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 May 2018 10:18:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dave.hansen@linux.intel.com designates 134.134.136.20 as permitted sender) client-ip=134.134.136.20; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dave.hansen@linux.intel.com designates 134.134.136.20 as permitted sender) smtp.mailfrom=dave.hansen@linux.intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 May 2018 10:18:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,382,1520924400"; d="scan'208";a="227180609" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.39.119]) by fmsmga006.fm.intel.com with ESMTP; 09 May 2018 10:18:58 -0700 Subject: [PATCH 10/13] x86/pkeys/selftests: Fix pointer math To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Dave Hansen , linuxram@us.ibm.com, tglx@linutronix.de, dave.hansen@intel.com, mpe@ellerman.id.au, mingo@kernel.org, akpm@linux-foundation.org, shuah@kernel.org From: Dave Hansen Date: Wed, 09 May 2018 10:13:52 -0700 References: <20180509171336.76636D88@viggo.jf.intel.com> In-Reply-To: <20180509171336.76636D88@viggo.jf.intel.com> Message-Id: <20180509171352.9BE09819@viggo.jf.intel.com> 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 From: Dave Hansen We dump out the entire area of the siginfo where the si_pkey_ptr is supposed to be. But, we do some math on the poitner, which is a u32. We intended to do byte math, not u32 math on the pointer. Cast it over to a u8* so it works. Also, move this block of code to below th si_code check. It doesn't hurt anything, but the si_pkey field is gibberish for other signal types. Signed-off-by: Dave Hansen Cc: Ram Pai Cc: Thomas Gleixner Cc: Dave Hansen Cc: Michael Ellermen Cc: Ingo Molnar Cc: Andrew Morton Cc: Shuah Khan --- b/tools/testing/selftests/x86/protection_keys.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff -puN tools/testing/selftests/x86/protection_keys.c~pkeys-selftests-fix-pointer-math tools/testing/selftests/x86/protection_keys.c --- a/tools/testing/selftests/x86/protection_keys.c~pkeys-selftests-fix-pointer-math 2018-05-09 09:20:22.825698397 -0700 +++ b/tools/testing/selftests/x86/protection_keys.c 2018-05-09 09:20:22.830698397 -0700 @@ -293,13 +293,6 @@ void signal_handler(int signum, siginfo_ dump_mem(pkru_ptr - 128, 256); pkey_assert(*pkru_ptr); - si_pkey_ptr = (u32 *)(((u8 *)si) + si_pkey_offset); - dprintf1("si_pkey_ptr: %p\n", si_pkey_ptr); - dump_mem(si_pkey_ptr - 8, 24); - siginfo_pkey = *si_pkey_ptr; - pkey_assert(siginfo_pkey < NR_PKEYS); - last_si_pkey = siginfo_pkey; - if ((si->si_code == SEGV_MAPERR) || (si->si_code == SEGV_ACCERR) || (si->si_code == SEGV_BNDERR)) { @@ -307,6 +300,13 @@ void signal_handler(int signum, siginfo_ exit(4); } + si_pkey_ptr = (u32 *)(((u8 *)si) + si_pkey_offset); + dprintf1("si_pkey_ptr: %p\n", si_pkey_ptr); + dump_mem((u8 *)si_pkey_ptr - 8, 24); + siginfo_pkey = *si_pkey_ptr; + pkey_assert(siginfo_pkey < NR_PKEYS); + last_si_pkey = siginfo_pkey; + dprintf1("signal pkru from xsave: %08x\n", *pkru_ptr); /* need __rdpkru() version so we do not do shadow_pkru checking */ dprintf1("signal pkru from pkru: %08x\n", __rdpkru());