Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp414808rdb; Tue, 23 Jan 2024 03:51:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGwX3AcYdwjumXDqANKNMDqmMapiXlL8B/WPyLhuQnb9QH6n+s1OU8Yh9H+/mJVAa1okk2V X-Received: by 2002:a17:903:24c:b0:1d6:f9b8:1a46 with SMTP id j12-20020a170903024c00b001d6f9b81a46mr3642494plh.104.1706010704559; Tue, 23 Jan 2024 03:51:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706010704; cv=pass; d=google.com; s=arc-20160816; b=BE4YHVeFyDzT6MlaTuTI4lrEOAG/Yb3ta6HDOejOo6JjRFLq/CD8qyR5InJldxH4Bx CC/MOKlhiK2VJsly0lvTCP8y6IDANIoa673wCe/MWxRRwT7bpFvPLlmOjXWW67Wp6Gez Wmt7Z3Qb5XqRshgI6pmOySK2Wgs6qfECjdCuDczOvscA4kkKryX2o7z4K7UH9f5U0880 v918Qp51BRmKkMO+cxKHPt/GEN64oPcJosSuclFzJ5eNdb1HBvLu6fqCMUxuC/RJMRp1 LZyiYn9vScymqRhtX1mlvIUK1ZozV4ZKdOS/8W2rn4kE2uKGPkN9XZ2hNJTV6PymTC5N UimQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=date:message-id:user-agent:cc:to:references:in-reply-to:from :subject:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=oUCT6pNtrR1jNMyLCavBXbbBeyQ4eRbbniuXYjszy1o=; fh=a57lVPmfcxbaYwJbua9YlK8Zm2O3M/XMIsMr66FXXr4=; b=YZbQzlfsLBaUYBYglIBACLBBTqDeYCPfAkXbpFLRsEnt/uBVjTUIm0wK8P0R1mvHUx pydB9qkCmFbg0siQaILPwXWRI5FNNo2RFAfBcS7VR2mmyiLg4CPzhrA8DWVHJLsI08OK 8Doz0VJo+tCyfu5ZRa8wzxB5iCcm9eA02piq19J69CykIorhKF9u6hB6fcVIMGz66n8Z 9BUo+AAtW8Lpygs+QwkWJK6srP39DEQjDC8yMtgl1dHGrgSmUDZE7zW4g49JoDXVzKRf gNlHuAH8Ehv5JpLFohxuGfvSMAu+KBoJ1ctdbxfJvHVJUN96H6DDMlsm5igiBFNql1Q3 aBRQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dEKue+x8; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-wireless+bounces-2379-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-wireless+bounces-2379-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id t5-20020a170902a5c500b001d75e3865besi2319357plq.444.2024.01.23.03.51.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 03:51:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-2379-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dEKue+x8; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-wireless+bounces-2379-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-wireless+bounces-2379-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 8809C2897C0 for ; Tue, 23 Jan 2024 11:51:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 188A55D8F9; Tue, 23 Jan 2024 11:51:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dEKue+x8" X-Original-To: linux-wireless@vger.kernel.org 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 DE95B5D8F5; Tue, 23 Jan 2024 11:51:38 +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=1706010699; cv=none; b=G88PL/VNZBkzjK98YIb3A2GRJadgl1jqPq+M2mBhSQBz9CCcTDUt9liXdkYH08L6mi9GEXxeIwBVuxBe4M1jrXWpRbGfQP0uQSL9msO3o5nN0C/8kUwxEhfXBHp6w4Tb4o3jS/7RAdrNRzZYB6iUvxNIecsh2A7ICzwWEfR2IZs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706010699; c=relaxed/simple; bh=eVteaCDp+KI9ue5dP1Jh4rwkWPglMdLIUPjw2f79rnU=; h=Content-Type:MIME-Version:Subject:From:In-Reply-To:References:To: Cc:Message-ID:Date; b=c6Qcpm4WRpM2Yu2pN2uXj/0+MjG8eofZx/w3qgW4aVmUHeUyK0ASfv2Bqd+8Ecf4kOu/TFgGaaP6GV7njm+lYT9a84pOHjQfQ4x7GiUYCUPbN8jqCJkygLvmWJDcOHrGoi+c4KlxBImxvTaZyybFZzs76aO0xWuyBSWW+A8P8wQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dEKue+x8; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6494C43390; Tue, 23 Jan 2024 11:51:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706010698; bh=eVteaCDp+KI9ue5dP1Jh4rwkWPglMdLIUPjw2f79rnU=; h=Subject:From:In-Reply-To:References:To:Cc:Date:From; b=dEKue+x8GGQMHmrkSO7aEgzamumcgotpPCrAMMSIGfFIst3qTfM8y13pFWL9NLe0g OPDfSuJEb1jMPU1mAF4GsgU1YSDHH4OU8BDPxpWXcESDBxVlSFiKdVa84+1A6jtJdl fHocw0xyIv2LneahdG1MGsfval0n6NC31eNszDn17neLK60XdfrvEBL04RAgebycyf 3n86YK168Q45/CkTBHMX7yvoPhK3K5fL8p54n+S5l/cM+nJjuZFTGmIKfMKT9U9JSR Z0/CMoYn+GyjRsTjtCBW0mkxp4rt22OpWC01wj5xU+iBE/Gu9vsOt8OsP3JGOT5x2g IKkqzJh0v2a4A== Content-Type: text/plain; charset="utf-8" Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [PATCH] wifi: iwlegacy: Use kcalloc() instead of kzalloc() From: Kalle Valo In-Reply-To: <20240119171655.7740-1-erick.archer@gmx.com> References: <20240119171655.7740-1-erick.archer@gmx.com> To: Erick Archer Cc: Stanislaw Gruszka , "Gustavo A. R. Silva" , Erick Archer , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org User-Agent: pwcli/0.1.1-git (https://github.com/kvalo/pwcli/) Python/3.11.2 Message-ID: <170601069480.3962299.16944652749116926438.kvalo@kernel.org> Date: Tue, 23 Jan 2024 11:51:36 +0000 (UTC) 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 > Reviewed-by: Gustavo A. R. Silva > Acked-by: Stanislaw Gruszka Patch applied to wireless-next.git, thanks. acf868ff60b1 wifi: iwlegacy: Use kcalloc() instead of kzalloc() -- https://patchwork.kernel.org/project/linux-wireless/patch/20240119171655.7740-1-erick.archer@gmx.com/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches