bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/1] bpf: Switch to krealloc_array()
@ 2024-04-29 12:00 Andy Shevchenko
  2024-04-29 17:14 ` Yonghong Song
  2024-04-29 23:20 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Andy Shevchenko @ 2024-04-29 12:00 UTC (permalink / raw)
  To: Alexei Starovoitov, bpf, linux-kernel
  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

Let the krealloc_array() copy the original data and
check for a multiplication overflow.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-04-29 23:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-29 12:00 [PATCH v1 1/1] bpf: Switch to krealloc_array() Andy Shevchenko
2024-04-29 17:14 ` Yonghong Song
2024-04-29 23:20 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).