Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp415461imw; Mon, 4 Jul 2022 11:44:10 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tr+gQVq/+mtXQYly3BuYD6aYMMaehInYGUM5I8u3yj1ojUHwy8pc5CEsDmh8I2fOMrmI3M X-Received: by 2002:a17:907:270e:b0:72a:b476:95a with SMTP id w14-20020a170907270e00b0072ab476095amr11618568ejk.648.1656960249975; Mon, 04 Jul 2022 11:44:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656960249; cv=none; d=google.com; s=arc-20160816; b=0xr6ddwprH17dZM4wnrCQRTjW1kwMq6oke/GxGFK5sofVkfakegUKCw3w7p43cHvk3 bLnWLN4POkMUfPCPE+XReyTBExITRB0XhxtFUaAw1u62xknz+3YFpoBuLz7AujVqB5rp LxJPBVcEiOI4cAKm6LA/8WkKgvhXJcXSQV/wgXBDhPtVmA/UxKDL16UthYZp1eOqNBTi FIvfuQqHim5EMU6py4E7vNudEYdMExs48boyKCO7kCIB++g6aqaD5I+kVzSUtBeqYAiB KccOknHDr47m2idgdeaLNrQQKzrxW594eTg//n9DAKuGta7BrY+5EeaGhuMaDz3Y3XvB KkNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=HZ+YeuujyK+kpO/HzleJC9YagcK0WT15I3KDnR/ZJ+U=; b=aL2wKbcA9y+2E3lq+dD7WIvCKIjAAgX7LeFQv27j31JKzDpvv7KAYsNjusnRnTdtfe Nl4tS1PBt/xL2uwfeWf67EpwMHDsWUKVYjnWbayXmzZDKjYcDGxeyYCats8540cFwjQZ yz22U4n9xvQ0ZcZFLVVwflAKyjInOnj4iFpUk40/X5M6Ct13ztcRvJKXi+pEG29h41f1 WergHYczum96sGqXaSfiQBvY5in9N7+REsJiNK+MuUgpU+wObOk89EbFoX9mG/qRxSSI dhNTCgAMvEDr+uKarTyWjkvF1fLXSXv2q0icbPtoxK/yXT8j0LonuYd2SeCODlG92csc sk8A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b14-20020a056402084e00b004356df259b4si9545942edz.361.2022.07.04.11.43.44; Mon, 04 Jul 2022 11:44:09 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231944AbiGDSjO (ORCPT + 99 others); Mon, 4 Jul 2022 14:39:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229595AbiGDSjN (ORCPT ); Mon, 4 Jul 2022 14:39:13 -0400 Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5579B11A2A; Mon, 4 Jul 2022 11:39:11 -0700 (PDT) Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 264INElF019868; Mon, 4 Jul 2022 13:23:14 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 264INAKN019865; Mon, 4 Jul 2022 13:23:10 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Mon, 4 Jul 2022 13:23:10 -0500 From: Segher Boessenkool To: Alexander Potapenko Cc: Al Viro , Linus Torvalds , Alexei Starovoitov , Andrew Morton , Andrey Konovalov , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Christoph Hellwig , Christoph Lameter , David Rientjes , Dmitry Vyukov , Eric Dumazet , Greg Kroah-Hartman , Herbert Xu , Ilya Leoshkevich , Ingo Molnar , Jens Axboe , Joonsoo Kim , Kees Cook , Marco Elver , Mark Rutland , Matthew Wilcox , "Michael S. Tsirkin" , Pekka Enberg , Peter Zijlstra , Petr Mladek , Steven Rostedt , Thomas Gleixner , Vasily Gorbik , Vegard Nossum , Vlastimil Babka , kasan-dev , Linux-MM , linux-arch , Linux Kernel Mailing List , Evgenii Stepanov , Nathan Chancellor , Nick Desaulniers , Vitaly Buka , linux-toolchains Subject: Re: [PATCH v4 43/45] namei: initialize parameters passed to step_into() Message-ID: <20220704182310.GQ25951@gate.crashing.org> References: <20220701142310.2188015-1-glider@google.com> <20220701142310.2188015-44-glider@google.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, 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 Mon, Jul 04, 2022 at 05:49:13PM +0200, Alexander Potapenko wrote: > One of the reasons to do so is standard compliance - passing an > uninitialized value to a function is UB in C11, as Segher pointed out > here: https://lore.kernel.org/linux-toolchains/20220614214039.GA25951@gate.crashing.org/ > The compilers may not be smart enough to take advantage of this _yet_, > but I wouldn't underestimate their ability to evolve (especially that > of Clang). GCC doesn't currently detect this UB, and doesn't even warn or error for this, although that shouldn't be hard to do: it is all completely local. An error is warranted here, and you won't get UB ever either then. > I also believe it's fragile to rely on the callee to ignore certain > parameters: it may be doing so today, but if someone changes > step_into() tomorrow we may miss it. There isn't any choice usually, this is C, do you want varargs? :-) But yes, you always should only pass "safe" values; callers should do their part, and not assume the callee will do in the future as it does now. Defensive programming is mostly about defending your own sanity! Segher