Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp71887pxb; Wed, 20 Oct 2021 16:49:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfadybfYqfIyLDHPVb+gxT1gyWirfelUu4EIvSBwdNjou44cPhKdYYsfwNmIVUms7VFWS4 X-Received: by 2002:a17:90b:4f88:: with SMTP id qe8mr2218309pjb.223.1634773765387; Wed, 20 Oct 2021 16:49:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634773765; cv=none; d=google.com; s=arc-20160816; b=v4GTzKuJLX17/Jz9TvGJKgv/xkRcmKdvKzu1NZkSxQIKXbRm0+cmpL/sYcatHnaKXD NkAkba9H6cN4co+hsLOMGx/vtpJLDAkUQBB26J+f8lghWRInFF1tRPTkB6zZJ7U39Cgh b3b+H37ZI0tp//HRPP+jG0OfvMyvmbeCdOPbrtNyKUWykjGjIS+rQKB31UDVLhBIo8nv d6gL/lwCXAVRNiHktY1MlbcFm0MjatI0O4tPZlINM8bhLaPuW8zknSXV8xmiERpKcz7k RDM/CnoQNxn+FMYKBGxp6VJQtzysrSZzebilDfKv58ctKIIHi3y2dkp7pFrRDHFuV2Rl FSRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=QOMXhl2t9tXprlLwOQ1BpWBiqNctAy6PHs74QzoB5+Q=; b=ki923IEvmY1V8S2Nfucd9PyTfkNOv1/yjJALzln7m9VYLdz2/RKmK8CRE6XmY109D9 XjYDuRItN/K/RE8bgy1agpcytQLWQrMgAew8zP4INIuzg9zHbLKpCB6SrhbVpGlwAxIs 5xjHdl8h5JDlpm33+0D4Ajt8m+ccdE47fQTlNoPhlkMaETU3o/w4SoaEUJAog71GILaa ZbuKXkfxdRgi20A0NBfBT509y50DeEJi+QsKQBl91/2EEdMRQyDHUSg6LmcN31m1BqnK JoH9CV3Y4TiNnrYUY5ef94oCZsFlrdZn1yc2CdtfqtFdNyyXF6imhb2RrsVx+GJCySXj rLLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KyPiwW44; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id na16si11833046pjb.128.2021.10.20.16.49.12; Wed, 20 Oct 2021 16:49:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KyPiwW44; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231311AbhJTXtv (ORCPT + 99 others); Wed, 20 Oct 2021 19:49:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:36006 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230103AbhJTXtt (ORCPT ); Wed, 20 Oct 2021 19:49:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 04E6861004; Wed, 20 Oct 2021 23:47:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634773654; bh=9d545R9PWdQWgRdbw7W5tcMHp9oZBeg+DHAnlfPE+vU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KyPiwW446bj302JCDkfG8CtZMG4oK07102wrPx+eQKBBQ2PDQV+ylFJYdPL9OtRPn IFuCrr8/h5BRVvP9Gf6leTiOAmalzBdAS5u+qb3UQ3WroX4GQpAvpQorfSPYN9m34J YUR6gtb7wF/5Yj+OyBaufc2uyPxyMUpgQ2liiwY6s0JVHvPachAfuUYhz62yRVhIsW eLU3jPlodt9HbDxx+u8g0012MIdtYSCJnQkeszpYQT7eDzti3V7Nj2rDQjIIPZfhET ftM+Lexlzin2QZgOp7eanyTJSsNhB7LCIQBgV8TQ5c50UglTH26MmQ1nbI0qKuiuLd GAOnbQnEhCU9Q== Date: Wed, 20 Oct 2021 18:52:14 -0500 From: "Gustavo A. R. Silva" To: Len Baker Cc: Jonathan Corbet , Kees Cook , Joe Perches , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH v3] docs: deprecated.rst: Clarify open-coded arithmetic with literals Message-ID: <20211020235214.GA1346969@embeddedor> References: <20210925143455.21221-1-len.baker@gmx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210925143455.21221-1-len.baker@gmx.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Sep 25, 2021 at 04:34:55PM +0200, Len Baker wrote: > Although using literals for size calculation in allocator arguments may > be harmless due to compiler warnings in case of overflows, it is better > to refactor the code to avoid the use of open-coded arithmetic. > > So, clarify the preferred way in these cases. > > Suggested-by: Kees Cook > Signed-off-by: Len Baker This looks good to me. Reviewed-by: Gustavo A. R. Silva Thanks -- Gustavo > --- > Changelog v1 -> v2 > - Clarify the sentence by changing "keep out" with "avoid " > (Joe Perches). > > Changelog v2 -> v3 > - Reword the sentence to comunicate better (Jonathan Corbet). > > The previous version can be found here [1]. > > [1] https://lore.kernel.org/linux-hardening/20210829144716.2931-1-len.baker@gmx.com/ > > Documentation/process/deprecated.rst | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/Documentation/process/deprecated.rst b/Documentation/process/deprecated.rst > index 8ced754a5a0f..388cb19f5dbb 100644 > --- a/Documentation/process/deprecated.rst > +++ b/Documentation/process/deprecated.rst > @@ -59,8 +59,9 @@ risk of them overflowing. This could lead to values wrapping around and a > smaller allocation being made than the caller was expecting. Using those > allocations could lead to linear overflows of heap memory and other > misbehaviors. (One exception to this is literal values where the compiler > -can warn if they might overflow. Though using literals for arguments as > -suggested below is also harmless.) > +can warn if they might overflow. However, the preferred way in these > +cases is to refactor the code as suggested below to avoid the open-coded > +arithmetic.) > > For example, do not use ``count * size`` as an argument, as in:: > > -- > 2.25.1 >