From patchwork Mon Jun 18 08:13:50 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: 10469871 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 995BF6029B for ; Mon, 18 Jun 2018 08:28:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8952228861 for ; Mon, 18 Jun 2018 08:28:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D70A288B8; Mon, 18 Jun 2018 08:28:08 +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 EFB8128861 for ; Mon, 18 Jun 2018 08:28:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 266246B0010; Mon, 18 Jun 2018 04:28:06 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 23D226B0266; Mon, 18 Jun 2018 04:28:06 -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 1052A6B0269; Mon, 18 Jun 2018 04:28:06 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f198.google.com (mail-pf0-f198.google.com [209.85.192.198]) by kanga.kvack.org (Postfix) with ESMTP id BC3E26B0010 for ; Mon, 18 Jun 2018 04:28:05 -0400 (EDT) Received: by mail-pf0-f198.google.com with SMTP id x25-v6so8296720pfn.21 for ; Mon, 18 Jun 2018 01:28:05 -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=+iEH687uAq6N2Wn3ANDiaFtC4p3fOve60p6nM4PWd00=; b=jIEsRsnAWTik24YpPQfTKMi2dMVXCEJl+EE39WWM5TXP0/NrbY7mHiSWYpRZSPLAo0 aFpCShi58ksJC0kmepdCRydxmHo/kwQ493anB6EZN/N3w4Siahtj4woASEnCMDoIt563 vqapPagd6q3LLWelLjztIp4ukk9zEtKzlJQkOetnE9iq3ufuUG7W6QXoqvrMV/vby7VO wwNfq0v/BhtxfQ1gE9L0kdOGIeTlMQJqqvPgSVqgdywzOE6a7d7eINEw8DA+VZGOH0B2 KE+UiwDeKGcfJtVkIGGjPMxx3uxNC0rRSyXnc5WeZji5LcUnv38CHj5rFn8jxQVa8ebL ylMw== 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/xf7s3tRskGhLux6kBd0mIopPOWonjRvdNkGkypOfyarYlqxA XKmqBV71ShcHgbXJ8ucWFkj4GkUjspldEYfRm1W76JqLz7jR/PZbmWkXAClX782ALpPI8jJrDR3 ckTD2APcbZ57ausaYBaLka7nW5iMAroClxFCen8zKDOZBRH+IeZ1Eb8LfLy0Hv2Yfxg== X-Received: by 2002:a65:494b:: with SMTP id q11-v6mr10392061pgs.105.1529310485437; Mon, 18 Jun 2018 01:28:05 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL/VeEgcdKtSTKnv4cogse+zZs/7rKuYBOfZePsfKdXuGMs6bCYr4JcHJ6GKVFKTCFFJU7L X-Received: by 2002:a65:494b:: with SMTP id q11-v6mr10392023pgs.105.1529310484582; Mon, 18 Jun 2018 01:28:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529310484; cv=none; d=google.com; s=arc-20160816; b=SctGJiimMAzFAqSxpKR2LmzxAoi1/OZvh6SUC1iDwEWzFxJHcz7dQGbO3OIs7vdSJO u/twY0hY29E/GYC0vtyxfnEf2bG1wqKZaOrBAGfE0VbBFR0j/dot/OpWJlOZ6dt7mKkQ 90L2Gt/GOqZQDByH16hEEVp0yY1c3K3H6uzUGaRh7fBcHo5Va7GWKKivvW2J5Dw4LJaL eirGZLlqUeFYlCXDqQdQZbT9mK5YC2cN8GwZRKkr3wAXQEgz8CJd/mCk40WzMiuJR4nI EdFxkIrTDZpkkm+6XaMRk242JCzGcBMmS9+/o6nJZ+7dRUvOzm/gR/iUcX5aI4m+VVlb EWuA== 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=+iEH687uAq6N2Wn3ANDiaFtC4p3fOve60p6nM4PWd00=; b=rZ5IliXNIyNB48LPle2hTbE6goSEd8f4isJFwxQ4U5OhhJdHm7fb8W6txu4Nx61Vqs 15Vetj8yBY5HwYyDzQOIJViOXJdup2ngjWMC1nQfyQN6bvkcxMW3TN6lzkBu8/EPZsJS K+m+zDmG+RPuMiQQ3gmTQy2qbod+Aul8W5xlaB3ER3wsYk5i/0f1G4u0/Hez3rREU7sj kpoSIPRHbCWRAgvSlP1GE5nvzpV3092Tdh75J2mOwK+Hcv7I3h08qcD8YTL0V+kOMoWr Rb0tn5uXnuMD7qBGTB/PGsqMo/0iUNvOYLISYj1gcDe/+qlwXMZnCKQhJk1SV9MsPy0V EK4w== 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 f21-v6si14803734pfh.33.2018.06.18.01.28.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Jun 2018 01:28:04 -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 C222DC94; Mon, 18 Jun 2018 08:28:03 +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 245/279] x86/pkeys/selftests: Fix pointer math Date: Mon, 18 Jun 2018 10:13:50 +0200 Message-Id: <20180618080618.910985893@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 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());