Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6014059ybc; Wed, 27 Nov 2019 13:24:37 -0800 (PST) X-Google-Smtp-Source: APXvYqxLSu3QKRy3J6WRYuZ2vUQQE7VZzM8A8aUL/ZZ9wyZR7IckBEx7KGgi6rGkL5Yb1hCzzGif X-Received: by 2002:a17:906:b253:: with SMTP id ce19mr25232647ejb.61.1574889877544; Wed, 27 Nov 2019 13:24:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574889877; cv=none; d=google.com; s=arc-20160816; b=F1fvML8mIneAiRyhkD6PFjjU3OIfLfGqhJV8VQoyS6jqXpLuDaqdZbXqkvXqy/ljyq jqOGCQ46c4EWg1e3b6mGYBK9XoIk69c+uy52HtWgD1HqFyElekH71NLpGZsBqMq/X3J4 d7iH327Xmug7cAw1I0Kt0ZKF1hGUIgQQcKMVzQb9XzbuyyTaBZDzh4DHIhMpN1lWxWrI Y4eS0zkTN8DYFShh3i2QbKWzLNPVZkBMf6Ev5C3kXf1xVj2xSNbgWzFpdJnpxjGpMLPW Laae1B2pQKo8DoYfSLmPfPhh7E+VpwzXbXv1MXSE4qyJRuXpvD1ddg1MBCGrEiV+PU7L rc4g== 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=7Zh6TZRMtWmYF25w9qBSfwtsQAhOKSTwPIPro1jH3eI=; b=EoM64ND87l8rMvl8G1xHB3aCmLEVuSDGDOxQOz/bMv6hIGdjLtoN2y2xmzvv0C+owP 4Ht0+93hbKyVWs7g3ud60f3CmYcOZedkl7JWrhDTZwMST2HMzEwkeyH8jWGVOL0PXlj7 FRRi0pPBgQFPXk+wx8c+B3QxR0kUdlaskRVDzLfpnTdqSkbDczIucyBXv1JJEqYcd/Cp NipbyfS6P5mufkUK/g/DrixoSuhE+HzfvExNiw1hsxXmqpxX4cdLDXJeqojOYqFo4SsG j1/VIiLBhCr3sz9JQpouNAOrsOsblc5p0tapNpslJ95HpQjPONHCc+hUINBeJRB6X1Ai V+Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pGcB67N9; 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 b12si3556095edy.63.2019.11.27.13.24.14; Wed, 27 Nov 2019 13:24:37 -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; dkim=pass header.i=@kernel.org header.s=default header.b=pGcB67N9; 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 S1732498AbfK0VGu (ORCPT + 99 others); Wed, 27 Nov 2019 16:06:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:60972 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732481AbfK0VGp (ORCPT ); Wed, 27 Nov 2019 16:06:45 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 5AA43215F2; Wed, 27 Nov 2019 21:06:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888804; bh=eaBjrtbhJ62pLWppLNZsKpx+Q5x1JcT00JxRyiiPxLQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pGcB67N9WWrB0p24er6ubVEYl1jppP+/PxxrHK///nEnPRCCDRtogNfRf8DyTtIv9 u9RrrFVgd26vVj6ISe97ptM4pNDeXC+HUIxDKQiTwLn3xpSEFGnnw2T+Fcy376512h 2BiGm/zAPiifM0d2KSQznaY1BaBwKlSW49En0Jac= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andy Lutomirski , "Peter Zijlstra (Intel)" , stable@kernel.org Subject: [PATCH 4.19 274/306] selftests/x86/mov_ss_trap: Fix the SYSENTER test Date: Wed, 27 Nov 2019 21:32:04 +0100 Message-Id: <20191127203134.829308234@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Andy Lutomirski commit 8caa016bfc129f2c925d52da43022171d1d1de91 upstream. For reasons that I haven't quite fully diagnosed, running mov_ss_trap_32 on a 32-bit kernel results in an infinite loop in userspace. This appears to be because the hacky SYSENTER test doesn't segfault as desired; instead it corrupts the program state such that it infinite loops. Fix it by explicitly clearing EBP before doing SYSENTER. This will give a more reliable segfault. Fixes: 59c2a7226fc5 ("x86/selftests: Add mov_to_ss test") Signed-off-by: Andy Lutomirski Signed-off-by: Peter Zijlstra (Intel) Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman --- tools/testing/selftests/x86/mov_ss_trap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/tools/testing/selftests/x86/mov_ss_trap.c +++ b/tools/testing/selftests/x86/mov_ss_trap.c @@ -257,7 +257,8 @@ int main() err(1, "sigaltstack"); sethandler(SIGSEGV, handle_and_longjmp, SA_RESETHAND | SA_ONSTACK); nr = SYS_getpid; - asm volatile ("mov %[ss], %%ss; SYSENTER" : "+a" (nr) + /* Clear EBP first to make sure we segfault cleanly. */ + asm volatile ("xorl %%ebp, %%ebp; mov %[ss], %%ss; SYSENTER" : "+a" (nr) : [ss] "m" (ss) : "flags", "rcx" #ifdef __x86_64__ , "r11"