Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp54474iog; Tue, 28 Jun 2022 16:14:22 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tHO37R3AiGS3yS+nNEpSMMlX6TmduYkSLgxaL9A2COqE2zsrMx7SHWnvSiSfttg3SM8Etq X-Received: by 2002:a17:902:a413:b0:156:15b:524a with SMTP id p19-20020a170902a41300b00156015b524amr6250507plq.106.1656458062125; Tue, 28 Jun 2022 16:14:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656458062; cv=none; d=google.com; s=arc-20160816; b=mxTA8cY6+Hz/+b8+WHtEowp2KpxaSTTGBjdkASKY4WGwQtehGeOTKzH55C/yWTX/6u DDnNS+ckkXHPx1XxPjq2/pJWN+WQkNF2ZssE2+bYibvDwnptdt1KUeBW6L5r2n0BAn7i Ic1tozFWGLYXPgm8a8Aee6jNM4jvpErJq2nqk6c8ieWOuQ1g1lbnQGaHTH2EqyTQhNsi TL3J77hSlAifJ1S2pyw1M/j15NXGmfpODcNHvat0pQS1aKKhbsS+gdgEkgSM55+7eZk4 0uaDvD7baMVMsQZndeSFDgUsnL2bMnkgxWJ1GY26Ny3nkAV3olBOxBWh/focQ3TnlPH/ ZGDQ== 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=N3IX/gTlOzcMhZyH2BrZr3zTeEd5GIRlks/xcDq+XFo=; b=CeTpMiC95z4sw7lsEvc/puCPaIEih9Ff4953qYkaOhWc+sq99b5xBLIlifcxf8pHbu 8IN0FgHtKs/SfHD3B/7S9nRpezWDYW+pbnYBo6EoYH8cODMQ+xjeTXa4hDy7kU95tpXj vFcrjGWSkB2iHtqiwag7v/da7Zi6PRvXXNXp2L0MJOgQDMKQvenRDEjcw1q9fcLq/dnS ASQCcZcHKSF7LCx0VCQzvZknrF/kW8Wuyp7my85TdZSh4O+jCpLcU+fPmhkN68c6VsHf kS3PlgKO955vLzvR2AXkSHt+VhwCKaB6MuA5WhFZVtMXs2KiNgcJ9aNhAiJ+N8NztXF4 Ug8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UfvPTzD4; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a23-20020a63cd57000000b0040d62e4b88bsi21269253pgj.133.2022.06.28.16.14.10; Tue, 28 Jun 2022 16:14:22 -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=@redhat.com header.s=mimecast20190719 header.b=UfvPTzD4; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231472AbiF1WnG (ORCPT + 99 others); Tue, 28 Jun 2022 18:43:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231468AbiF1WnE (ORCPT ); Tue, 28 Jun 2022 18:43:04 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4A2951EB for ; Tue, 28 Jun 2022 15:43:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656456183; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=N3IX/gTlOzcMhZyH2BrZr3zTeEd5GIRlks/xcDq+XFo=; b=UfvPTzD41rvXA2l9B+CbhVkJqRJQggq9FUrcbPFORqNxFiCSoEbZiQQwuAw950cY2EjQMG u4I+X+ejjBTWO79oPQ26bY8mqPw2X6AVvEkQgt/TuQEr0E/y2K9nnOVQ/VHPdgM5HXmpVE plxWVM5gugHMPuHzTjuv6Mx8tp8Gt3M= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-621-HRMjf2mqM--EoK4jeMcX0A-1; Tue, 28 Jun 2022 18:43:02 -0400 X-MC-Unique: HRMjf2mqM--EoK4jeMcX0A-1 Received: by mail-qk1-f200.google.com with SMTP id m15-20020a05620a290f00b006a74cf760b2so14853555qkp.20 for ; Tue, 28 Jun 2022 15:43:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=N3IX/gTlOzcMhZyH2BrZr3zTeEd5GIRlks/xcDq+XFo=; b=ZhA0Ggk5c9xN0S0HVb5cdavoxwDmeroePLTN71s3diJuI4WKsUnXySidqaFES850JC D4CIMPaDhgntzVMSbbv83sqQnwyP/xG9kd4qFP50l52HJNt9vwZlgg9SzqXqnQpYwELH p5DFgGoksyliR+hSpNKIj2FSQCBchawKC4bk2xYFCw2QXNr9MiISXBH6ZJZZjywUDLQh SsTENzWEKixawtJaop4wrAnYHgSrx0a2exAVdhDEzyyokMUpq3JwhNMa7/76m4CdxaQZ 1OY3WTm2WHkVR25OP3TaJkB/loMm6wiQUfHYBuVH7NibH2arzBu4dRfPExknN3OaCor0 RefA== X-Gm-Message-State: AJIora+UlYha+AdkbqpMY3uwkVUbIqSkSPUoJDcBxxGXQ8V9UM10vkmX KKLDFAoK9cesMIn6N/5HVqI8LqkhjF1SiHSAMYwm9nYO7qmSb+4FXwl/mbsGIQpMu6ybj/04Nxv rCVz5lMtVj5mSqiePEQFw1J58 X-Received: by 2002:ac8:5b85:0:b0:31c:b896:fb7d with SMTP id a5-20020ac85b85000000b0031cb896fb7dmr286291qta.188.1656456181279; Tue, 28 Jun 2022 15:43:01 -0700 (PDT) X-Received: by 2002:ac8:5b85:0:b0:31c:b896:fb7d with SMTP id a5-20020ac85b85000000b0031cb896fb7dmr286269qta.188.1656456180961; Tue, 28 Jun 2022 15:43:00 -0700 (PDT) Received: from treble ([2600:1700:6e32:6c00::35]) by smtp.gmail.com with ESMTPSA id f1-20020a05620a280100b006a71c420460sm13022378qkp.22.2022.06.28.15.42.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 15:42:59 -0700 (PDT) Date: Tue, 28 Jun 2022 15:42:55 -0700 From: Josh Poimboeuf To: Nick Desaulniers Cc: Linus Torvalds , Sudip Mukherjee , Nathan Chancellor , Kees Cook , Linux Kernel Mailing List , clang-built-linux , Peter Zijlstra Subject: Re: mainline build failure due to 281d0c962752 ("fortify: Add Clang support") Message-ID: <20220628224255.w4lmzalkx3qejuyg@treble> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,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, Jun 23, 2022 at 04:33:35PM -0700, Nick Desaulniers wrote: > 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. FWIW, GCC does the same thing for calls to __noreturn functions. After the call it just "falls off the face of the earth". So there's nothing special about Clang here. > 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/ As discussed with Nick on IRC, the problem highlighted by the fallthrough warnings seems to be a mismatch in expectations as to whether __ubsan_handle_divrem_overflow() is noreturn. When Clang inserts calls to it, it assumes it's noreturn. But in fact its kernel implementation can actually return, if !panic_on_warn. So it needs to be changed to *never* return, otherwise hilarity will ensue when it returns and "falls off the face of the earth". And then objtool needs to be told that it's in fact noreturn. So, something like this: diff --git a/lib/ubsan.c b/lib/ubsan.c index 36bd75e33426..d257baa62721 100644 --- a/lib/ubsan.c +++ b/lib/ubsan.c @@ -177,6 +177,7 @@ void __ubsan_handle_divrem_overflow(void *_data, void *lhs, void *rhs) pr_err("division by zero\n"); ubsan_epilogue(); + panic("can't return from __ubsan_handle_divrem_overflow()"); } EXPORT_SYMBOL(__ubsan_handle_divrem_overflow); diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 864bb9dd3584..6f67d48fb3e4 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -187,6 +187,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func, "__invalid_creds", "cpu_startup_entry", "__ubsan_handle_builtin_unreachable", + "__ubsan_handle_divrem_overflow", "ex_handler_msr_mce", };