Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1386252lqa; Mon, 29 Apr 2024 07:13:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXIX+FLKafwUj1Q7Bj3N45XzZjbxEPkqxaXYWUqT9bhexdUmN9RnbJBCm8vmC21VBldU9EkSF2G7OtDbp8WqI9BRLcSbDAPPudWpp9H0Q== X-Google-Smtp-Source: AGHT+IHB/2fFD+mV06UOKyjVRS0m9yVP8d2wleSe6+Pdi9fJXjJ/ACZCe1dL+zIAe7DiPhIPHmnb X-Received: by 2002:a17:90a:ad88:b0:2a5:5a2c:6066 with SMTP id s8-20020a17090aad8800b002a55a2c6066mr6407849pjq.37.1714400037654; Mon, 29 Apr 2024 07:13:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714400037; cv=pass; d=google.com; s=arc-20160816; b=qnplDxdFkAVIdqftmxKAPJcvhPnL3P4JWUxY8i0B6kmvYIARhfCmsrrl2y6lVQh+Qt FRek1uuP1Vg4vW66qX2evlgUuD/+gO0whCA5A40UjlPWHTKEuDBVoMlcM4CwDWwsJI9F B/lHK+T9gg0fsdGNN7EpcON63g+85mBUPTBDVO+x7IfekmVeRrADiBhXLa+868UN/oXX B4ijYGYVdUGC4DkveLIqmZEMiFyZKTZWzm410qyVfyDRI1krNCqQG/DoTM9sHnfByved E2vrL1u63rWLhKsvwzVquK+BFCWjjAlNwC7oU17zSlo8wH9LfGa5g1k9p1lGb5MRhNMX LSQQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=vDk7ORHkvfYGLJBNdzhQEf0FcHOEKI9wXLtGdCQn+Zw=; fh=/aV4zCO9AZy5PpGq6rbnd7vL2iCF/IqaXkQVKNavVgU=; b=jZx6RvPCwScE9VSxBVI81pcAkVs8njHR1sqjS6lmRhXJv4900xIN8gjkJ+xTqsiBDy ZrpPUVypuefJ/Hgb2H0MFYS0YqgTSXZ+SgO/gC7aVlmx+rJI/PDjjSLACWkbNcJIzfWF 20+qwYd2VGuNy0dUI6mF56+ZnC2PaKwMLHzjauZ5oVuMzwPKxyNAp/JbI4EGQJmhlJo1 Eo08svoRFUBF1UWS20bwShLXFhMb79SHY+LfPWyTlcnNpBJZPQxP0MOLrzdFuFvIPI4b ZXWP3+XHXS51edeZ/rU2QQd3hkpehpci3DjT2Lqn6/lHX9H91vAzHwsemhz+4+s7DxhK RD3g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=V1rWMRgP; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-162183-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162183-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id h8-20020a17090a710800b002ab69dde334si19919312pjk.31.2024.04.29.07.13.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 07:13:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-162183-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=V1rWMRgP; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-162183-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162183-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id F190AB225CB for ; Mon, 29 Apr 2024 12:00:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 18C77535D1; Mon, 29 Apr 2024 12:00:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="V1rWMRgP" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 AA1BB4D5A2; Mon, 29 Apr 2024 12:00:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714392026; cv=none; b=C8Yyo9gwM0Zk/JjC8noMe+tzzrN1TjKDUt2r5+XVPS4y0R1Y7YHtanjT7HVqKM/Dn2nqUh7PCP2lEjiBpuPGGAtBnrgvYT8gG6yq80ioOAocvTOCfiqsC8FuKRVF/e/HLYv7ykbDcI+ZyvWE89FcXQmjyJZnSve2+QtbnqS+q70= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714392026; c=relaxed/simple; bh=hNReNeYTpfIULcJuF2gEsqCmdOprPMwUabi9ZhnESwQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=r/1/Fqfe4wXdDOIyjxRQa/MLTKymDjSHocD61qgXXonzN3xrOar0U8WhZ5p/mWyqzMxxKuzisRnP9sMhICyAvxeAmtH/o/J4OUbFjAjHh3YDk7dCr56ehUA/6GqaPwiAPDY2BriUZgjSuvUThpjcRrZXNbSY18zyz1zCLnN8n4o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=V1rWMRgP; arc=none smtp.client-ip=198.175.65.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714392025; x=1745928025; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=hNReNeYTpfIULcJuF2gEsqCmdOprPMwUabi9ZhnESwQ=; b=V1rWMRgPTAPI59RwBaLA/IndQl+PzAGD0ls4+8TPg0xemW71ytaLi8nH MiYkGv0nIj6EUle8jUjj9q20OYs+dE1tmX2VxiyiT13j+jxrZ7tAjX9md 65m5X7yWUbur02/iDdjjeDEqafLbWPOVROQBcXYMwDsvNioauzmQCdmuM zkrAI9y1dDgT3S6waLK2R6+52HBmb3yJfIb3OvL0wO/jSFl0YP1rroHKc 6/G/9047W8jJsTRA9NVAbtcwkfPaTvqHqzWzG9CFkW/qUhQcYiYR8Hzvz yP7z65tka7qNUMlBbdaHot6Cex73TYiQn3I0jXiPTby4p+WKW5HTsw5iY w==; X-CSE-ConnectionGUID: IQ7jTKWuTeyZ4+Qpx/LOuA== X-CSE-MsgGUID: WhU1MuiIQNWI8/hJXa98wg== X-IronPort-AV: E=McAfee;i="6600,9927,11057"; a="9876776" X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="9876776" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2024 05:00:21 -0700 X-CSE-ConnectionGUID: guqDvAGkROiAQGdhFIY/lA== X-CSE-MsgGUID: OotK0ZcCQbiSV6fjkutl2g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="49300112" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa002.fm.intel.com with ESMTP; 29 Apr 2024 05:00:09 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3CBA215B; Mon, 29 Apr 2024 15:00:06 +0300 (EEST) From: Andy Shevchenko To: Alexei Starovoitov , bpf@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Andy Shevchenko Subject: [PATCH v1 1/1] bpf: Switch to krealloc_array() Date: Mon, 29 Apr 2024 15:00:05 +0300 Message-ID: <20240429120005.3539116-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Let the krealloc_array() copy the original data and check for a multiplication overflow. Signed-off-by: Andy Shevchenko --- kernel/bpf/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index 466c2deeecff..778775bdbb2e 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -849,7 +849,7 @@ int bpf_jit_add_poke_descriptor(struct bpf_prog *prog, return -EINVAL; } - tab = krealloc(tab, size * sizeof(*poke), GFP_KERNEL); + tab = krealloc_array(tab, size, sizeof(*poke), GFP_KERNEL); if (!tab) return -ENOMEM; -- 2.43.0.rc1.1336.g36b5255a03ac