From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62967C433E0 for ; Tue, 12 Jan 2021 00:41:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 22D20224F9 for ; Tue, 12 Jan 2021 00:41:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391649AbhALAZN (ORCPT ); Mon, 11 Jan 2021 19:25:13 -0500 Received: from mx2.suse.de ([195.135.220.15]:35884 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404213AbhAKXw6 (ORCPT ); Mon, 11 Jan 2021 18:52:58 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 61B22AB7F; Mon, 11 Jan 2021 23:52:17 +0000 (UTC) To: Andy Lutomirski , Borislav Petkov Cc: "Chang S. Bae" , tdevries@suse.com, x86-ml , lkml References: <20210111200027.GH25645@zn.tnic> From: Tom de Vries Subject: Re: gdbserver + fsgsbase kaputt Message-ID: <0ad68c87-ac2e-478e-ed97-95256464a3ba@suse.de> Date: Tue, 12 Jan 2021 00:52:16 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/12/21 12:40 AM, Andy Lutomirski wrote: > On Mon, Jan 11, 2021 at 1:06 PM Andy Lutomirski wrote: >> >> >>> On Jan 11, 2021, at 12:00 PM, Borislav Petkov wrote: >>> >> >> >>> Or do you mean I should add "unsafe_fsgsbase" to grub cmdline and bisect >>> with fsgsbase enabled in all test kernels? >> >> Yes. But I can also look myself in a bit. >> > > Tom, if I reproduce it in an interactive gdb and play a bit, I get: > > Program received signal SIGSEGV, Segmentation fault. > 0xf7df2cb6 in init_cacheinfo () from target:/lib/libc.so.6 > (gdb) p $gs = $gs > $1 = 99 > (gdb) si > > Program terminated with signal SIGSEGV, Segmentation fault. > The program no longer exists. > > That's gdb itself crashing. Any idea what's wrong? > The first "Program received signal SIGSEGV, Segmentation fault" means that gdb intercepts the sigsegv, and allows you to inspect it f.i. by printing $_siginfo. The inferior is still live at this point. Then when trying to continue using si, the signal is passed on to the inferior, which means it'll be terminated. AFAIU, gdb has not crashed, and behaves as expected. See below for a similar scenario. Thanks, - Tom ... $ cat test2.c int main (void) { *((int *)0) = 0; return 0; } $ gcc test2.c $ ./a.out Segmentation fault (core dumped) $ gdb -q ./a.out Reading symbols from ./a.out... (gdb) r Starting program: /home/vries/a.out Program received signal SIGSEGV, Segmentation fault. 0x00000000004004a0 in main () (gdb) si Program terminated with signal SIGSEGV, Segmentation fault. The program no longer exists. (gdb) ...