From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 371592F2E for ; Thu, 5 May 2022 19:32:20 +0000 (UTC) Received: by mail-pl1-f170.google.com with SMTP id i1so5318175plg.7 for ; Thu, 05 May 2022 12:32:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=EOewjZKogNzEx9zFkxTiwVeX9O73E8+rxUrKCGLnZxg=; b=TgYp87XeMuHw4kfuuIYKyJ5xg3Bf+EBlgFpOVZz9+/0BPs+Z6azVvmnOICk6zx2eTE tczIFjF07XtN/n9uGmSnmZf+pbPbkOzW9u24HVcBrKjfFRAXW8suN/eYiFsQiaSTDjAj AGDsgPRlkyLVEDH7ZM2ezggNxFIlqaWFz6sF8= 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=EOewjZKogNzEx9zFkxTiwVeX9O73E8+rxUrKCGLnZxg=; b=SyoE8kk8nYgr/23AObJg+IJ2gOthr0aYB5diAxbYjMJBNg+oKnKw+nwBZmGwX1skap jvkI79wiYuDVUvgsb7d7An0UwVARC2JeqIquy6/JX0HoAMpzyDHFW1vpqWyGySSb0Gra dhx75iMK7Ccct1BfKuSHnQuMrXWr+8U3BjlFCMEjRi2+A+wqiCUfigWk+KxA/agxKwP5 h8KvM6fnYIWux8JylF8DjGq8xhXVxeJSUmuW9xryqv+nxL/vSH+ncgeViOaFpd0hlOP+ 9YPCwo7Zz98uT0reuGIwCsmAs1CvM1suYGWNSjlxc27ed2SbSkmhYXVtj7smJgXFaBaT BQCA== X-Gm-Message-State: AOAM531fhsKi+NeqHRdkvtdLvYX4ApP1ktC/GCAQNoOXtHkTgzjnZXsT 7mrnDqfnSgmCJc6uNRU+nnncQg== X-Google-Smtp-Source: ABdhPJxL8Xyqbkq2ci79I6DY8zysA5FCbZa+vgjColIyO04wVwYosK0CB3nAiv0hotnSlV0fyXrrOw== X-Received: by 2002:a17:90a:c08a:b0:1d9:88de:d192 with SMTP id o10-20020a17090ac08a00b001d988ded192mr8024103pjs.8.1651779139639; Thu, 05 May 2022 12:32:19 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id q187-20020a632ac4000000b003c14af5063fsm1666643pgq.87.2022.05.05.12.32.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 May 2022 12:32:19 -0700 (PDT) Date: Thu, 5 May 2022 12:32:18 -0700 From: Kees Cook To: Keith Packard Cc: Johannes Berg , "Gustavo A . R . Silva" , Francis Laniel , Daniel Axtens , Dan Williams , Vincenzo Frascino , Guenter Roeck , Daniel Vetter , Tadeusz Struk , Alexei Starovoitov , alsa-devel@alsa-project.org, Al Viro , Andrew Gabbasov , Andrew Morton , Andy Gross , Andy Lavr , Arend van Spriel , Baowen Zheng , Bjorn Andersson , Boris Ostrovsky , Bradley Grove , brcm80211-dev-list.pdl@broadcom.com, Christian Brauner , Christian =?iso-8859-1?Q?G=F6ttsche?= , Christian Lamparter , Chris Zankel , Cong Wang , David Gow , David Howells , "David S. Miller" , Dennis Dalessandro , devicetree@vger.kernel.org, Dexuan Cui , Dmitry Kasatkin , Eli Cohen , Eric Dumazet , Eric Paris , Eugeniu Rosca , Felipe Balbi , Frank Rowand , Franky Lin , Greg Kroah-Hartman , Gregory Greenman , Haiyang Zhang , Hante Meuleman , Herbert Xu , Hulk Robot , Jakub Kicinski , "James E.J. Bottomley" , James Morris , Jarkko Sakkinen , Jaroslav Kysela , Jason Gunthorpe , Jens Axboe , Johan Hedberg , John Keeping , Juergen Gross , Kalle Valo , keyrings@vger.kernel.org, kunit-dev@googlegroups.com, Kuniyuki Iwashima , "K. Y. Srinivasan" , Lars-Peter Clausen , Lee Jones , Leon Romanovsky , Liam Girdwood , linux1394-devel@lists.sourceforge.net, linux-afs@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-hardening@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-integrity@vger.kernel.org, linux-rdma@vger.kernel.org, linux-scsi@vger.kernel.org, linux-security-module@vger.kernel.org, linux-usb@vger.kernel.org, linux-wireless@vger.kernel.org, linux-xtensa@linux-xtensa.org, llvm@lists.linux.dev, Loic Poulain , Louis Peens , Luca Coelho , Luiz Augusto von Dentz , Marc Dionne , Marcel Holtmann , Mark Brown , "Martin K. Petersen" , Max Filippov , Mimi Zohar , Muchun Song , Nathan Chancellor , netdev@vger.kernel.org, Nick Desaulniers , Nuno =?iso-8859-1?Q?S=E1?= , Paolo Abeni , Paul Moore , Rich Felker , Rob Herring , Russell King , selinux@vger.kernel.org, "Serge E. Hallyn" , SHA-cyfmac-dev-list@infineon.com, Simon Horman , Stefano Stabellini , Stefan Richter , Steffen Klassert , Stephen Hemminger , Stephen Smalley , Takashi Iwai , Tom Rix , Udipto Goswami , wcn36xx@lists.infradead.org, Wei Liu , xen-devel@lists.xenproject.org, Xiu Jianfeng , Yang Yingliang Subject: Re: [PATCH 02/32] Introduce flexible array struct memcpy() helpers Message-ID: <202205051228.4D5B8CD624@keescook> References: <20220504014440.3697851-1-keescook@chromium.org> <20220504014440.3697851-3-keescook@chromium.org> <202205040819.DEA70BD@keescook> <970a674df04271b5fd1971b495c6b11a996c20c2.camel@sipsolutions.net> <871qx8qabo.fsf@keithp.com> Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <871qx8qabo.fsf@keithp.com> On Thu, May 05, 2022 at 08:16:11AM -0700, Keith Packard wrote: > Johannes Berg writes: > > > Yeah, dunno, I guess I'm slightly more on the side of not requiring it, > > since we don't do the same for kmalloc() etc. and probably really > > wouldn't want to add kmalloc_s() that does it ;-) > > I suspect the number of bugs this catches will be small, but they'll be > in places where the flow of control is complicated. What we want is to > know that there's no "real" value already present. I'd love it if we > could make the macro declare a new name (yeah, I know, mixing > declarations and code). I don't think I can do a declaration and an expression statement at the same time with different scopes, but that would be kind of cool. We did just move to c11 to gain the in-loop iterator declarations... > Of course, we could also end up with people writing a wrapping macro > that sets the variable to NULL before invoking the underlying macro... I hope it won't come to that! :) -- Kees Cook