Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp965749imw; Thu, 14 Jul 2022 14:27:20 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uBY1H50V6a0gFclIqmDBU0C+nLjmxrmEtqJ6lDdL162r9nE7zN0dwOCjcyMAqfof/Eabmq X-Received: by 2002:a17:902:c94e:b0:16c:4d5e:5dfc with SMTP id i14-20020a170902c94e00b0016c4d5e5dfcmr10266139pla.56.1657834040586; Thu, 14 Jul 2022 14:27:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657834040; cv=none; d=google.com; s=arc-20160816; b=A6wDOlCHcBn1EIToFD4IOVHAOXSKdl7bkvocx8DjQI2Jm1Qpoh6/xE8EWhU51oiuny 3qOH3ksIvveu3A7ZeIaLO7e+7QBrzac0+H3RMn811z/q9hdMLUSOI9oS+rGkTWujpJQW Mw5+/IbxrCVe3cLDv7QkVs/XgrlSkn4XNFviJWqnuY1HVkDZv2GNmgQTpxll1I8t+n8e +zl+UegTnHVlTIC+rdHuE1NTDjqspxIu2i01yfH4B1BvrdUfDH6jhT7ItdAjY791+guB d13RAiQiKYKVlKKLnO3Rh0o6cZqfZzSK++s2mDjeDckHe7nMS3uXDO9o+3P2ZeixMG6G DowQ== 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=GUD66KXYruWTeFLrqZus6yW7MSzc8J6rVQqQGgkyWFc=; b=z0bW/51nOjJxn3YS/qvhmwIUQTfx3ixbz7Tv6ivh7Z9vp+wgG5EOaQgj2SNbtaaybi D3t6TBm+Gx575LqaUrY/SnbIFwDzHVOS4QHasr/Hzsc4oHgcH7OK0j9QQbv0sPVp93es 6kYDNY82aiuxZBYEhTqTasU4Xz+jceJpvGeKeT+zOa2pPl9f9jLTR+MTrwdE8v9py4fj dicsGhMpiN2fxl/0vpacRLqRXgqDLd/W/eXxnyjor+hgVmUGpCDo1u1/LliurWvxeIUB CnmETSpu33mdwkaUg7xv8sTATbNuO7tWrQ+0bKAiuL0MPBKuWBaDmDWsKzghEz/h0Mjl oEqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aGGgGGFT; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fw13-20020a17090b128d00b001ecba51171dsi6200934pjb.143.2022.07.14.14.27.04; Thu, 14 Jul 2022 14:27: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=@kernel.org header.s=k20201202 header.b=aGGgGGFT; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239483AbiGNVZE (ORCPT + 99 others); Thu, 14 Jul 2022 17:25:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240467AbiGNVZC (ORCPT ); Thu, 14 Jul 2022 17:25:02 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 352CC54C8F for ; Thu, 14 Jul 2022 14:25:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D8BE6B82943 for ; Thu, 14 Jul 2022 21:24:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C873FC34114; Thu, 14 Jul 2022 21:24:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1657833898; bh=WvpnAxKxsj54Q5vNQwYzZo/IQOstcntEKXe0TpyNz8s=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=aGGgGGFTBXsnNpfLZqeLZBpxrfs0pGGhOWXuWtu1oy1ohhMvPtLtolqO3ILQmMBSR 4BBBUeQJ9bF/2j7HPR3PnA1ej+sVppXFT1ruIoAX0K7NiOMsD7cNueLI6GdcaN4v6g cwYfx1Yn95feVNT+2/0ccwUW1WN4362rfhELcCc5XIqdt3gjo90gQAMF6upuYAvldS n+xXRFZvH2UyHOX7wQ3PZ55JAhKEfhT3livOPWs7EFNl0hd4n8o+g9a9ePMz/BW8u2 9ThFsr+JfS5nC0XZ7GVvF8EU3mXB78QoRQmUu8qf19wxUwHJ9aAsS5/Q0asGOM9MrT lEri2W4cMKlcA== Date: Thu, 14 Jul 2022 14:24:56 -0700 From: Nathan Chancellor To: Nick Desaulniers Cc: Kees Cook , Sudip Mukherjee , Linus Torvalds , Tom Rix , Marco Elver , Andrew Morton , Josh Poimboeuf , "Peter Zijlstra (Intel)" , linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: Re: [PATCH] ubsan: disable UBSAN_DIV_ZERO for clang Message-ID: References: <20220714205646.4023495-1-ndesaulniers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220714205646.4023495-1-ndesaulniers@google.com> X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Thu, Jul 14, 2022 at 01:56:43PM -0700, Nick Desaulniers wrote: > Building with UBSAN_DIV_ZERO with clang produces numerous fallthrough > warnings from objtool. > > In the case of uncheck division, UBSAN_DIV_ZERO may introduce new > control flow to check for division by zero. Because the result of the > division is undefined, LLVM may optimize the control flow such that > after the call to __ubsan_handle_divrem_overflow doesn't matter. If > panic_on_warn was set, __ubsan_handle_divrem_overflow would panic. The > problem is is that panic_on_warn is run time configurable. If it's > disabled, then we cannot guarantee that we will be able to recover > safely. Disable this config for clang until we can come up with a > solution in LLVM. > > Link: https://github.com/ClangBuiltLinux/linux/issues/1657 > Link: https://github.com/llvm/llvm-project/issues/56289 > Link: https://lore.kernel.org/lkml/CAHk-=wj1qhf7y3VNACEexyp5EbkNpdcu_542k-xZpzmYLOjiCg@mail.gmail.com/ > Reported-by: Sudip Mukherjee > Suggested-by: Linus Torvalds > Signed-off-by: Nick Desaulniers Acked-by: Nathan Chancellor > --- > Linus, > I still think we should add explicit checks to gaurd against divide by > zero. > > lib/Kconfig.ubsan | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/lib/Kconfig.ubsan b/lib/Kconfig.ubsan > index a9f7eb047768..fd15230a703b 100644 > --- a/lib/Kconfig.ubsan > +++ b/lib/Kconfig.ubsan > @@ -84,6 +84,9 @@ config UBSAN_SHIFT > config UBSAN_DIV_ZERO > bool "Perform checking for integer divide-by-zero" > depends on $(cc-option,-fsanitize=integer-divide-by-zero) > + # https://github.com/ClangBuiltLinux/linux/issues/1657 > + # https://github.com/llvm/llvm-project/issues/56289 > + depends on !CC_IS_CLANG > help > This option enables -fsanitize=integer-divide-by-zero which checks > for integer division by zero. This is effectively redundant with the > -- > 2.37.0.170.g444d1eabd0-goog > >