Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1580116pxb; Fri, 27 Aug 2021 12:08:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwBjGFO+mMkU67p+KoSoyoNtrMrVAVVYat/7j1kKIUD9IlvY2kvAGbtmxrRFDqVkWvANHu X-Received: by 2002:a6b:3b8c:: with SMTP id i134mr8433781ioa.29.1630091280245; Fri, 27 Aug 2021 12:08:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630091280; cv=none; d=google.com; s=arc-20160816; b=GeBceyo7DCtsC+Xk1Ty8ri9/gDhoHzm0vcGxaROOpjvoLSrebYQTfQ512DrNrZxKr4 5B/QzIVMApIfbAx62LVYvEfz29G87DZV5LZzXsxCHH+Sc0aCF4PeF3Y3iH8hfL3+NG1C 5NxsKGeHZs5FO7P45zlcwuIJrAkV2qS5MXI0B4qnsDXKi1Jfm5subII6gBw1NdYozkmz jHagyaIl7KKl4bbOmE5MPVyyq5jqoU7Cr8BXpcf5RHaU/goxWHgH3jjvhK1QaItW5BMt X1JcXaFD+234EuPXRuxc8lBV4XDcOh286yJ/9EQLFUdwFoYS9tz8R/eeDYYJI5jSkR2t vF/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=DZ+Dh7HUtwZ1H3MJecWO7LXLeO6rU1u4VAQJhQbUNOI=; b=QR1uNO/cPLyAOh7PBZKNND/mpXHQTAn8uxOojQX24/Rj5kJ7ttgPTH29p1q4HRA7FY u+0a1bgkp1IiwM4UXdg7tg/p5+CgdoNgbR4gVS5TP1Eg16FoiUuO5McLTKpNuXcCTMbU TtDtOvwD/k0Z+oKcnf7LIbdiYIJEGSvhRek0Y5LTpkyFqwjp1BXyAsIN5D1+8j9HpyKe irJ5n24RLinuWOxfcd1n7GPdYjpU4qP69kTPhSUDHusUN4h2DcuwkY6ZWXBn8D4B3yUL d35SV+U2EQQBZRbTxeyTokNKgQmoo8RpMsBpDQK8WQgs15hUIXnpBfBTDD/QaoqQecQX cueg== ARC-Authentication-Results: i=1; mx.google.com; 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 h15si5613650jar.80.2021.08.27.12.07.48; Fri, 27 Aug 2021 12:08:00 -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; 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 S231319AbhH0THN (ORCPT + 99 others); Fri, 27 Aug 2021 15:07:13 -0400 Received: from smtprelay0254.hostedemail.com ([216.40.44.254]:47348 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230405AbhH0THN (ORCPT ); Fri, 27 Aug 2021 15:07:13 -0400 Received: from omf09.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay07.hostedemail.com (Postfix) with ESMTP id 18073181FFCD7; Fri, 27 Aug 2021 19:06:22 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf09.hostedemail.com (Postfix) with ESMTPA id DA7D21E04D8; Fri, 27 Aug 2021 19:06:20 +0000 (UTC) Message-ID: Subject: Re: [PATCH] docs: deprecated.rst: Clarify open-coded arithmetic with literals From: Joe Perches To: 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 Date: Fri, 27 Aug 2021 12:06:18 -0700 In-Reply-To: <20210827171226.2938-1-len.baker@gmx.com> References: <20210827171226.2938-1-len.baker@gmx.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.40.0-1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.49 X-Stat-Signature: xbgfsqba9wxwpwxd1pandj15ocaigmbt X-Rspamd-Server: rspamout02 X-Rspamd-Queue-Id: DA7D21E04D8 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX1+BH4zRMi41Wrmm5oI1t237jWH/vS28Tg0= X-HE-Tag: 1630091180-141653 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.