From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80224C433EF for ; Mon, 4 Jul 2022 18:33:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 903BF6B0071; Mon, 4 Jul 2022 14:33:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8B30B6B0073; Mon, 4 Jul 2022 14:33:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 77AC16B0074; Mon, 4 Jul 2022 14:33:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 687B66B0071 for ; Mon, 4 Jul 2022 14:33:25 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 0B37F34400 for ; Mon, 4 Jul 2022 18:33:25 +0000 (UTC) X-FDA: 79650265170.03.E5CDB91 Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by imf01.hostedemail.com (Postfix) with ESMTP id 71F4040002 for ; Mon, 4 Jul 2022 18:33:23 +0000 (UTC) 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656959604; a=rsa-sha256; cv=none; b=vQ40ShEj7tFeFBzn3/4umWJm9LrPdHUH9he/+9Opv2OAvEXNXzN0Es2ErwaPfzsGXN6neQ 0q8kCvxVnJQxTb63yNKvST1U1l963TmOpbhEvhijyk4NIckn15DjmPF6X+9oQN44HvHKyh W6MygsxULkdhNxYTJDO5XdGceTw2P3U= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of segher@kernel.crashing.org designates 63.228.1.57 as permitted sender) smtp.mailfrom=segher@kernel.crashing.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656959604; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HZ+YeuujyK+kpO/HzleJC9YagcK0WT15I3KDnR/ZJ+U=; b=WqyZjq2uKinkx/NIwhVynXQG50EtQy3wy7cO2sMGWEH2rVJfcmIiZ25OQ+TSS79l6pIST8 Ig4ZRgMnhlSH7XdLzb7uZMetSxPYVJYzjyfM1Nei44bTRTdSvyDVaaAnp7z6XgEeWpnLY3 NB9IZyqfCfJYXNW4cQi6S49anfukTpM= X-Stat-Signature: 41qr4frth8go8ifs3wshywc1h8mewnpq X-Rspamd-Queue-Id: 71F4040002 Authentication-Results: imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of segher@kernel.crashing.org designates 63.228.1.57 as permitted sender) smtp.mailfrom=segher@kernel.crashing.org; dmarc=none X-Rspam-User: X-Rspamd-Server: rspam12 X-HE-Tag: 1656959603-141455 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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