From patchwork Mon Jun 18 08:14:18 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: 10470143 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 B7DE66029B for ; Mon, 18 Jun 2018 08:38:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A893D26E3C for ; Mon, 18 Jun 2018 08:38:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D63F28449; Mon, 18 Jun 2018 08:38:22 +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 20CAF26E3C for ; Mon, 18 Jun 2018 08:38:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7409E6B0273; Mon, 18 Jun 2018 04:38:20 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6F2D36B0274; Mon, 18 Jun 2018 04:38:20 -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 5E1F66B0275; Mon, 18 Jun 2018 04:38:20 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg0-f70.google.com (mail-pg0-f70.google.com [74.125.83.70]) by kanga.kvack.org (Postfix) with ESMTP id 1E7C56B0273 for ; Mon, 18 Jun 2018 04:38:20 -0400 (EDT) Received: by mail-pg0-f70.google.com with SMTP id t5-v6so4926019pgt.18 for ; Mon, 18 Jun 2018 01:38:20 -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=y4OPn8xENSlWXx0DpJq76XCukpSEuDQTt78ORUO+mP0=; b=CSEukWd2fGACT1HMURYWWkhjpS7Qgelk+ieqCv1AbHMO33QmuI1nWL4bfSV4D7Ic/g yK1lMsDoqVFl2EBzwO7/orio4ZQF4eOkcIkNpvS9pDK18AaanwfXnxy3RQnJTOswm1g7 kEiEd0otB2mCyfoNRVuK1xTlu/Fl+E0qtKx2ZHic6fGf+aQRPQdVQVIV6bh7y9ALhQZ2 ZVmAAoxmhfYqAWmdxSH+XnzcTL+1V5W0hhzvMjUNnkxigieGvPxnzwL/h078sUHFO/eB jBo8BxseneD0cgeYZsHoaQ47cMaEKaW6PUNIMIPgkPHlqqx3rYlqLvttsz7wo318S5/g xamg== 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: APt69E2+oFFFCFkK46DtbILoAuNgevXowrZPQ0T7WuLb0gRdNOYX+kHD 30LF3D/Dc4+ARLelHOjwJZaS80fM+ADmPgrGBoRiGW+B3wm19svGfzGSlORfhHqJGZyu2hCXxyB 8zOQWO/ttllxRmgrgT0LAMe8bFVKnKbGPOYSjSR3fENdvZBy87AU16oAoy5FGk5wBSA== X-Received: by 2002:a62:f0d:: with SMTP id x13-v6mr12577250pfi.100.1529311099798; Mon, 18 Jun 2018 01:38:19 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIJVhST3/HyIHbf5f8TpNRSYBIfFpkQEOmz2lzZronthbrv8/mTZw7siugDBYokpSostwOo X-Received: by 2002:a62:f0d:: with SMTP id x13-v6mr12577207pfi.100.1529311099039; Mon, 18 Jun 2018 01:38:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529311099; cv=none; d=google.com; s=arc-20160816; b=O0gyS9XgfrDH8BpUuP9xsWGBVz4Tks+E/oQMwxXSNmsMfmfaLfNQ3j3P4m15k/CtHF RpgbzYW94kRWDglumeGTaZX1XULmBZPtzIAMgCVXkPOlaMMyqVB6v96ui4c+JxmR4iDr USzRG3rOtP9Zp+QK06xcrgcuRh16V6PxHbhR1VXA6GgAa8v63fFaf7mw0iWadPzrBdk+ E8OasHGoinj81Mbow0Y/l3KCw59GgDQW6crIL16AtePmglmv9ME1Tlo+o7R13W1MkfLn EAyCaVGIkaZEq/O9hCEhEKiGYTPTYe6aqZ61vMB63F+xZESAd7wX7RiDlrBJFUGJB6O9 CUhw== 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=y4OPn8xENSlWXx0DpJq76XCukpSEuDQTt78ORUO+mP0=; b=UO2Y0xu6AK3LUlKknDYnbEVbPewGPCbZCTI3yOXvPr1NbCs2eed1LqQ0XUgfp/6ESF KWqvSoi2Ewqm7enHryulNjqZTDMvTwyxQhDwF+//sgeH7JwZG2OwdNu0CgdkSJsrekf1 R1PONx/aDJv6MiOMzTkA70yK1JZy4xiPTY+dbUMw3sZ24YJ+5HCXH9ZFRSnXdLjvwQUz ZMFezvZDpSuRg/YelbCwOC8l5R6f0sq7+e1Wzlo7AeBciHDbgB4JCgFQ8iiDK8xn6CRk KKg+1MyO3VBkFWaFeSYT6firC9ixryjfknM9eM/bqon4rRuYnkegvn8aG4qtaItw8elM 1QgA== 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 q13-v6si14861153plr.220.2018.06.18.01.38.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Jun 2018 01:38:19 -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 339C2CBB; Mon, 18 Jun 2018 08:38:18 +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.14 162/189] x86/pkeys/selftests: Fix pointer math Date: Mon, 18 Jun 2018 10:14:18 +0200 Message-Id: <20180618081215.733540335@linuxfoundation.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618081209.254234434@linuxfoundation.org> References: <20180618081209.254234434@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.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dave Hansen [ Upstream commit 3d64f4ed15c3c53dba4c514bf59c334464dee373 ] 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: 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/20180509171352.9BE09819@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, 7 insertions(+), 7 deletions(-) --- a/tools/testing/selftests/x86/protection_keys.c +++ b/tools/testing/selftests/x86/protection_keys.c @@ -303,13 +303,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)) { @@ -317,6 +310,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());