Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1504538pxb; Fri, 27 Aug 2021 10:17:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywJS4E17lsp0FcsBJLSTT7vPt6wDpoYGoVFqXPaoe/zuGjE8P2XQZHfcrFoulHr/X5MTkq X-Received: by 2002:a17:906:31ca:: with SMTP id f10mr11493525ejf.73.1630084633208; Fri, 27 Aug 2021 10:17:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630084633; cv=none; d=google.com; s=arc-20160816; b=qq1q8yprKNA0uVepa2271lCDGgAhTvMWxFWef282NFAkYvnkUq1TuZbXRi0phLxtOE 356Uw4PPvf/vh63k9IctlXprlHMrrrKskW1muDro198YIpE9c6JAWZ/TD+9CoDCp5g/O 8ivwIrfCVjhWhuG4jNH13rM2HVCM+aMdkd+rUKFmm8+BEVHyxB1uk6d8WlAugHIh1tML jqiLqiiKSGW925xXUuTnRm1/9bFQ6xoc+9xNrxQBC3G2Jd/aODp6TVLbavsKrJ26C+89 azzrBqAGMBj1NBSWdz4K40KCIZ/HoPY+3wuA8AC1FWyqfxIN6pdBcpD9WMB+g/WOrg0b rWWg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=YGrt/tZqC6Fgg1MGVMuVmS6neQk6AN33ybHRfOyG7U4=; b=oyVWKL0CGxTGhF2dfDUSwHgLlHYQxNCzyk+y3HaJ1lqM5C9Gj1yqd8/HT60wR3ikQa 9H5+dggTcV1eHWghLLS9oSEAYpDgZI9nrrLBkfMyTmXwRR/GQVZ60E4k8L0Fbt2uV1C6 bPfDaVdboEoYd7i2upQrMD737jiVCdJ+MW8a+quNzEo3pgGHjyBBsq+iiVLVvRPbgaLq jo+TtQUDqfXNld0FucSeVnP7Hevnlw2GpjGrn5dDx6vRv53zyZxDwH/HpwmhEr5vJmkX LpJdsIF9gf3b35VvrtGZp1Jtz/TTNc8A89KggcUFQfHLGAtrU8egyB6NnG0HOtoa+hum 8Ieg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=HexiUg1W; 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=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z10si7122624edd.2.2021.08.27.10.16.50; Fri, 27 Aug 2021 10:17:13 -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=@gmx.net header.s=badeba3b8450 header.b=HexiUg1W; 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=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236084AbhH0RNt (ORCPT + 99 others); Fri, 27 Aug 2021 13:13:49 -0400 Received: from mout.gmx.net ([212.227.17.22]:56999 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235695AbhH0RNs (ORCPT ); Fri, 27 Aug 2021 13:13:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1630084370; bh=YGrt/tZqC6Fgg1MGVMuVmS6neQk6AN33ybHRfOyG7U4=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=HexiUg1W5x2Jo15hbQizUtOvWIGA7i04Ksg6C4jYtc9xdf/4EcF+Hr5T+y3uwh2H+ nnkZ+QOQRvYtD/qi1VtgNc8k+jlMk9UcdGH+PxQhFIhw+Jl1mFyaEDoCRGzSF3YIQY tG5kWehi9jn49B5WbDbQ9g0/CCDKAAJZtZr6vpMM= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([79.150.72.99]) by mail.gmx.net (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1N8XPt-1n60o70u0H-014Vvb; Fri, 27 Aug 2021 19:12:50 +0200 From: Len Baker To: Jonathan Corbet , Kees Cook Cc: Len Baker , "Gustavo A. R. Silva" , Joe Perches , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] docs: deprecated.rst: Clarify open-coded arithmetic with literals Date: Fri, 27 Aug 2021 19:12:26 +0200 Message-Id: <20210827171226.2938-1-len.baker@gmx.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:I4VWPP58QCGSuKHAt9e7f4B6GR0oJLIbfsgC5vaEc4Jc+JHrAW/ M8cvyz1w4tH1262z1GzwPm7Yy/QsCM+Vv0UAV7x/DqOpdjRa/hRByyP3Xzbyi67knQD8aek b/m8TnEg9IQROi9C2I+iIjWx20VYjJerMA2GtIpeY2noVT6Eg4G1DQH3ncBfar9gb+6SNM/ jwcjwJobLqQzVzi+IC+LA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:eJgriy0mrwI=:BRr/Xj1/Ce77Qxj3YGdtWH 900bbVsHm6mQeIWxP1zoB9sgWuq1885wFtslqEN/+l9wJxXfaqyuSDE9wvAT2tWOhDCGeagc/ VlfRsgzJQr54TnB8gELEbfCWRNPeJioRovPh0znkMooyZkF0D/ZfOYD8wclbvq3Un4NrGlOR0 IOx/UjqmDrOrZ7wOiCppKuvfb/hW/8GKAxXvUAg8l1pZz88/gmBsLgsdC0louSCm2/rLM//+V dWvvYh+OnmkgcBnIw3pVZmQvBoFJSNbAFByOIv0GH37kp3UGmonNtk+GHvW/fcEq67AXZCd/c xNRAGUcCxKzjEyYEKffDQVfK1ANPMjdTOZbGunJaOGlfzuTNbZ+BA+jkJYlGukrwO8VfiDKDd Y27ly0uCWBcixtHZgrCaXv5jSRL9Y9MmIgbCvsdHx0R6P/nGBMQOy726KonYpsOClhdoFgWZY vdAG/PbNRyQgRUikzqCB6w7zA/lyzm5HOKtDi/O5cikXMXSCgiJmEyGwAyjFYdMoyDQ99PPaL ZYPUTMjimH8qeUj8Twz1pYydnX2G/c3dYC4i4+8K0FbK3jQ+CbnWAa1jwvm1IgmOe9Khu/xbj +TqUzfJSimkaP6kjlEurxyslOiIRLmI3XoelrXcDNPQmItrd9Jy0hcxxvo9RVNP1jp5bqUXrT d8xM5IxrMLiDxw23aUKi84aQqw0l56OeoU4fjsz5IUje3QJQk5e8e+4DTaz2gsGuaJ66sS8TQ RHhyxP1syRFD6vwuUsjghqjW3CeCTZkghqKl3fcFIBZIBCYgF7dP6qhcs/cJjBCFL7xM6Edvx AfEhL9+U9AxsvuPNjLd6ilGSziwDsImiCncZFN1JbT50oZKQfI5e/LIr5qpW8veg60b6wEmut ELPlaLfSCOBaFluHWvY4Hs4Zu8QIXCHAiWPfWI9EOBCeWrBDji6hbCg8ktpjShbTm60kf9HM8 QLU8wmOMoQ/5nMPw8Yjfd9u6DhDrdrxzkyryZXjsc4/HQWJsWZckcaTpVcgCgT1kuZL3CqzuK OBWzcAVfLKlQ5SYxGc8JN/Q0D8EqCYFWh+eNUiutQL56GRL943xFGlgogzhfghmtmvbxCDuOk qPHbgb5oqk0DIqJN4/X4I6kJ1a22yoKAAMjCk6iOEmqUppnS6R73Ovmgw== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Suggested-by: Kees Cook Signed-off-by: Len Baker =2D-- Documentation/process/deprecated.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Documentation/process/deprecated.rst b/Documentation/process/= deprecated.rst index 9d83b8db8874..fdfafdefe296 100644 =2D-- a/Documentation/process/deprecated.rst +++ b/Documentation/process/deprecated.rst @@ -60,7 +60,8 @@ smaller allocation being made than the caller was expect= ing. 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.) For example, do not use ``count * size`` as an argument, as in:: =2D- 2.25.1