Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1355117ybt; Thu, 18 Jun 2020 06:53:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwET4rHSLb+N+OCOj8OCMjdl0Frv7divTQO/b7Oj8K2pB06p00MhjEQOGRxWWzDlln3nu1U X-Received: by 2002:a17:907:9495:: with SMTP id dm21mr3966947ejc.357.1592488433188; Thu, 18 Jun 2020 06:53:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592488433; cv=none; d=google.com; s=arc-20160816; b=MmPBOrTfTnM/uc9F3FlvsQsHQOgWRqQbZVwDmV30d5z5pQITzEnXeFVuzaCkMliK8c pXuG5V/ynA5ed9FW4EQ/jdnQ3JWlFSgVYP0RYSuYMaImoK4tLfbbAryWLI83c0DWx3Vr yQGA50pdsFkm872NfVBeXeFI3PeLXjqzaamHGlgpyJN92n4RfMRVQ6z3/SQUnO/0V+Rl jO6wt1xJlJVM9qJ3MEP0RU96zCX+OWeZZA9Q3qoniM/M/2c5U1j5ZAf6ddDJhSp3VrDj zGiQN68EFCqz49JMapQt1EvTyINb4LVvugLwoOyuwW2jk7Swy7NR6P+RFmsXAzTBx2i+ RIdQ== 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 :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=UVcf2TVYSQOCBuqL2aVketV3WTsQtvlpFho8Enh1jhA=; b=UKVDtFCYGLnczMqlmITg6flImMy46/v/W6IWNuA4DHBbbj7X5YQilgdyD4d0x2SyaB SH2pVI7veG9o1NRd+OegdacIS9n1ZfSR9dsE+3wYi11es0JF78Q9tcvZ1WqftpA1I+Ga CyYkPYvnbU6VvumEtGShX6YvlynQyyUbIRTNP5Fhe7BRhDq8zt0R5FYxa2zKf8iokpEU P6XsiRLjkz2mssuyTc0qvTIEmKh9eGNSAl6cgONiJxx55UusWImDIcHg3v0Uu3VZSFoD yTfPqafKa2CNTtKvAUVFe2Pg2JSLt6Eg/cHtQH/aYCKPSgnv0vuCtnIYp7y8jEye1jwZ msTw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oy15si1863818ejb.538.2020.06.18.06.53.30; Thu, 18 Jun 2020 06:53:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730619AbgFRNvV (ORCPT + 99 others); Thu, 18 Jun 2020 09:51:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730566AbgFRNvG (ORCPT ); Thu, 18 Jun 2020 09:51:06 -0400 Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 726F5C0613ED; Thu, 18 Jun 2020 06:51:06 -0700 (PDT) Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jluwR-0002iZ-Up; Thu, 18 Jun 2020 15:50:56 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 3C11D1C0087; Thu, 18 Jun 2020 15:50:55 +0200 (CEST) Date: Thu, 18 Jun 2020 13:50:54 -0000 From: "tip-bot2 for Chang S. Bae" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/fsgsbase] selftests/x86/fsgsbase: Test ptracer-induced GS base write with FSGSBASE Cc: Andy Lutomirski , "Chang S. Bae" , Sasha Levin , Thomas Gleixner , Tony Luck , x86 , LKML In-Reply-To: <20200528201402.1708239-17-sashal@kernel.org> References: <20200528201402.1708239-17-sashal@kernel.org> MIME-Version: 1.0 Message-ID: <159248825497.16989.5412219618320805456.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/fsgsbase branch of tip: Commit-ID: 5e7ec8578fa3dada50c50f5b234fa8d154b76349 Gitweb: https://git.kernel.org/tip/5e7ec8578fa3dada50c50f5b234fa8d154b76349 Author: Chang S. Bae AuthorDate: Thu, 28 May 2020 16:14:02 -04:00 Committer: Thomas Gleixner CommitterDate: Thu, 18 Jun 2020 15:47:07 +02:00 selftests/x86/fsgsbase: Test ptracer-induced GS base write with FSGSBASE This validates that GS selector and base are independently preserved in ptrace commands. Suggested-by: Andy Lutomirski Signed-off-by: Chang S. Bae Signed-off-by: Sasha Levin Signed-off-by: Thomas Gleixner Reviewed-by: Tony Luck Link: https://lkml.kernel.org/r/20200528201402.1708239-17-sashal@kernel.org --- tools/testing/selftests/x86/fsgsbase.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/x86/fsgsbase.c b/tools/testing/selftests/x86/fsgsbase.c index 950a48b..9a43498 100644 --- a/tools/testing/selftests/x86/fsgsbase.c +++ b/tools/testing/selftests/x86/fsgsbase.c @@ -465,7 +465,7 @@ static void test_ptrace_write_gsbase(void) wait(&status); if (WSTOPSIG(status) == SIGTRAP) { - unsigned long gs; + unsigned long gs, base; unsigned long gs_offset = USER_REGS_OFFSET(gs); unsigned long base_offset = USER_REGS_OFFSET(gs_base); @@ -481,6 +481,7 @@ static void test_ptrace_write_gsbase(void) err(1, "PTRACE_POKEUSER"); gs = ptrace(PTRACE_PEEKUSER, child, gs_offset, NULL); + base = ptrace(PTRACE_PEEKUSER, child, base_offset, NULL); /* * In a non-FSGSBASE system, the nonzero selector will load @@ -501,8 +502,14 @@ static void test_ptrace_write_gsbase(void) */ if (gs == 0) printf("\tNote: this is expected behavior on older kernels.\n"); + } else if (have_fsgsbase && (base != 0xFF)) { + nerrs++; + printf("[FAIL]\tGSBASE changed to %lx\n", base); } else { - printf("[OK]\tGS remained 0x%hx\n", *shared_scratch); + printf("[OK]\tGS remained 0x%hx", *shared_scratch); + if (have_fsgsbase) + printf(" and GSBASE changed to 0xFF"); + printf("\n"); } }