Received: by 10.223.185.116 with SMTP id b49csp1028179wrg; Wed, 21 Feb 2018 10:49:57 -0800 (PST) X-Google-Smtp-Source: AH8x224xCzqleimpfaBw/xKaGdITOO+66d017lEBpRX9S1teDYfW0+iNSxlh9azrTgYhUiJjaII5 X-Received: by 10.99.142.76 with SMTP id k73mr3454697pge.278.1519238996951; Wed, 21 Feb 2018 10:49:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519238996; cv=none; d=google.com; s=arc-20160816; b=WSfjMJQjJ1ED/p3RRVKURaCPD5HZKPkztIlTqRKh2sjozBmhTGehPH07b4Mxama5qq 7YzsYgwo8buyG8kVvIbdhnSPFs4h1LCh5CS9Mle/fvSteFi8PpQm1remyqRBh12HcurA SnJlvhvutu+WcSKoyzxmqMcYOCJ9MT3kcOfawI6Sc0hcQC1ZIYqGOWEeplXkMGEkwYgU 3T9yvCKim1d/Q0f4YIIOZlFf4NWUn6joSEOvheRZTfdw52NwBl1zCCfBkljznLcV2FuL i7hTBx9Li0zNjRmLj7yJj71REPG0mrKwgxYZFh+fuofdb9YNkVmaj8ceSdVI93SI15aW z9Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=/8bgk6VdOZASwngdA2yRbKckVQqW7q4ajyOm1D3IyzY=; b=uXuninVn+e0Ttg2zmp0JBR/XOInV9bSsm3ux9lCVgCixW5wxFUaRfu5OF0WmGdnIp4 urLc2CEN+PYatVpGUVPAH6K1LmuqBVU0wxBP8u2Rn9STWaW97351ZKPOfe8rm7lhyaZq WhdCyxJOtcmv8W5mB+VvSaQkmlGFAZ8yb7CtTRRG8PA1MgFQl/NYa1wFjSJ1JEslCUgP FqxefF5371hWtr/vnARbtHuOhXWbXEYj7e3FaKqKldT8YzqEywDjJDKurpW6gSEOkeS7 xjelwg6tL782I6/Bg80nGdl1AlHFzBahy3lbXYXw7Iyjwwh8sNIHteXnvCWZ9xj3EG39 p5Eg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w4si1350294pgt.635.2018.02.21.10.49.43; Wed, 21 Feb 2018 10:49:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937329AbeBUOJj (ORCPT + 99 others); Wed, 21 Feb 2018 09:09:39 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:38648 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933040AbeBUNBt (ORCPT ); Wed, 21 Feb 2018 08:01:49 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 4035FC19; Wed, 21 Feb 2018 13:01:28 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rui Wang , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , dave.hansen@linux.intel.com, Ingo Molnar Subject: [PATCH 4.14 085/167] selftests/x86/mpx: Fix incorrect bounds with old _sigfault Date: Wed, 21 Feb 2018 13:48:16 +0100 Message-Id: <20180221124529.064601061@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180221124524.639039577@linuxfoundation.org> References: <20180221124524.639039577@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Rui Wang commit 961888b1d76d84efc66a8f5604b06ac12ac2f978 upstream. For distributions with old userspace header files, the _sigfault structure is different. mpx-mini-test fails with the following error: [root@Purley]# mpx-mini-test_64 tabletest XSAVE is supported by HW & OS XSAVE processor supported state mask: 0x2ff XSAVE OS supported state mask: 0x2ff BNDREGS: size: 64 user: 1 supervisor: 0 aligned: 0 BNDCSR: size: 64 user: 1 supervisor: 0 aligned: 0 starting mpx bounds table test ERROR: siginfo bounds do not match shadow bounds for register 0 Fix it by using the correct offset of _lower/_upper in _sigfault. RHEL needs this patch to work. Signed-off-by: Rui Wang Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: dave.hansen@linux.intel.com Fixes: e754aedc26ef ("x86/mpx, selftests: Add MPX self test") Link: http://lkml.kernel.org/r/1513586050-1641-1-git-send-email-rui.y.wang@intel.com Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- tools/testing/selftests/x86/mpx-mini-test.c | 32 ++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) --- a/tools/testing/selftests/x86/mpx-mini-test.c +++ b/tools/testing/selftests/x86/mpx-mini-test.c @@ -315,11 +315,39 @@ static inline void *__si_bounds_upper(si return si->si_upper; } #else + +/* + * This deals with old version of _sigfault in some distros: + * + +old _sigfault: + struct { + void *si_addr; + } _sigfault; + +new _sigfault: + struct { + void __user *_addr; + int _trapno; + short _addr_lsb; + union { + struct { + void __user *_lower; + void __user *_upper; + } _addr_bnd; + __u32 _pkey; + }; + } _sigfault; + * + */ + static inline void **__si_bounds_hack(siginfo_t *si) { void *sigfault = &si->_sifields._sigfault; void *end_sigfault = sigfault + sizeof(si->_sifields._sigfault); - void **__si_lower = end_sigfault; + int *trapno = (int*)end_sigfault; + /* skip _trapno and _addr_lsb */ + void **__si_lower = (void**)(trapno + 2); return __si_lower; } @@ -331,7 +359,7 @@ static inline void *__si_bounds_lower(si static inline void *__si_bounds_upper(siginfo_t *si) { - return (*__si_bounds_hack(si)) + sizeof(void *); + return *(__si_bounds_hack(si) + 1); } #endif