Received: by 10.223.185.116 with SMTP id b49csp1023989wrg; Wed, 21 Feb 2018 10:45:08 -0800 (PST) X-Google-Smtp-Source: AH8x2246bBqgcPlK9rClW7Fac8v3/S+vDXpODo+AklvfMYM63B94cJEHE7pzxWyVnAuKH5cx9enl X-Received: by 10.101.71.202 with SMTP id f10mr3395817pgs.91.1519238708783; Wed, 21 Feb 2018 10:45:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519238708; cv=none; d=google.com; s=arc-20160816; b=JH338I2CmagjUoUD7sRF+cQeH6JIQtL2Skf2oQOAfFAcNowTLUVIkIeCug2YHFUJk5 ehvnBGPm3p2BrqE3803Q7NpXe6yAqUPc4rKNA2+4UypB4wR7hNKxlna1XW6UcZc9E9eF jESu/AVjn/NIImXjIXFNQSuMAc0D4g7uv9v0G7+f3Gd1GIIu2GJUBqtJRTzftG+bBhJT pFuuPPIur4tsnJ33II0cI6r3su9SGL1HBNzyCwo4nfWxnFDfeOwIcHwsb3otXHwEp6pW c+z3zKfWYHRZbUImYlKPxD/1DFxrmXS7G33MK1KQT512DSA0eGPaBKWm8XEBh/ADCa+S cQ2w== 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=fhyX205zNX6orm9c9M1eZGGaKeV1ukebj2eD2JP5Rxs=; b=nhg+c1RWPhVesWE9zSYjMkwE8HYTjLlW4G5zPER+CxAIqqgrIIpCrgEwEA8pPPwqYk imjT2z/M0aCKDQ3nULCnSTF2dyTzp7slBvezyAB6tUxbn6uAMDovqIkKaPVTniWakrL3 Bj+zQVMZsq9nPeFRC1Knx3712o+BENjrtnWFbTSLOYnULMTSnY5qJrsnmbLgY2Zvy4rQ 8nFQvxeEWpvTMiydYzZ0mkt4bKC+slybjVtnVcHl5tGkZMt2Va2u6pBq9d64D+VeYacl WWQ0LrmtL/v0UhFVB36S4FUMrKjwZLrIfyMOm+eXEQFahXauPxhxXUfwF/Ng6RDbOYXT KrUw== 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 b65si7021293pgc.70.2018.02.21.10.44.54; Wed, 21 Feb 2018 10:45:08 -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 S936930AbeBUNfe (ORCPT + 99 others); Wed, 21 Feb 2018 08:35:34 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:42918 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965406AbeBUNJV (ORCPT ); Wed, 21 Feb 2018 08:09:21 -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 5069C11DA; Wed, 21 Feb 2018 13:09:20 +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.15 083/163] selftests/x86/mpx: Fix incorrect bounds with old _sigfault Date: Wed, 21 Feb 2018 13:48:32 +0100 Message-Id: <20180221124535.007730540@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180221124529.931834518@linuxfoundation.org> References: <20180221124529.931834518@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.15-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