Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp29589955rwd; Wed, 5 Jul 2023 14:21:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlEH0Elnq6f2wtf87O7dcyhDrHfEwORkHn0Lt+CmCKQ5S1beefwV8GMytRRFRRtHYh0KkLQY X-Received: by 2002:a17:90b:1e0f:b0:263:e804:3988 with SMTP id pg15-20020a17090b1e0f00b00263e8043988mr15039pjb.1.1688592098947; Wed, 05 Jul 2023 14:21:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688592098; cv=none; d=google.com; s=arc-20160816; b=lHLy+UL2WGUh4kO76E36ROtCcmifAbyawIge5y8v2yD/8fB/dzKl5UJhyDEWh8F0na lIK9qUR58I3RLi4skIAvRsyTR/nphUSWBC5kuSFKVVetfSA7xmElUXxcNwWybfejSuCG eqEwl0RkNKFH2gCsPCR8Gr83w4p5jIdV4453R0YLT4qw5c1bW8iCJbqlWZrSmFjGk0lW MmUTUP0jxxth3AXAOX5djoXU8IojtaQqm6Vsmc7dy/XvJkI4knLlJHNpyQxwn4T/ccVL zWFA1VDfrgTkz9NbtUuuXMU9iNYDskWmkPJdTo47lapnH+DC1BP1sCWidWcEMD7CWuqk RP2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Ug73FggPnbwdd1VaI/h85Jqlh9rWzsohKtgG2/gb7Z0=; fh=EKXLADng+TKYerH5OEYf2EhloNl840mIXFCWGw+g/KE=; b=w1qDr67pv5m7cQ8GVzbVysXTPRLfVQGLuInkqvUGp61VIh9Z7e/exC5Rp47gDpOmew 61YP9xgC8t4H3YZ9NpYmKwUeGNo7/IYoYrAqWYbY4LIwtmS8O/zzJpmhQNSxL9Z6iRD8 4p0+wGgzu6agQXBwookioCIQqM9V/OxCbP0dCp62ducauV2/in8SnVk23scfjekT5zD3 8xxd/0qj7lEUj+gtwwhm6DNm7VNrLf4r+htv3Tq47cf/37r+mKYyQDDhVDoaJx1GLBJ3 Igr24/LpGUTX5xdzHJVlUy8hGNLFDNzJo0tGizsT+tmZTPnIvEfXCr3M/0A0u1dvJBTA ab3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=IFNOV4ZE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hi7-20020a17090b30c700b00260d0644358si2308372pjb.187.2023.07.05.14.21.24; Wed, 05 Jul 2023 14:21:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=IFNOV4ZE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231700AbjGEVIP (ORCPT + 99 others); Wed, 5 Jul 2023 17:08:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229532AbjGEVIO (ORCPT ); Wed, 5 Jul 2023 17:08:14 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4846819A0 for ; Wed, 5 Jul 2023 14:08:13 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-263036d54b9so86108a91.0 for ; Wed, 05 Jul 2023 14:08:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1688591293; x=1691183293; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=Ug73FggPnbwdd1VaI/h85Jqlh9rWzsohKtgG2/gb7Z0=; b=IFNOV4ZEPbH0J7ufVwembvtKuwugzRGT0taaw/ZrLwCiQHr92VrBulxkGJ4TK/gd83 zPM5qvFSxmaP/2MudSKJG+aGnlR0QuiW97FKCvzeSmLETNIJJkE65jMJPTuJu/pTJaTE iXAqFJoBzZZrjQbyBFsPvGz7xeSpFZtnBx4ms= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688591293; x=1691183293; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Ug73FggPnbwdd1VaI/h85Jqlh9rWzsohKtgG2/gb7Z0=; b=NUg8bcrdhd99cgMkpu1vb2dGOc+8WzAHOjC6lqQaeEdGF9zD8i/ZTsQWmRKtfDT/QZ zWQ+qpGgClwKOJwIQSZGjw4ehcb+gSeg7tqP2t1bnZTz1dUpL/8DoQEN3t4+XVg7XF46 bN9PnCFXGvYFFl7nHtdBvbeAiKG5qC++yVNZn3yVYR7Aqmdsu+JlSWQ5DPkK41bOY20S +WZXzyQqN7Egpe63Pj/YiwxpPQ/2Nc/J7JNFY6BhclMkWzzsTrNbtsmielxP21UjXI62 kCgEcxXV4bkTpCCdu8CyEFW4wC0Sk0vfNlK0ps08L/w3tRxPQl+96uUcXh8AQ8iYNKcQ 0N/w== X-Gm-Message-State: ABy/qLYkjDC6hbJkyRVBTuW3mYZ7mkDddBn+XeeYP0a8gXemevbemo73 MTPzkrrcKOA0uhYGYuee1sIT9GkL39kg2Kry/ow= X-Received: by 2002:a17:90a:358:b0:263:e804:3988 with SMTP id 24-20020a17090a035800b00263e8043988mr5089443pjf.1.1688591292720; Wed, 05 Jul 2023 14:08:12 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id cx3-20020a17090afd8300b00263987a50fcsm1815914pjb.22.2023.07.05.14.08.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 14:08:11 -0700 (PDT) Date: Wed, 5 Jul 2023 14:08:09 -0700 From: Kees Cook To: Jann Horn Cc: Kees Cook , Linux Kernel Mailing List , Linux LLVM , the arch/x86 maintainers Subject: Re: CONFIG_UBSAN_TRAP #UD error message on x86 [was: Re: [CRASH][BISECTED] 6.4.1 crash in boot] Message-ID: <202307051405.E746464@keescook> References: <2b1a4f49-ba18-0246-af09-4e4133814411@alu.unizg.hr> <202307022230.6121D6896@keescook> <202307031149.823F9A3@keescook> <202307031606.3FD9D0D@keescook> <3CDD1188-7B2A-4D53-9B8F-C07BC39844E9@kernel.org> <19d0e63c-db47-8f02-2f79-0923f675898c@alu.unizg.hr> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 05, 2023 at 05:16:36PM +0200, Jann Horn wrote: > On Wed, Jul 5, 2023 at 4:10 AM Kees Cook wrote: > > On July 4, 2023 4:15:20 PM PDT, Mirsad Todorovac wrote: > > >On 7/4/23 23:36, Kees Cook wrote: > > >> On July 4, 2023 10:20:11 AM PDT, Mirsad Todorovac wrote: > > >>> all Wayland and X11.org GUI applications fail to start, with errors like this one: > > >>> > > >>> Jul 4 19:09:07 defiant kernel: [ 40.529719] invalid opcode: 0000 [#1] PREEMPT SMP NOPTI > > >> > > >> Hmm, is CONFIG_UBSAN_TRAP set? > > > > > >marvin@defiant:~/linux/kernel/linux_torvalds$ grep CONFIG_UBSAN_TRAP .config > > >CONFIG_UBSAN_TRAP=y > > > > Ah-ha! Turn that off please. With it off you will get much more useful reports from USBAN. > > It might be useful if the x86 code under handle_invalid_op() at least > printed a warning about this when the kernel crashes with #UD on a > system with CONFIG_UBSAN_TRAP=y? It seems pretty unintuitive and > unhelpful that the kernel just crashes itself with a #UD and no > further information in this configuration. > > Even just a "WARNING: CONFIG_UBSAN_TRAP active, #UD might be caused by > that" on every #UD that does not come from a known BUG() location or > such might be better than nothing... I've considered it, but usually CONFIG_UBSAN_TRAP isn't accidentally set. Also, the crash info is something we can get help from on the compiler side, to mark up where the traps are, similar to what we do with KCFI, but it hasn't happened yet for x86. For example, arm64 already encodes the details in the trap instruction itself: https://git.kernel.org/linus/25b84002afb9dc9a91a7ea67166879c13ad82422 > And maybe the Kconfig help text could be clearer on this, too. > Currently it does say that this turns warnings into "full exceptions > that abort the running kernel code" but it does not say that the > exception reporting will become pretty unhelpful, so it's probably not > really what you'd want for debugging. Yeah, that's a reasonable change to make. Can you send a patch for this? I can carry it. Thanks! -- Kees Cook