Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp3981266pxb; Tue, 7 Sep 2021 11:48:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwg1ngeDUp4p+BvV3w8a1XcP8qxoarFtppguvLFyz6/9w2oL45cz1LIIf1cK4hmDI1l17R6 X-Received: by 2002:a17:907:3e05:: with SMTP id hp5mr19869687ejc.527.1631040520759; Tue, 07 Sep 2021 11:48:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631040520; cv=none; d=google.com; s=arc-20160816; b=nUva1QZwX2obIOafEXRRHH9gXhdENZ1xrZfrACsWhTgm+Hdy9Mf8ZPv7UZ++pc8VAz 33Fnn+7fR/ZpGXXFBfBgK6GloClj1js7Fy7mIYjhERWo2NvF5X5U8r+eF3/JdAEyS/VH SRA7X/7XvDQfmY7YUgTww4b77jswO7hx85V4sifahNhtyjuJnIBUIfuck8iO2XrQsJe0 czEjcXeZnUIY6nPt5EPiiRsynLvsGknmk4HH+HMkiPpTHO+3BaST/IGH3f4LCyiMfBRp CueLvEujSMltBjm8kYVgh/fTdlHyX7Ky1ZljxN7CyPQwnyrOqBrZVqIX0RsRbRJqJo8S Vu6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=fo01n+oht3lwEJyeQrCoe6KGpWuXH6sm5NGKluVcVIg=; b=oQ19oK/bYjmIYFHZ6QtzzrbLx8ZJ3sIj+xQ13KVAvFCodeNOk0dFlsSfedmcop62aH FJcKeuy/k0kx/om6mz5fWdcbfklQ3QjUGw6ZmuZRO96iZjzOJWL/3geAEue6nppTn5ey Jt9V+mtJu7h2wu3ZS8j/At+XaKkOfc3uyI1WARpLDUGR8hHj3UJLAHeu8uBgzbQ4T6kw zl8t+8SUNqhQWdMU4mlVW8n1SnbiOZBpH+KA/XjCM6AiaTKw3U6tFGrn7eU9gBO9XyGH a+Gw5e9MkZqHAq4N58/NG1Sv5b+akFnIGbsuhQzjGEYDNMe1zLM1r1narq2T8y1sgou/ zOYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LFIdP+U7; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p12si14082092ejy.328.2021.09.07.11.48.17; Tue, 07 Sep 2021 11:48:40 -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=@gmail.com header.s=20210112 header.b=LFIdP+U7; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345278AbhIGQ42 (ORCPT + 99 others); Tue, 7 Sep 2021 12:56:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234571AbhIGQ41 (ORCPT ); Tue, 7 Sep 2021 12:56:27 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3E1CC061575; Tue, 7 Sep 2021 09:55:20 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id j16so8646709pfc.2; Tue, 07 Sep 2021 09:55:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=fo01n+oht3lwEJyeQrCoe6KGpWuXH6sm5NGKluVcVIg=; b=LFIdP+U7Iy++SMozkDbn1A+ei8rDjByZWsek36sc+DPewZshw3o11baFsUXh8NxHD2 1SCt+C6R1JVqpf+i0FwudI+7/TxKXjMfNIOOxvVXjtGz5F4x7jsC5VLaNV69fi8oFuZv cbn1mZz4bNPQEjz/rOldefzEBxFq2TyX7GKuT6B5qNiXHyMeY515Prcz77pQrPs/oKaw UsH9r6D4ptR1fpeS0MCTOy+0yqyLQjDc/zwTK4+tZgjVCKNTFLyeRa2K6udHvq1vE5m9 yl3L2Lfs8PLKc8tO7pdhHYp9qkuNAtRzZpqerJP2zNFKhzghKl7eN07W2c9VYdAwq/+L mxqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=fo01n+oht3lwEJyeQrCoe6KGpWuXH6sm5NGKluVcVIg=; b=Nsb4pTsDLD0VQXkg8KrqWpob0enCXR9sbjlv3oAJWsPsh3nieLcxl9sBjINbu6zktb PTgtVwdJjrNKUDKciSFEqPO9YF0LFf0rN3iqmXOtBIc9unzNps+G2kqB5qjnua91lmC6 wQSuv3/LwRlwMDfthL1TpwnSQtzghuwVVWJ4DDs9zgkusED8efNJoqgZAvgEjaQCaZ2G nBCwadl/WchtCBRwdSr3OZ8ypPdzL4XYR6pDB3eeR5Lyg/lr27bSCA4TsKN9o+cVQrcl Dgz3zYHbDA8Bx390cqvMf3sR3GUIeBSUUK2tdBfSJIRPDAhtG8vrOfeUd2Lq28hoUMWq cKPg== X-Gm-Message-State: AOAM532nMF8ezxryhfEOupe8jHE1u22aCjEWp596C1q444gBcIf7bhgv CY55AT2iX5iR29uHyuMeJbs= X-Received: by 2002:a63:704f:: with SMTP id a15mr18037290pgn.120.1631033720601; Tue, 07 Sep 2021 09:55:20 -0700 (PDT) Received: from [10.69.44.239] ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id gw21sm2865041pjb.36.2021.09.07.09.55.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 Sep 2021 09:55:20 -0700 (PDT) Message-ID: <8edb44da-87e3-7e81-c9a8-54b27dde2fc1@gmail.com> Date: Tue, 7 Sep 2021 09:55:19 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.0.3 Subject: Re: [PATCH] scsi: elx: libefc: Prefer kcalloc over open coded arithmetic Content-Language: en-US To: Len Baker , James Smart , Ram Vegesna , "James E.J. Bottomley" , "Martin K. Petersen" Cc: Kees Cook , Hannes Reinecke , linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210905062448.6587-1-len.baker@gmx.com> From: James Smart In-Reply-To: <20210905062448.6587-1-len.baker@gmx.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/4/2021 11:24 PM, Len Baker wrote: > As noted in the "Deprecated Interfaces, Language Features, Attributes, > and Conventions" documentation [1], size calculations (especially > multiplication) should not be performed in memory allocator (or similar) > function arguments due to the 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. > > So, use the purpose specific kcalloc() function instead of the argument > count * size in the kzalloc() function. > > [1] https://www.kernel.org/doc/html/v5.14/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments > > Signed-off-by: Len Baker Looks good. Thanks Reviewed-by: James Smart -- james