Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1866232iog; Tue, 14 Jun 2022 15:25:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5ISAQuYUKgnxhhUCuw+kHD538TglUhfXNWCzhPZgQB9ShD0tWdOU3bKI3/mBZSD/9Pnqz X-Received: by 2002:a17:906:58cb:b0:70a:751c:91fc with SMTP id e11-20020a17090658cb00b0070a751c91fcmr6201990ejs.258.1655245559499; Tue, 14 Jun 2022 15:25:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655245559; cv=none; d=google.com; s=arc-20160816; b=mSJS5TPApPzsH/Mcn3YTu69/NPDDdGgKtKcbpXtHviOL5cgouvPcpF4hbJChT/fXd+ q1Ix7WST80o3xnA1Dh7ZfAdtW6kai4LM8VUMPG+q1J/UFUacS5En+PO2j6Oxb9Rg3OJl mNgExbPbgaUBtcdUzBYXbLoCgERmni300sp3WptSFx19fa7/U/IEBTccZtSS0Q7kq7tI p4+dM2nXDvy3o2GATmM56+KVK0TylnXzIDUQCnpag8G0ASg6dDJzsSOTrXouH+3iSkyR VJPcoPV5BfX6TkHZ8Cmftw5Bi8Q8HncWLTlVsIF6GiMrhQMok1Sye2a569pl0mi8Vd2N BgxA== 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=4dGwyqQWqKQhUVZXocdLXxbcz5iYcIebggOB8F+Krxg=; b=JSKuy/jv2rxXKrFCaCcqy8+uK/ch8BMmAlxV/TyZ0I6dHZ019tkcn5v/C//D+PMXq9 s3pNjGr3fBwTq2ml1u/zKDxtugy5QKDLaretHwOgJxYO+oohi/SximmgGAxBfE8GMRQ2 +GRB5fDP2plB8S39Uelk0uzR0A8s1SZOaN+FopTSYxkAPzoBAb32N5qPNJVAqSL3gxDo ztbZt9jM/6aBXyjE7WQ7o20R1BadynsIT+bzcOgl9TIbI+DRCcpZxueJDUdqAVyvs3wc ZO7yvnezbSqUyMzurtMdAa/Jdv5Q+PeV9ReR0hkHrS7D/UZ3uaFw6VZuudfLzWO3dM/M hORg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=FMnyQsbB; 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 s22-20020aa7c556000000b0042da5231c11si10079692edr.491.2022.06.14.15.25.33; Tue, 14 Jun 2022 15:25:59 -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=FMnyQsbB; 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 S1353630AbiFNWI5 (ORCPT + 99 others); Tue, 14 Jun 2022 18:08:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352180AbiFNWIz (ORCPT ); Tue, 14 Jun 2022 18:08:55 -0400 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E166D4EDF9 for ; Tue, 14 Jun 2022 15:08:52 -0700 (PDT) Received: by mail-io1-xd32.google.com with SMTP id e80so10880577iof.3 for ; Tue, 14 Jun 2022 15:08:52 -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=4dGwyqQWqKQhUVZXocdLXxbcz5iYcIebggOB8F+Krxg=; b=FMnyQsbBTpfaI982a6MQ8uP9ByA2o3U8F3mrkPUXG5pAZOzw98y0CapM11N8zUSG0t 99K7QlRSow8lJ80bPLWSV5/BAgHq/LkEyuiWY8Z5wDHKVa42NKERpzSJzXuvOlA7ZgtE PxlpozmA+LusYvnX5clXnPKnxVgZ/njUZPiWCIrJkhuGEkvmeeNlfHMHPyoLZGI7ljXB 5d/9uZc5/9VAjp90jGCddlIt3tzsIzRkKWeHDudrnFvSmA+kUcVneI4x7FaSLKVfHR+t Lgq9/jNX/HxyW+K50bQGutQLKTOcIxdU2M1Zx7BDWn2VLhxHEPBklp1eztS5pV776hHS x0PA== 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=4dGwyqQWqKQhUVZXocdLXxbcz5iYcIebggOB8F+Krxg=; b=3TmKo6nGsHimh0W1hZY0Nq6eg3qnLGPfsSI3F3Lu5khv54h/zAM8WDp+739KbCQYEZ BhdfK/p4Q+2BJt5R/7T5+bGnNisOzkEVi4mrsyoBWG48XkYDVjbzcbzIY4VEt9a7tH2o n67C7YRQ4bLsRvVtieFH+FE2bNX9jZe6h85IQ5ZrByHAEpWl70MR+JB3vwd9YwdHNUlV AThUR6gNP9u33pTwXc91mp6+5Kv5V2lnyOLOjiJhMgLP7fw4LrdUCxhDDFEUS1Y/nbiP 5oVSSoWmLKZFiJ9Zo0y4p3jRgLYt745puhvWQbIu06oW6053eGfNz+AFfswu2XuTKvbz 35RQ== X-Gm-Message-State: AOAM531YZgVFcXgkMuHKdvTgXGW8360czOg9c55McM4h/VJWi3TWjmxj +aUg68FCPK8rcVtMZ2Br6fJdk7rxC0fbUkGynMxjnQ== X-Received: by 2002:a02:a98a:0:b0:332:b171:df78 with SMTP id q10-20020a02a98a000000b00332b171df78mr4035478jam.54.1655244531923; Tue, 14 Jun 2022 15:08:51 -0700 (PDT) MIME-Version: 1.0 References: <20220614144853.3693273-1-glider@google.com> <20220614214039.GA25951@gate.crashing.org> In-Reply-To: <20220614214039.GA25951@gate.crashing.org> From: Evgenii Stepanov Date: Tue, 14 Jun 2022 15:08:40 -0700 Message-ID: Subject: Re: [PATCH] [RFC] Initialization of unused function parameters To: Segher Boessenkool Cc: Alexander Potapenko , Linus Torvalds , Kees Cook , Marco Elver , Nathan Chancellor , Nick Desaulniers , Thomas Gleixner , Vitaly Buka , Linux Kernel Mailing List , linux-toolchains 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 Tue, Jun 14, 2022 at 2:45 PM Segher Boessenkool wrote: > No such luck: the passing itself already causes UB. > > GCC does not warn, it has already optimised the code to what you expect > by the time this warning is done. If you use -fno-inline it does warn > for both "c" and "size" (via -Wmaybe-uninitialized). > > But it is still UB! All bets are off, no compiler can do any correct > translation of your program, since there *is none*. Clang also puts "noundef" attribute on most function arguments in the frontend, and the optimizer can assume that the inputs are fully initialized. The diagnostic for this is very imperfect. What Alex is proposing (the KMSAN option) takes place *after* inlining, so it will only enforce the "semantically meaningful" case in Linus's words.