Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6334950iog; Thu, 23 Jun 2022 17:08:11 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vVh8cm45HWO0GWSNJHRvjDelMh+kuptgXhHgRpl55looPBvHBkj5o4Gr6nCx/N1d6Uhjjt X-Received: by 2002:a17:906:4fc9:b0:722:f204:ef5d with SMTP id i9-20020a1709064fc900b00722f204ef5dmr9812944ejw.213.1656029291483; Thu, 23 Jun 2022 17:08:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656029291; cv=none; d=google.com; s=arc-20160816; b=G8vXpIsH7rqs4Y6ibM2qadR4rHTXB4WzOEyTlI6D27n0/EcwrhSMpHB5hBCz8K1hZc Io+J5xSW2+y+IJBrFesj4zcS+QIyRg2ED97XmPLslmmHt8//X1T817JwT8xbNM5xAgGK BarkM+yv7GiklfpmWu3LZ8JcXT5e1GXNcYyiQSN/qFvmk32cu+5jT6P5flNHTgsek/Qq drLrzNkuV3qfmjoG1HkT/8PWco0Nt8/at7j7/Xfy50JHlcsMa0ZIZU3ACEiAEX+ASs8V /W3IGbpOJMH7gCWY8+0kZbabhg/ZsoQofKeoAvRWPg87CqDZ4Ad9l5vZIdk5nIVjNMup CC1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=y5t2HdHgbQDM3fVs9f9inVKfPOgEozAtWYglMYVXHeo=; b=aNtgKrFSoi3UcX3xpr6TP8xyTY1GJHWo0y5g3ezZiMyCydqQBd5P8Trr2jnqwABMu2 dySMvY2qcWh+aUkUQvrZ34pth5G86rVcT1/cmvrpTGd6fc1BNr3vuJYAYO6+zlfc+PqD 3h7/3n/DGM7wvjMlaQ6cT3n+N4lfo1pSMhEfDnUCX1BGNy2V7bfBhYbTczN7Hp9iGohl Efx7Fyw6Mw1FHtnzmphkFR9eBqXDZ+UQA2i+b2NPwzzBBePRZbgsotJLVMVUi6ur97og 1pSO+f+tRX8FTkyspD1b+W/DmADt4NJs4UO822QipT/xkwlQ680FMHnxtMuX47NYh0fv SYAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=RuFxaVmx; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hz3-20020a1709072ce300b00718cd33f793si801634ejc.158.2022.06.23.17.07.40; Thu, 23 Jun 2022 17:08:11 -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=@google.com header.s=20210112 header.b=RuFxaVmx; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230336AbiFWXdx (ORCPT + 99 others); Thu, 23 Jun 2022 19:33:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229514AbiFWXdv (ORCPT ); Thu, 23 Jun 2022 19:33:51 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D2F55639F for ; Thu, 23 Jun 2022 16:33:49 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id a2so1566022lfg.5 for ; Thu, 23 Jun 2022 16:33:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=y5t2HdHgbQDM3fVs9f9inVKfPOgEozAtWYglMYVXHeo=; b=RuFxaVmx5XYRY5cqHS6MXL8FQOv9P3Qc6bXQm6YEdOifK6a/lTAFCGFL2J4ATAQQFY lwCKS6zC7RJM/DUvxNJJCHOVPnF/6IJjID28NEl412feqsYv1uZFexivMdsdVa+7tn2X MGMfYO0AbTXmbcfSxsQPuGgp2ZmB8OmFzHZSms9FbzYCu1SojnuuERyeWei46ML1VAnI f5+edDfn3TD/BIFurtpH6q80H076WYN2G7TkGUjrLTpAyNcYDfaVP63FXe76kdTu9nr2 KhrmWXUNpaXlUGfWHxfTczNfXxGUYutkiGRxGjmVn9kcsMYI2nS4Wkona1TX4gvI67M/ gwMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=y5t2HdHgbQDM3fVs9f9inVKfPOgEozAtWYglMYVXHeo=; b=kw8kNB15iC7lTM5PGSm1K6A8T3t3mOG85ka9bROCwY+I2+ttSC/9fIRyvYxhlpJW05 Est68HEtwsTL0lB22mlqBx32WCo0+YjYv65qzJXs/I26HZfAnC+1EDrGNfA7OGH985up 140a2L1kOlK3mhLCnsDECe4rHuqX6J3gQkvoaqN4v/C35zS7OpQ9ur3/Y0ukGCo8W1U4 phUwffOv7/AujbooeFa/VoFlRv3xBQN2nXH4bzAkM9H1ZgtZwrt54IPjyT61tImFlWzY eftWJ0DGUeNQ58E4oEaD2Je+KEhTo9fAmVZ3O2sKxAkKwIVt6SqKXjVMHRi7XyANNb1t N17A== X-Gm-Message-State: AJIora9yqepTKw+oQl5kN5Do6LbPCALJoO6U1Gy6QZEvmYJXJG1qzrCU 8NVv4MtNuvF24MGINDUts8RSJAQuXDwcO2maRS8mrA== X-Received: by 2002:a05:6512:3f9f:b0:47d:c87e:f8f3 with SMTP id x31-20020a0565123f9f00b0047dc87ef8f3mr6953750lfa.401.1656027227275; Thu, 23 Jun 2022 16:33:47 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Nick Desaulniers Date: Thu, 23 Jun 2022 16:33:35 -0700 Message-ID: Subject: Re: mainline build failure due to 281d0c962752 ("fortify: Add Clang support") To: Linus Torvalds , Josh Poimboeuf Cc: Sudip Mukherjee , Nathan Chancellor , Kees Cook , Linux Kernel Mailing List , clang-built-linux , Peter Zijlstra Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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, Jun 22, 2022 at 3:40 PM Nick Desaulniers wrote: > > On Wed, Jun 22, 2022 at 10:49 AM Linus Torvalds > wrote: > > > > On Wed, Jun 22, 2022 at 12:26 PM Sudip Mukherjee > > wrote: > > > > > > Tried it after applying your patch. There was no build failure, but some warnings: > > > > So some of those objtool warnings are, I think, because clang does odd > > and crazy things for when it decides "this is not reachable" code. > > > > I don't much like it, and neither does objtool, but it is what it is. > > When clang decides "I'm calling a function that cannot return", it > > will have a "call" instruction and then it will just fall off the face > > of the earth after that. > > > > That includes falling through to the next function, or just to random > > other labels after the function, and then objtool as a result > > complains about a stack state mismatch (when the fallthrough is the > > same function, but now the stack pointer is different in different > > parts), or of the "falls through to next function". > > > > I think it's a clang misfeature in that if something goes wrong, you > > basically execute random code. I'd much rather see clang insert a real > > 'ud' instruction or 'int3' or whatever. But it doesn't. > > So adding `-mllvm -trap-unreachable` will turn these > `__builtin_unreachable()`'s into trapping instructions. I think we > should just do that/enable that in the kernel. The following patch > eliminates ALL of the fallthrough warnings observed from objtool on > x86_64 defconfig builds. > > ``` > diff --git a/scripts/Makefile.clang b/scripts/Makefile.clang > index 87285b76adb2..1fbf8a8f3751 100644 > --- a/scripts/Makefile.clang > +++ b/scripts/Makefile.clang > @@ -36,6 +36,7 @@ endif > # so they can be implemented or wrapped in cc-option. > CLANG_FLAGS += -Werror=unknown-warning-option > CLANG_FLAGS += -Werror=ignored-optimization-argument > +CLANG_FLAGS += -mllvm -trap-unreachable > KBUILD_CFLAGS += $(CLANG_FLAGS) > KBUILD_AFLAGS += $(CLANG_FLAGS) > export CLANG_FLAGS > ``` > > There's more I need to do for LTO; `-mllvm` flags need to be passed to > the linker in that case. Let me do a few more builds, collect > statistics on build size differences (guessing neglidgeable), then > will send out a more formal patch. Looks like these are actually from calls to __ubsan_handle_divrem_overflow which is __noreturn when panic_on_warn is set by the corresponding config. I wonder if we should be unconditionally adding __ubsan_handle_divrem_overflow to the allow list `global_noreturns` in tools/objtool/check.c? It seems like the kconfig defines aren't passed through to the tools/ sources. List of fallthrough warnings from allmodconfig for reference: https://lore.kernel.org/lkml/YrNQrPNF%2FXfriP99@debian/ -- Thanks, ~Nick Desaulniers