Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3942951imm; Mon, 8 Oct 2018 12:04:25 -0700 (PDT) X-Google-Smtp-Source: ACcGV62KlSg8agB1vaBPg/e3qF7ed+EiVlvv7eJm+AWMKjAlvveUkF9mDdhyTpTr2N4vS1y60fPT X-Received: by 2002:a63:8543:: with SMTP id u64-v6mr13324903pgd.373.1539025465536; Mon, 08 Oct 2018 12:04:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539025465; cv=none; d=google.com; s=arc-20160816; b=P/fC0EP4vsoVrPs1CMAUjt/PiPRdFLc5f4+qUd2v+MI4iLhJLEi6URz5N6RwydjVoX s7qnoOMjHVzeJAks9nPK6aF4MqMH0KsDq+SpJLYwdSZhvY89lPYqcBaMU7vX2ntL53Nu rM5bTiV47MdWA99v2IuZSaHOS921bl8MkxhJ3UBo+ikUKz+Tg0k612HCnNT+XyafnyiS 4KEkfqDCe5xjpsXa7q/s2qy2pUuRv3MoRlihJWjv5dTKHWaUsDHMuQa2KOY/ZpPf5tfp X3/S1e/DfaqT5DEAob9vnNRIb46k4rb3FHuh0lMKeUgjzO0mheOnDqPenR/+BzoSJNP8 Srhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vIZDUvhIosOc6YoBA5GfhFcUX3leZCuamC5L/ZkLBNQ=; b=FvX39HZH2VFpS/J5f+A8qCRVCh0V9DqWCZnGoAUl2Fk62K/LTWQ0yBcMILAt8V4fDO yINcfzqtk9+YfG5uof7YSQDaHi3i0fbAjCFxP8R+9Zc2lxorPlZqfBH/mnaMKMBcct7i A3xe0UtWRrn8Mz2Nens5Shw1SKDLWCfZoFPFxO9xPyWfKLVrY9dlSd1OUQA7ZMrINzPp MNsX/gzSq4MzMidUJflItBpiPKDe9IWUFizIhkdZUGqM306B18q5newBi0M+fk7Ad8at EJvwtxYbZcCMbZHyGQwASdr0lgFPLEH/NCkGaXR5BpqDQu53CvxwF59uZREz8WmChZof sQFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HablBo4s; 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 j6-v6si18269416plk.145.2018.10.08.12.04.09; Mon, 08 Oct 2018 12:04:25 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=HablBo4s; 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 S1731053AbeJIB6s (ORCPT + 99 others); Mon, 8 Oct 2018 21:58:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:46912 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728570AbeJIB6r (ORCPT ); Mon, 8 Oct 2018 21:58:47 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B5F892064A; Mon, 8 Oct 2018 18:45:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539024341; bh=4OsRXEhzVZN1STz+wYgU8HzMCkdRqr6QQW7bmIonO24=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HablBo4sh/vnprSIWEIRq36yf9gyu86XlCOuCmfhMaUZQXXfdgTOKSZg8JYeDQ0xi L3RAy+JoHTknUfmDbFeo59CSTV98ec07aWpMU1i+9yTFez5/bsDe1Mcbq4VpMS7D+t FXROU+fVIyMc+0t0uPEkse5tA2hMirp7nx1n6sAs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mathieu Desnoyers , "Paul E . McKenney" , Shuah Khan , Thomas Gleixner , Joel Fernandes , Peter Zijlstra , Catalin Marinas , Dave Watson , Will Deacon , Andi Kleen , linux-kselftest@vger.kernel.org, "H . Peter Anvin" , Chris Lameter , Russell King , Michael Kerrisk , Paul Turner , Boqun Feng , Josh Triplett , Steven Rostedt , Ben Maurer , Andy Lutomirski , Andrew Morton , Linus Torvalds Subject: [PATCH 4.18 001/168] rseq/selftests: fix parametrized test with -fpie Date: Mon, 8 Oct 2018 20:29:41 +0200 Message-Id: <20181008175620.096912313@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181008175620.043587728@linuxfoundation.org> References: <20181008175620.043587728@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mathieu Desnoyers commit ce01a1575f45bf319e374592656441021a7f5823 upstream. On x86-64, the parametrized selftest code for rseq crashes with a segmentation fault when compiled with -fpie. This happens when the param_test binary is loaded at an address beyond 32-bit on x86-64. The issue is caused by use of a 32-bit register to hold the address of the loop counter variable. Fix this by using a 64-bit register to calculate the address of the loop counter variables as an offset from rip. Signed-off-by: Mathieu Desnoyers Acked-by: "Paul E . McKenney" Cc: # v4.18 Cc: Shuah Khan Cc: Thomas Gleixner Cc: Joel Fernandes Cc: Peter Zijlstra Cc: Catalin Marinas Cc: Dave Watson Cc: Will Deacon Cc: Andi Kleen Cc: linux-kselftest@vger.kernel.org Cc: "H . Peter Anvin" Cc: Chris Lameter Cc: Russell King Cc: Michael Kerrisk Cc: "Paul E . McKenney" Cc: Paul Turner Cc: Boqun Feng Cc: Josh Triplett Cc: Steven Rostedt Cc: Ben Maurer Cc: Andy Lutomirski Cc: Andrew Morton Cc: Linus Torvalds Signed-off-by: Shuah Khan (Samsung OSG) Signed-off-by: Greg Kroah-Hartman --- tools/testing/selftests/rseq/param_test.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) --- a/tools/testing/selftests/rseq/param_test.c +++ b/tools/testing/selftests/rseq/param_test.c @@ -56,15 +56,13 @@ unsigned int yield_mod_cnt, nr_abort; printf(fmt, ## __VA_ARGS__); \ } while (0) -#if defined(__x86_64__) || defined(__i386__) +#ifdef __i386__ #define INJECT_ASM_REG "eax" #define RSEQ_INJECT_CLOBBER \ , INJECT_ASM_REG -#ifdef __i386__ - #define RSEQ_INJECT_ASM(n) \ "mov asm_loop_cnt_" #n ", %%" INJECT_ASM_REG "\n\t" \ "test %%" INJECT_ASM_REG ",%%" INJECT_ASM_REG "\n\t" \ @@ -76,9 +74,16 @@ unsigned int yield_mod_cnt, nr_abort; #elif defined(__x86_64__) +#define INJECT_ASM_REG_P "rax" +#define INJECT_ASM_REG "eax" + +#define RSEQ_INJECT_CLOBBER \ + , INJECT_ASM_REG_P \ + , INJECT_ASM_REG + #define RSEQ_INJECT_ASM(n) \ - "lea asm_loop_cnt_" #n "(%%rip), %%" INJECT_ASM_REG "\n\t" \ - "mov (%%" INJECT_ASM_REG "), %%" INJECT_ASM_REG "\n\t" \ + "lea asm_loop_cnt_" #n "(%%rip), %%" INJECT_ASM_REG_P "\n\t" \ + "mov (%%" INJECT_ASM_REG_P "), %%" INJECT_ASM_REG "\n\t" \ "test %%" INJECT_ASM_REG ",%%" INJECT_ASM_REG "\n\t" \ "jz 333f\n\t" \ "222:\n\t" \ @@ -86,10 +91,6 @@ unsigned int yield_mod_cnt, nr_abort; "jnz 222b\n\t" \ "333:\n\t" -#else -#error "Unsupported architecture" -#endif - #elif defined(__ARMEL__) #define RSEQ_INJECT_INPUT \