Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp2131287rdb; Sun, 21 Jan 2024 08:42:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IGStV9QHUZDcYsBcTGq0UMAMkFS0her++ujESzXtDnn5Lhogx6esaOKQBCmBHdnbdsPO03X X-Received: by 2002:ac8:5ac9:0:b0:42a:2fb0:491e with SMTP id d9-20020ac85ac9000000b0042a2fb0491emr3728561qtd.29.1705855324923; Sun, 21 Jan 2024 08:42:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705855324; cv=pass; d=google.com; s=arc-20160816; b=hjansBSNQ/iDFaj7M7w/sCymrALgq9+65ix8lBC3izeybuiDivMhXmmOXqjFA5pVpG Nt9Qe/oOcTOCRt/wEFd57UTNQHY2fz39TEr1NLdd5cSwwKq7ognzdYE32frpwrgrDOtt gqFecRrxtJDucW8fbuOMJtgP7ys+Id7rxmkGvhJS+YewH30pIp3BTNdhprZdJTCg3PqW BNtUxmgIrDorJv/6bK/AJMW0NqM3P199pzpAITsYE7q16vAxqRgQlEgop8hQ1+g6P2Xv Cf8v7vuGD9xdkiOe5KVZp5Pn/G7CFA8fP4mQHJ3uG4RLY4rIFKN6aWEJISsvpUfGM9tP w3BA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from:dkim-signature; bh=jWxNvTu3VRKKkJS9ktve/6yX4KuqNsInHVLQP2tORBs=; fh=3LYLj704jOD9KSKbokSRodynex4ormnaUzp7E249wnE=; b=TQ6+cdxJKroa3SNNAQKvAMTKDM8iqLTpeplvUSb6b26x960AjrjXSckLcXmhtvlpPN fziiqNoUAQhI714VcwOoAPaBT08qbjiiveUISKZaVOu3Wu9gGMVkdSjy4tYVesbtR3gJ 1PNw/YUSMS42RoCwX/ssai9opuMBHWJAneGfr2vhc6ZfD1DCfPAT0MKNno238Jc8QPOl xQMFqxBPxJg8Ujr0jYAwG/AZisZx6KoX7tTUAM729wqsjWILiWDc23aBwxaxUs3yMBjX jG187L/daujVupSKkpozcsKQQ9hNhYsECPolkck1YEm57k+kGIGliqD3uM2YS/psXfhZ is5A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmx.com header.s=s31663417 header.b=plKXPz+Q; arc=pass (i=1 spf=pass spfdomain=gmx.com dkim=pass dkdomain=gmx.com dmarc=pass fromdomain=gmx.com); spf=pass (google.com: domain of linux-kernel+bounces-32117-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32117-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id bp17-20020a05622a1b9100b00429fb2c6591si3756954qtb.575.2024.01.21.08.42.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 08:42:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32117-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 header.i=@gmx.com header.s=s31663417 header.b=plKXPz+Q; arc=pass (i=1 spf=pass spfdomain=gmx.com dkim=pass dkdomain=gmx.com dmarc=pass fromdomain=gmx.com); spf=pass (google.com: domain of linux-kernel+bounces-32117-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32117-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.com 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 AD5A31C213B8 for ; Sun, 21 Jan 2024 16:42:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BD3AD37719; Sun, 21 Jan 2024 16:41:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.com header.i=erick.archer@gmx.com header.b="plKXPz+Q" Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (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 6378A381B9; Sun, 21 Jan 2024 16:41:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.21 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705855314; cv=none; b=Nl3epM2FUZqzoOeJR4/fad2Od8/uKvqfv2ADubx/AdSpXGE0XEWy6BKDjohSCTtRCIvBl8VfNP2s3gk4Aa7FWXu8ckisYn2KzXKts6yT9H4sxUJzBkXppeA4B9A0+SlJ4UytIWWjSCLQtEz6in+Nz2qjIAYjh/PeidnOLzsOJ/Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705855314; c=relaxed/simple; bh=45wkP8U/iOWMDIyqAxusjLpXiYYeRC8CCOH80xeHkDo=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=rS/8px1zQuBX7SKDtfKEWM33Io7QF1jTugrtS2Rx8rr5rHN5JVI4zRgT3j4aVRSL6NR/0JJZO+h1k6tuL4gxZeyd6TLepZN5vXo2h+Toha1+raIt5xetSUUCO6c3O0Zu640sRDI4wwf8Eg7d3aq6gpOB1mIewiL0sQuCQiFQGKs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.com; spf=pass smtp.mailfrom=gmx.com; dkim=pass (2048-bit key) header.d=gmx.com header.i=erick.archer@gmx.com header.b=plKXPz+Q; arc=none smtp.client-ip=212.227.17.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.com; s=s31663417; t=1705855259; x=1706460059; i=erick.archer@gmx.com; bh=45wkP8U/iOWMDIyqAxusjLpXiYYeRC8CCOH80xeHkDo=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=plKXPz+QWbQqY9/sF1zxo0lX6nUYj8vpdb4wgbzCv4Mwwj9Ad2dgnxR3kK5sbxv6 +sK3E3RACXGzf03EKFCzBtAqZZRRmzhDn9GnjcRATuUXR7oeiM+VrLYza6cIWDCGl GrWwYnK0Y765jpyipUrOQTVvp9/lt4CpoMEXeQ8ot9PzXSHHYbSAgVyPRYtNKZOey DInj7c7CfUZsiXfdfgvFzVjwdGg4eiD918B+twb/oXs81mxcIUwIRr49a0D0BrvIG lNV8bV7rrKr+yiQVNHTnSXE5f5hNQx5mWHZovxGovt52HO9pTqEizx7ubMnoYdM47 LCM79y63HG0PfPusig== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from localhost.localdomain ([79.157.194.183]) by mail.gmx.net (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MpDJX-1ql9r21ePP-00qfvG; Sun, 21 Jan 2024 17:40:59 +0100 From: Erick Archer To: Giovanni Cabiddu , Herbert Xu , "David S. Miller" , Erick Archer , Tero Kristo , Andy Shevchenko , Damian Muszynski , Shashank Gupta , Tom Zanussi , "Gustavo A. R. Silva" Cc: qat-linux@intel.com, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] crypto: qat - use kcalloc_node() instead of kzalloc_node() Date: Sun, 21 Jan 2024 17:40:43 +0100 Message-Id: <20240121164043.11222-1-erick.archer@gmx.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:X86R2S6O3Nk0sqc1AIm7SPvLRWYkmOew4svoTCxiKwDfMQakNbj z/VDlvAyiB0sKKvMrEs5N6V5M/Afkll3REGU0PxSx4oW+rM0LZnyBYGovxm0fp7oK4yznKm ZpxO2sPpFtJBRNK+ckGs5bW4nGrqQrNLRQktmeX2h32BzQUa8i9UbX0gK1GcW87bGYKJyG0 1uVhbOx5z1014E+1PF/iA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:LNvvB4XfrQE=;xm4iJMqcqcW3z9pKqpfiRjQ8hgI Rq3/8Yg4GQXoma4V9C/vYZsiydDrsdDVkPtyhi1dBGAp+fW6+jS4zsLh+/2TTUrcbtx1sisC2 YK6Lus7q+ZZxBwmk2gRc3UwlKLYwPubAZvQW5yGeGvXU4jsarDhPtZiUCJUizu3wU4+DmGTLH qkq4UE4zv0LRJ7fp3mG9mAcXFQORPegM3Ig2I2IX3/c7HBfOkEhcGduRThA5seorzjI/xFCf5 NIM6R9OQMTbs0RzuNd0blNsyhbiUb9u2eHIXtm6h6dXE0jo0mqcz7p/GNNsXL1PJsuatjw4Xh q/Sl/RcPMw8zEUwiQd+kTC8+hjI8YZl3ugcs6U2YDep/9Flxyp8XfyiFkqdOuAOGaVLUfsOLv 2IxgOt8LeUEqc4W6AE1hBgFvKqGLt8nL3IOxB+zS7YxadpQoi8zsrc+ZIWurVluJhVPrfvbj0 h/WyWnrBYi7CqYYYUu8/KigZ+8VD9BPpdkO/tn6HGDNBPlKr5IJgOswKlgNgPr53k+38MoHrU VlHVk1y+kgfyMDPvG3yj5bAJf40iAq6UccIrmdS2wkyTzcSAWdxeEHbyd++7nmYl6hXbxAlJL auRbtW5pPwKsEVHtCkT45EWRyM4eQpISoqraF20YaZN8QoXf1A0KG6L34XWFQDELirAgTf7Si TKszUHhbfcM4agL+t+IkjhT6gL0SsxsUuamxarMjxt20oIKA5fx1HFWBBOV7a8W2uoxEdEsJx T8Ao4m4WBm875WIwsOUT7/U6F1ALJqrD42ON/fTTn+kZLDv5DUozay/ANNQ+lBV/3vk4gxWfY x7vklLuVYfXcxMk8hEU+JkKSQ24/bWuMhgKqb4+GqFwytu/TqVzJz/+oW4InB07jR62HXy8qg IqNH3JW5MWCuHWnX2nA0uSIqRjn61CF0wDI45RTXoOnOfgYuyYYOXuB2V07mCjRC8DjZ907bJ Iw9VSum+LtFnAgB+957SAQ30vFw= 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_node() function instead of the argument count * size in the kzalloc_node() function. Link: https://www.kernel.org/doc/html/next/process/deprecated.html#open-co= ded-arithmetic-in-allocator-arguments [1] Link: https://github.com/KSPP/linux/issues/162 Signed-off-by: Erick Archer =2D-- drivers/crypto/intel/qat/qat_common/adf_isr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/intel/qat/qat_common/adf_isr.c b/drivers/crypt= o/intel/qat/qat_common/adf_isr.c index 3557a0d6dea2..a13d9885d60f 100644 =2D-- a/drivers/crypto/intel/qat/qat_common/adf_isr.c +++ b/drivers/crypto/intel/qat/qat_common/adf_isr.c @@ -272,7 +272,7 @@ static int adf_isr_alloc_msix_vectors_data(struct adf_= accel_dev *accel_dev) if (!accel_dev->pf.vf_info) msix_num_entries +=3D hw_data->num_banks; - irqs =3D kzalloc_node(msix_num_entries * sizeof(*irqs), + irqs =3D kcalloc_node(msix_num_entries, sizeof(*irqs), GFP_KERNEL, dev_to_node(&GET_DEV(accel_dev))); if (!irqs) return -ENOMEM; =2D- 2.25.1