Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1668979rdb; Thu, 25 Jan 2024 02:38:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IFz6AcCfJexP/cJfkKPuFd5xdOgKGIHPpkkzveegfVjhwHQNU6r0Vk7iqeSw6WtD0s3YIPy X-Received: by 2002:a17:906:f74f:b0:a30:6276:3cdf with SMTP id jp15-20020a170906f74f00b00a3062763cdfmr422807ejb.140.1706179131431; Thu, 25 Jan 2024 02:38:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706179131; cv=pass; d=google.com; s=arc-20160816; b=qc2/YbaBtXS3llLI/srWkQdGnpWqB2LSMksRCNrmSfEcGq9DWBNMaE1LJeUKPcS/k6 McBG/K4eu7UF637Tms1M+cFbX0CjgBgwxnpaJz3FoG/HMqOEDjOulHG3xjqXCJ+l/x5h mWotIHCu9Pck7k4pAuHWEao+N9Xxb5nHatvtqqpTCpzlTdABDpoowhGnT4CXBUXstjFS 4iY9rvqomUj2sh+V8BRgBlF+7H3tUFsKKnhIS7TpIFgndqV7VRdATxGdq+qmccFLDkuC ZWiUSVZAvgC5suLpOCwKVkK/Kyp5bF5VOLykxDGV8Jdx3TziWcARsBONQipNNrOG9yDW kydw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=aJFfSIt1uCsYZfXjvT7D3nqG4UcJRPxhEJ1wvYpfdqQ=; fh=eXYnGbSRzj14tHnZpBUTilEziV0S5+GT1qxu4e2oFKc=; b=XYp8MQ9ygm9+kHK9VQl/O4Un8GPDKRv5udrKrctrZWYrts6eMgMIERBtDXf5NdV/kB 3RcPmYioMu0yzgeG/vya89+/Cnh6Z5Jc5lRRXyQdX+lJW7M2WQmKCTqwYxQ145SaWfMN qx/d3S6oBPhBdorsTcPwSatDmJ9Ls27VhBJ8JSBNbO8oplL4VnijzR0LUB0nk+BpDiwa S3iVYImsSB67o80k9I/didwmHRmIxVVq2x0vz+hbQCN5wAFP6v3k2DFGb+RnkPkDEabU vPJMpvzSJQVL+QCwyLjxfGY18arxwunzeF6Y+P9X/MGIjnIPbzaiKIv54llp53onG/1W SNoA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jPmG+InE; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-38403-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38403-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id y27-20020a17090668db00b00a2a2c6da5acsi803283ejr.93.2024.01.25.02.38.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 02:38:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-38403-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jPmG+InE; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-38403-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38403-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id DD9EE1F240D9 for ; Thu, 25 Jan 2024 10:38:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0D15A28DC4; Thu, 25 Jan 2024 10:38:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jPmG+InE" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 31DEA286BC; Thu, 25 Jan 2024 10:38:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706179109; cv=none; b=EeeUyPoV1UBMWb5mTcUd2xs+t+YqT3ejQfeIb5ao4/6sNp4y8uQz6xlC+lR9nDx4hxf6u8+lNXJKR4LEJtSqi4Cf65F018ZtWjo00n/kXjdnT3iJEslkeChyZtxQWqgAEdAHcSRuNjk38LXza0V6++ChjO66qUbDpv12khIj8JE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706179109; c=relaxed/simple; bh=N1jVOSNlM0yJonXxmcq0nNV6L21AE9zFYCH/FyRsngg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=RbuJtKmqWCjyJnGUK2wa8TSAUzO0gWWvdxkASbctc0CvLKSdoZkqFIexbHE+QAVF4XtKP2kIDNgCPo0WLDMLBtayPIokHUIPySoTFJhtxKUZTacVu19tuaV7UhHPFGzZX74hcgZvFud9eQs1f1q09cQS6OsbBAiw87rdltVjRWo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jPmG+InE; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00E34C433F1; Thu, 25 Jan 2024 10:38:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706179108; bh=N1jVOSNlM0yJonXxmcq0nNV6L21AE9zFYCH/FyRsngg=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=jPmG+InE//r1LeUk0J19ONKWSo9DOVR9btHeiHWdm3aMkvVl5kYe1wSfLMkLgB+8k J6GpV7LFkvD2lQD7w6N6vZjhDybYSIGzUVjwg3EL64pXBiHDsVNWL5jX5/Vb4g3D7L CJr+NylKuGWziuoVs32/vABe0pbA4eqLiuyA5QEutf0P7sw7QANYRLxo0kKT28YnzV 6sR5w7oDg7oK+gqAM2xRY5plyMojpzN5QDkXwUMn9RdIb2zIlml/qUg83kBc5ggitG gQOoqD3g2PWnUKvqFXaU532MdiAVFsEMkYpo11K5jJp49QqwVeROhI0J4Cyft0rzWd K/KI/oDQki59w== Message-ID: Date: Thu, 25 Jan 2024 12:38:23 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] accel/habanalabs: use kcalloc() instead of kzalloc() Content-Language: en-US To: "Gustavo A. R. Silva" , Erick Archer , Marco Pagani , "Gustavo A. R. Silva" Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org References: <20240120151028.11092-1-erick.archer@gmx.com> <91e87233-3a10-43d6-b850-9cac083913e0@embeddedor.com> From: Oded Gabbay In-Reply-To: <91e87233-3a10-43d6-b850-9cac083913e0@embeddedor.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 22/01/2024 18:45, Gustavo A. R. Silva wrote: > > > On 1/20/24 09:10, Erick Archer 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 >> size * count in the kzalloc() function. >> >> Link: >> https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] >> Link: https://github.com/KSPP/linux/issues/162 >> >> Signed-off-by: Erick Archer > > Reviewed-by: Gustavo A. R. Silva > > Thanks! Applied to -next. Thanks, Oded