Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp29610247rwd; Wed, 5 Jul 2023 14:44:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlGiirElYvWVTPPswHb5SI+HoOUMVhI9yWqGwJGJrBXKe7DANtJjI0VkWWgbk4KW1OjblEeB X-Received: by 2002:a17:903:249:b0:1b5:642e:139d with SMTP id j9-20020a170903024900b001b5642e139dmr249248plh.10.1688593460125; Wed, 05 Jul 2023 14:44:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688593460; cv=none; d=google.com; s=arc-20160816; b=i+H0m5CxICUcJ0IzTEHgw9xyu3IzSomR0YmiD2UbQka2GxZ+/XsHx66D7EeLmV0C71 P2n9Hm85JQ+BrH/GAi7X5kXnRnr5cUIu11ZRUgIU886x+lDHWmpCSrliBFjyhYTlOdnX ZLEjqedmB8yPimrj/xeInKEVKVXFx0JRitL+ICuN/a4gEdH0qpruiF+/ivor03XjteH0 i9CBUtON35GIEOFCPKim/Pop3bUuRsflZforK5KaIZbak/q3VhZYjMZl5tl5PM152h7u 0NwoMYDW+CpY9krV14FMR+fDn5H7yjgPNvdywF3NEiJ7EOpJ3cusGK+io7chEdxpAjlh hl0g== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=4aSLSjsOXrHcGMVuRFn80IJVcHXwZzbRbgGO/RYsbxU=; fh=PzL0GIJJtX6ysb0FzRnyThD75NYPImMIuYQ1E7BC1yY=; b=gGZrwdhRaynRrbN3dR1bcCzm6YL4yVmZcA5rJ80YaFYiXUonHTR5jib3pXw5R0wb1f YwF4AhMkElNI/Cagl4T1bwQciQzKt9O3LWc84HzTsvAB5jRuaTPjVIpeJiYEngDqkJKK CVV1vbSlRvhwQi91UraFCnro8MEkVAazr3kPYrXuqHWHmJlsYdt9eW+oE+gQI7MlAlws yn1uzNGLTNGqL76S/W9YnkZDBj2XyBe01bC8U53K9ezvZIZeEu38bPdSolnQqo785wbZ QT/a6THu8SALGqT1k1QcNCBfKsuAne0MRkj7VlxG33eDaRzQzoJgz6/t81mcbn0PTgpw iyqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=ShVGdSCi; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c6-20020a170902d48600b001b8b386ae30si1944046plg.335.2023.07.05.14.44.08; Wed, 05 Jul 2023 14:44:20 -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=@infradead.org header.s=desiato.20200630 header.b=ShVGdSCi; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232382AbjGEVcb (ORCPT + 99 others); Wed, 5 Jul 2023 17:32:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232329AbjGEVcN (ORCPT ); Wed, 5 Jul 2023 17:32:13 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2240D1BCB for ; Wed, 5 Jul 2023 14:31:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=4aSLSjsOXrHcGMVuRFn80IJVcHXwZzbRbgGO/RYsbxU=; b=ShVGdSCi88bb3fTZeS6G24qea1 jZXdz0tmD8xVt0TLa54/4BY41sBr8C0fvw4aMSbp/kb+VLCvjOztii4OZ4qQKgH1z8ehAvOhSlOoS j1YuGkRQZ+lEU90rH1DFsrmhPAjLddGZ1HsspR/iE0xAruY2zrgThko0SlBkMstCxOf2W0Etikyio rGMTOJITT+eSc8qUHi6mrNfL/LFK/swqFo5yMIhTG62Mdx/GTsYvcKgJVjlGllpF7yiiJTZTziFsG iKeLrSQJT2j43LwilfSPta9IVNC7h0aUd0dd7JQKd0I0SCw5EuKdukZ2mTbhai9NYOYv37vED+3CP IgIij5RA==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qHA5i-00CGI9-28; Wed, 05 Jul 2023 21:31:15 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 6E8D030005E; Wed, 5 Jul 2023 23:31:13 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 545712007F0C7; Wed, 5 Jul 2023 23:31:13 +0200 (CEST) Date: Wed, 5 Jul 2023 23:31:13 +0200 From: Peter Zijlstra To: Kees Cook Cc: Jann Horn , 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: <20230705213113.GC2813335@hirez.programming.kicks-ass.net> References: <202307022230.6121D6896@keescook> <202307031149.823F9A3@keescook> <202307031606.3FD9D0D@keescook> <3CDD1188-7B2A-4D53-9B8F-C07BC39844E9@kernel.org> <19d0e63c-db47-8f02-2f79-0923f675898c@alu.unizg.hr> <202307051405.E746464@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202307051405.E746464@keescook> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,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 02:08:09PM -0700, Kees Cook wrote: > > 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 Right, so you could easily use a different #UD instruction that has an immediate, something like: 0f b9 40 ff ud1 -0x1(%rax),%rax or even: 0f b9 80 00 ff ff ff ud1 -0x100(%rax),%rax if you need a 32bit value. It shouldn't be hard to fix up the #UD handler to decode the instruction and obtain the displacement for a clue. Typically we use ud2 because it's the smallest #UD instruction (2 bytes) and that's enough, but if you want to provide additional clues, there's options...