From patchwork Mon Apr 29 12:00:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13646714 X-Patchwork-Delegate: bpf@iogearbox.net 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="V1rWMRgP" 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: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net Let the krealloc_array() copy the original data and check for a multiplication overflow. Signed-off-by: Andy Shevchenko Acked-by: Yonghong Song --- 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;