Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1603360pxb; Fri, 27 Aug 2021 12:41:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxJCVcl2wO+6MNTll5VJjhlI3GXsrozPjMWBgifRPO+52DJrT5MudvXVkd9xbEW+u3aTVz X-Received: by 2002:a02:76cd:: with SMTP id z196mr9411447jab.76.1630093294385; Fri, 27 Aug 2021 12:41:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630093294; cv=none; d=google.com; s=arc-20160816; b=TZ1LU3XC/YSXj99rB0qQnO+yi2KLybM9LYrwNc/DL2R0gKHYmg6I/jw2ABdjk29q3W gXQoVvEjM+bezp1YejGpY3OyJxO6UzLmRhVZ9oNQR6LtSv4zIBiZKqEZ5CjPXiQpaIC5 SeviWS6SX1lYEO9nctf7IQ0cSfjoJ4dn9zQ7sipKvvR3FdwHo2PTKYNcyVYSTB/3g1Sq GZVAShh+gk96zHhzo/Bm7hLgEWGNTyetwP6kT5iIOCScbedFgeGc27fdeuXNl6rZu74p b5r1yhabzipkFHXrM/CAwf4Bguci0oieKdpqejgVivmntj/p1RqOdB5wElpsLNVqfnCN TkfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=aQ+xyVdAGvAkJszGSEZ3M6/27HiFqk27YJnKR6c1e0U=; b=bU9yrCMm0kIu4y+O7T6mGCWJ2WYTFEy2Uwhg11An1/WUTQbG6dzUX/Gvh3wwp1YLrB AbrMEOCWfv4CaB85FaF5SJ1WnPAsVKjTnCCI5S8wFDOXUMsaIWgO8lQ/YY0eXjgpM/eJ VBY9co9EV3+tegwgVOinKxme8A2mZDXwynyRBT1QG9WlCsUSD/QhkD+guyb46ARiGDnl rejbSceHngW9QMKj/VaFkDjzx1UFTm5RijHVbO/itgrkuiKumI1ywXHE3dIC0ojdN4PX ik9kascKfcSol0sCruQX46tVHSv1hTJpoLl70hEl1IXcEk2nNGEVjjg+zuyq0+p9e0Gz Zn9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=JSlpIlng; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b9si8394928ilo.64.2021.08.27.12.41.22; Fri, 27 Aug 2021 12:41:34 -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=fail header.i=@embeddedor.com header.s=default header.b=JSlpIlng; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230446AbhH0Tlc (ORCPT + 99 others); Fri, 27 Aug 2021 15:41:32 -0400 Received: from gateway36.websitewelcome.com ([192.185.200.11]:16736 "EHLO gateway36.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230005AbhH0Tlb (ORCPT ); Fri, 27 Aug 2021 15:41:31 -0400 X-Greylist: delayed 1247 seconds by postgrey-1.27 at vger.kernel.org; Fri, 27 Aug 2021 15:41:31 EDT Received: from cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7]) by gateway36.websitewelcome.com (Postfix) with ESMTP id 58C00400CABFE for ; Fri, 27 Aug 2021 14:19:48 -0500 (CDT) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id JhOGm1SVJ7sOiJhOGmWsvQ; Fri, 27 Aug 2021 14:19:48 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=embeddedor.com; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=aQ+xyVdAGvAkJszGSEZ3M6/27HiFqk27YJnKR6c1e0U=; b=JSlpIlngwa/IPreF54AyFuR7UT Y1K3XLtG6XKI+ZFWnF7VbaNzHUPSij3zWFhxqMJjkjQx7clXPLG60TSnQs6r+VOFRychc67nIzlki srEq5y4gD4VtYuSV+Jb2MdsSZK7vglXpc8PYfM4mp1A7H8rDSSzr/aN+t/LOQDeEkTWchAHSOtmw6 JOab9TqTJpayHvMFbJ9DeJt8CqlWa4VtTPMUbuurHvS9+Ts0VXFzMlH1XNqAzTIr3o8U+xHoehWQS jJYUGc6KJTHgrDMR43aNUhNzg5IV+tYKnaA4BMVeiNP3uX3idaFiw10vxvDD5J+b6qj7UnP3daNEL rp2nkDSg==; Received: from 187-162-31-110.static.axtel.net ([187.162.31.110]:36872 helo=[192.168.15.8]) by gator4166.hostgator.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1mJhOF-000Q4P-NP; Fri, 27 Aug 2021 14:19:47 -0500 Subject: Re: [PATCH] docs: deprecated.rst: Clarify open-coded arithmetic with literals To: Joe Perches , Len Baker , Jonathan Corbet , Kees Cook Cc: "Gustavo A. R. Silva" , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org References: <20210827171226.2938-1-len.baker@gmx.com> From: "Gustavo A. R. Silva" Message-ID: <9a338127-0b17-fa9e-96b6-578193ce96f4@embeddedor.com> Date: Fri, 27 Aug 2021 14:22:58 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 187.162.31.110 X-Source-L: No X-Exim-ID: 1mJhOF-000Q4P-NP X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 187-162-31-110.static.axtel.net ([192.168.15.8]) [187.162.31.110]:36872 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 7 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/27/21 14:06, Joe Perches wrote: > On Fri, 2021-08-27 at 19:12 +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 math idiom. >> >> So, clarify the preferred way in these cases. > [] >> diff --git a/Documentation/process/deprecated.rst b/Documentation/process/deprecated.rst > [] >> @@ -60,7 +60,8 @@ 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.) >> +suggested below is also harmless. So, the preferred way in these cases is >> +to refactor the code to keep the open-coded math idiom out.) > > wordsmithing trivia: > > 'keep out' is difficult to parse as 'keep' is generally a positive > word but its meaning is later reversed with out. > > 'avoid ' maybe be better phrasing. +1 -- Gustavo