Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8091C636D4 for ; Fri, 3 Feb 2023 16:36:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229800AbjBCQgW (ORCPT ); Fri, 3 Feb 2023 11:36:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233212AbjBCQgP (ORCPT ); Fri, 3 Feb 2023 11:36:15 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05443A8A28 for ; Fri, 3 Feb 2023 08:36:05 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id t12-20020a17090aae0c00b00229f4cff534so8253992pjq.1 for ; Fri, 03 Feb 2023 08:36:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=LZtc3hBezsFJ+JgXERdSrjKYkX6f+8fQELANbScmeYk=; b=mHrlZ7VUo1d79tXgLzaqxxG9hcdPrsDjmdvruc68JlP/BcPGX6egmlSPG7P7It0txU 9dSU8O56fxinEmwWStz23VSXfaZYMa0GH4lpLKS7aLvcF5ojWn1K1ZD/aInbbKE8BbJ1 hWhhJvJq4ELKM69xRklBE4mzVGrmH5qINRT1M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=LZtc3hBezsFJ+JgXERdSrjKYkX6f+8fQELANbScmeYk=; b=EqgulrUEyJ6sCZq79LZlx8GrH/YqiJOtK8+0pq8+9e/Tb0n/xx4O+hk6Xg+bDs2gec b8JkoTHMQ7M5xmReWASRw/jNdg6PGz/OOpSvPvzgeq6KHrct7dkMs5giziRkwFUBh7Ac Bn+ImwynQe7Q85L9WR7c9GP2G/lqniQocIXeByzZnPTdbB8Y6lvXWSzbO7xkn3JuMz0k UBK2uMDJk2I86HMFqC/365pe+hZF9M6u2GNx5TP/gBmMGQqHLmp43mTXZoyxb0N9IJtK w7dbHxiiki3ZGm/sxuTPWEX0t5N1yLR8jODpinYBOmM12hLH24N6SCVvD9qSbY8DHVnI ht1A== X-Gm-Message-State: AO0yUKWDjez6kSPk0kxn3u/a7qKU39E6ErtkS6nZom/QE9V+51Z4PSXF 5y3pHfzO4a2knSOpbim4l4w+Bw== X-Google-Smtp-Source: AK7set+3gOK3BkJ0vQrBWtI5HAPi2PUYKNh8e6pqdOUt0vJfLvEQUgDgdUfKrw4YniHqw5Fg1TUcIg== X-Received: by 2002:a17:90b:38c2:b0:22c:15a4:62a0 with SMTP id nn2-20020a17090b38c200b0022c15a462a0mr10965335pjb.37.1675442165363; Fri, 03 Feb 2023 08:36:05 -0800 (PST) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id gt21-20020a17090af2d500b0022c25153cf0sm1405689pjb.44.2023.02.03.08.36.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 08:36:04 -0800 (PST) Message-ID: <63dd37f4.170a0220.9621b.27b3@mx.google.com> X-Google-Original-Message-ID: <202302031632.@keescook> Date: Fri, 3 Feb 2023 16:36:04 +0000 From: Kees Cook To: Ard Biesheuvel Cc: Catalin Marinas , Will Deacon , Mark Rutland , John Stultz , Yongqin Liu , Sami Tolvanen , Yury Norov , Andrey Konovalov , Marco Elver , linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev, Nathan Chancellor , Nick Desaulniers , Tom Rix , Alexander Potapenko , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] arm64: Support Clang UBSAN trap codes for better reporting References: <20230202223653.never.473-kees@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 03, 2023 at 12:34:38PM +0100, Ard Biesheuvel wrote: > [...] > > + switch (check_type) { > > + case ubsan_add_overflow: > > + return "UBSAN: addition overflow"; > > It would be nice if we could avoid duplicating this UBSAN: prefix 21x times. Yeah, agreed. I didn't see a way around it without weirdness or loss of details. die() takes a string not a format string, so without really odd shenanigans (re-write a single string in memory?) this is the most straight forward. One idea, though, is to drop all the strings that'll never happen -- i.e. wrap individual case statements in the associated CONFIG_UBSAN_foo. I already dropped several strings that were never implemented in the kernel's UBSAN. I could be even more picky. I'll try this in v2... -- Kees Cook