Received: by 10.223.185.116 with SMTP id b49csp1031257wrg; Wed, 21 Feb 2018 10:53:10 -0800 (PST) X-Google-Smtp-Source: AH8x2254+sncJsIjLd09omZfNe/tFpq30cPAZ7KpzL3ZBi9hoe8GmQedgU3qmt7cldsBgkQgbkg7 X-Received: by 10.101.101.84 with SMTP id a20mr3497882pgw.163.1519239189952; Wed, 21 Feb 2018 10:53:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519239189; cv=none; d=google.com; s=arc-20160816; b=Pn8KpK4/nsiy9PdzouZvy+p34luqD7EXk6xXyIp8Na3vaoXyqz7pdOz+4T9dntQaO8 luE3KKqiGvHVmZs8QEY97o7yBhqxzK81KLw8bY/47lC+y3kk3oZ2MGUZE/YPgR66fqNh 99HTwvrHmDYb+53wtSo0rz1p0Zrwmwy9C4+eVXF9vr2w9NofDiVi18jfTeUtXLRwn+n2 s6SC+2hTaoLH0y92xEsHPZNf62N52q1PSdKkz9eR5i2hVFxCvzw1pqdrRd76DHnY9d46 2fIT3V712ufIkybUBo0/L+boTbImYBVZiSS72Tv4N+Y2Q495m/dLVC0LGGSc/Pyf8Ayj RoAw== 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=wOV7net1OsVCIEkGpcMtx8y3j7Ml9Z6s7pUIUSpVo04=; b=KtrhUS9tqEqUX/GsMFJ8OyT2ITYxJFcBI80hw9TXXB6Ph7pQCdMhXQCzgT47uvMxs5 3Xx5G3dugWX/gdIroZ5snJjYM1VGesRfdQ/hI5vo1c0Z1y1V+sG5X6/s9lS7bqECHX7e J8EPzYzO2oMlp/KQZDz9jUhZlFC0R92w+Lf8DlgIicmx13QkHb7VHN29giY7aniX4QdI olYS7GTzG1PC5OCN1Q4Yr5fVriRp10Wpvv1XFVfNjtwsA1pPT3iiw/MGGVnQQtNFmuHj JRnY7W6GIvuO7EJiU7Df/JbvCQ5l/XYUdYpcnMR6OFeQ17SROMrSPHRGIkujxQsiyjyf hR4A== 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 k198si2127602pgc.299.2018.02.21.10.52.55; Wed, 21 Feb 2018 10:53:09 -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 S934775AbeBUO3R (ORCPT + 99 others); Wed, 21 Feb 2018 09:29:17 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:35534 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934519AbeBUM4r (ORCPT ); Wed, 21 Feb 2018 07:56:47 -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 9A850F32; Wed, 21 Feb 2018 12:56:46 +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.9 63/77] selftests/x86/mpx: Fix incorrect bounds with old _sigfault Date: Wed, 21 Feb 2018 13:49:12 +0100 Message-Id: <20180221124434.872265094@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180221124432.172390020@linuxfoundation.org> References: <20180221124432.172390020@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.9-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