Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp2023945rdb; Sun, 21 Jan 2024 04:22:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IHA7FkAHHFkLN72LEjDEavzFJMDWxKszEGi6M7JBrtHj12MgpbpQufVNNTY+gUjFKip2Wrv X-Received: by 2002:a05:6214:4018:b0:685:2d19:783b with SMTP id kd24-20020a056214401800b006852d19783bmr3523604qvb.83.1705839730521; Sun, 21 Jan 2024 04:22:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705839730; cv=pass; d=google.com; s=arc-20160816; b=iQTveHI5Yc3ZzhIgz55de0dGi0nTxja32drhQK4/BZRQkhIervcrw4Mxr3I0d2Y5FX RMFm+pGQTS8bz8Fj8+Hg18yvT3mWkJlwY8hmMT/SRZ0v8WcDKBFREE5oSeM9uUzS9h4D kYZmjRBvZLZYuAifsWIDwCRkzyLQFPY1wBwyWWgxwa17lV5wp5Q3MC0T3ilMqFb9Y1ut FwHJeJxzeeTYqiAEwu2QO9kbmxX5JSJgufhQfFGFR4i1K9b0TJBpDCaqxhF2RbBmpHqH rhTFnNPt1JPBH2QrxMH0Yj8Zcfr6TfsKDBWN258G/N4YXQEips/n89x6TcuHNU9gfl7h k2Hg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=xTrv3uIUbt6UuXd8Zd/SNP2Yl4s8u6K1/Z6BTJI5wkQ=; fh=4y0VtO+TlGxMUbDECGr5Hi3SzWGaPCoMvkjxSy5T/g0=; b=uv4LX2TZAZVEQnWz9DB7Qf0wysG6OAh10go3vWAwTpe0k0WbJkeEisBcuMwwmBSpo8 KBLO9a9biRDmO5MjLfN6XUGv1QNpKBJS6xL4Y9cj5cX5a0BJ/z0bKmMA8qhp42gCh99I l+ctHCfc0YFOw+SNKS4VJY8lbngOFnMuPp0JHvnKVaHOrIPjtaR7Xb8wlgaxFjyUezGq bXeSWUafMTITIlLOkK9BSnYWBSPgPM8A3rhlPn+QiUr5taT0w7klJBRcZ4xKaBryTLmy SJHPYZKbSaoYx6WbdyujIFW8B7m6Z5mwjDhM5eFrINNsy3nohwxuhJQVTaVCdT4dgfzv F+aA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@wp.pl header.s=1024a header.b=GakjS08x; arc=pass (i=1 spf=pass spfdomain=wp.pl dkim=pass dkdomain=wp.pl dmarc=pass fromdomain=wp.pl); spf=pass (google.com: domain of linux-kernel+bounces-32043-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32043-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wp.pl Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id r5-20020a0cb285000000b0067f2bff6290si3480087qve.62.2024.01.21.04.22.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 04:22:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32043-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@wp.pl header.s=1024a header.b=GakjS08x; arc=pass (i=1 spf=pass spfdomain=wp.pl dkim=pass dkdomain=wp.pl dmarc=pass fromdomain=wp.pl); spf=pass (google.com: domain of linux-kernel+bounces-32043-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32043-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wp.pl 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id F3B571C20BA8 for ; Sun, 21 Jan 2024 12:22:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 30BE036B0C; Sun, 21 Jan 2024 12:22:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=wp.pl header.i=@wp.pl header.b="GakjS08x" Received: from mx4.wp.pl (mx4.wp.pl [212.77.101.11]) (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 86C56273FB for ; Sun, 21 Jan 2024 12:21:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.77.101.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705839722; cv=none; b=F2T0wvVylWYY4PmmV7IoLqYZU6CH8m97/PtZA/Cd4c7OSmgKLzMlUVyN6qasJPTrwm2vSDKtGD8XOJvyrvk5Pb2z6Nk9WlyE1OA8eEDBHoWcQgtO1uyYTvtFvd4oX/DVuWBvADQK6u6KtZGQv/e3QOVpNVZCLFTaCKKigDx+HCM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705839722; c=relaxed/simple; bh=o1t6NlrqghyU9rGMUDhTLRcjKyBZkUM9u1OELKMcUQQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Dp6UGI6KDXrs/mVzOTIKFGwl5EAkq9zETN9cc01AQ0+1QAeu/Z5THtOpKrdcxFwrFNsFABJwwuzBk3QA7mc4ioiRjyTFLz/0iOtXqqgd66WE3FUnMNLXQKARykSPl6CO0DLPDYBxb6rTIDUqYU6Sf7YsBxM4UT59PruK58YAUBA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wp.pl; spf=pass smtp.mailfrom=wp.pl; dkim=pass (1024-bit key) header.d=wp.pl header.i=@wp.pl header.b=GakjS08x; arc=none smtp.client-ip=212.77.101.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wp.pl Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wp.pl Received: (wp-smtpd smtp.wp.pl 30448 invoked from network); 21 Jan 2024 13:15:17 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wp.pl; s=1024a; t=1705839317; bh=xTrv3uIUbt6UuXd8Zd/SNP2Yl4s8u6K1/Z6BTJI5wkQ=; h=From:To:Cc:Subject; b=GakjS08xiD3ByYQHOhS491W/hV1pCZ0oyXWx5lYFdSbHZaxa0gC1shzQh0dLP9evs tAOTN0CcpJ5XUc+7OkBCLF7fpV80V4MTt0vhyUO0Nq/E70irZ4m2z4EdlWr4ZWkb7g jQ1R5RsThmRD4jqKpOx7Be1ogz4bE8C6p+u/YU0k= Received: from 89-64-3-131.dynamic.chello.pl (HELO localhost) (stf_xl@wp.pl@[89.64.3.131]) (envelope-sender ) by smtp.wp.pl (WP-SMTPD) with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP for ; 21 Jan 2024 13:15:17 +0100 Date: Sun, 21 Jan 2024 13:15:17 +0100 From: Stanislaw Gruszka To: Erick Archer Cc: Kalle Valo , "Gustavo A. R. Silva" , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] wifi: iwlegacy: Use kcalloc() instead of kzalloc() Message-ID: <20240121121517.GA52639@wp.pl> References: <20240119171655.7740-1-erick.archer@gmx.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240119171655.7740-1-erick.archer@gmx.com> X-WP-MailID: 7942f6e91f609b762a6db31f482acad3 X-WP-AV: skaner antywirusowy Poczty Wirtualnej Polski X-WP-SPAM: NO 0000000 [YQPE] On Fri, Jan 19, 2024 at 06:16:55PM +0100, 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. > > Also, it is preferred to use sizeof(*pointer) instead of sizeof(type) > due to the type of the variable can change and one needs not change the > former (unlike the latter). > > 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 Acked-by: Stanislaw Gruszka