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 X-Spam-Level: X-Spam-Status: No, score=-11.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AC57C433E0 for ; Fri, 5 Jun 2020 19:30:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DC551206FA for ; Fri, 5 Jun 2020 19:30:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="CM7S9hzo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727087AbgFETa2 (ORCPT ); Fri, 5 Jun 2020 15:30:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727010AbgFETa2 (ORCPT ); Fri, 5 Jun 2020 15:30:28 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B17FC08C5C3 for ; Fri, 5 Jun 2020 12:30:27 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id t7so5672828pgt.3 for ; Fri, 05 Jun 2020 12:30:27 -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=AbyBZikI3hqgXmsHBOfV75n7XdKr0G/JAWMAPeCKaVM=; b=CM7S9hzo9pTl7u6+baQLjXQEAeN1JeKl7OKM3VOg/W5H7eiQwaxhARGEUpluvm5OZE qn/79lkDeXfzIlQH7fGekrn/YUFxJZfRMp48Jp6lvtniA5VWnvNqjkqPyX6dbDM8ytgq FlAykxq3HNcAX2dQtka5uiu3J/ZrW3Ii+QuAQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=AbyBZikI3hqgXmsHBOfV75n7XdKr0G/JAWMAPeCKaVM=; b=oCgYYSP4QbN5OcM1bx3UcHH28z0xSA6TxjPfFSkLSbrah/OQKXaiM+vlUKD5Ka0xqS 5PbURwkJXowq+DipB/wivhBgY1NxFbDxSNO4LEzXka0a4qp7XtXZNLypD34eKMI8K1kN Kc2M+1F+zICEgKhDbnPKN1PgguGeXmAcMhbWvzbmMfuds8Cc6rEu1K/1JG/mXm0F+pco Afr3yOv9GrVZ9KUJ/sK9CoWSxswkd2j124O6yTpM8BaOWYT7G0kV/sov/WyD+AfNPUIY WfpIQCWxEbad/UyM2YSBbRHypdAYkEil80sAJyUx7kTuFIg/3xOU5cK0diZHqIlHJGBi 4WTQ== X-Gm-Message-State: AOAM530gheE1/oX4XfmbG2znbQd5rH8yjr4SX/kXaG0nRlJa9OI64hKo dSPeHEcOunn4LHM6cQzG2z0Bog== X-Google-Smtp-Source: ABdhPJwF7iSAohqEGKNsj8WMqTwy2PzH6/8uc+MdsDrlJtOWrk3aZlMTtCIbbLzwQ7WIMzePkNkM+Q== X-Received: by 2002:a63:454c:: with SMTP id u12mr10994700pgk.153.1591385426987; Fri, 05 Jun 2020 12:30:26 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id x11sm332239pfq.169.2020.06.05.12.30.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2020 12:30:26 -0700 (PDT) Date: Fri, 5 Jun 2020 12:30:24 -0700 From: Kees Cook To: "Gustavo A. R. Silva" Cc: Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: Re: [PATCH v2] docs: deprecated.rst: Add zero-length and one-element arrays Message-ID: <202006051150.B30EE1104D@keescook> References: <20200605162142.GA1617@embeddedor> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200605162142.GA1617@embeddedor> Sender: linux-doc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org On Fri, Jun 05, 2020 at 11:21:42AM -0500, Gustavo A. R. Silva wrote: > Add zero-length and one-element arrays to the list. > > While I continue replacing zero-length and one-element arrays with > flexible-array members, I need a reference to point people to, so > they don't introduce more instances of such arrays. And while here, > add a note to the "open-coded arithmetic in allocator arguments" > section, on the use of struct_size() and the arrays-to-deprecate > mentioned here. > > Signed-off-by: Gustavo A. R. Silva > --- > Changes in v2: > - Adjust some markup links for readability. > > Documentation/process/deprecated.rst | 83 ++++++++++++++++++++++++++++ > 1 file changed, 83 insertions(+) > > diff --git a/Documentation/process/deprecated.rst b/Documentation/process/deprecated.rst > index 652e2aa02a66c..042c21c968e19 100644 > --- a/Documentation/process/deprecated.rst > +++ b/Documentation/process/deprecated.rst > @@ -85,6 +85,11 @@ Instead, use the helper:: > > header = kzalloc(struct_size(header, item, count), GFP_KERNEL); > > +NOTE: If you are using struct_size() on a structure containing a zero-length Please use: .. note:: for this kind of "NOTE:" > +or a one-element array as a trailing array member, stop using such arrays And I think it was likely my language suggestion to say "stop using", but probably this should be more friendly. How about "please refactor such arrays ..." > +and switch to `flexible arrays <#zero-length-and-one-element-arrays>`_ ... to a `flexible array member <#... > +instead. > + > See array_size(), array3_size(), and struct_size(), > for more details as well as the related check_add_overflow() and > check_mul_overflow() family of functions. > @@ -200,3 +205,81 @@ All switch/case blocks must end in one of: > * continue; > * goto