BPF List
 help / color / mirror / Atom feed
* [PATCH v1] net: filter: Use kmemdup_array instead of kmemdup for multiple allocation
@ 2024-08-21  7:37 Yu Jiaoliang
  2024-08-22 12:40 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Yu Jiaoliang @ 2024-08-21  7:37 UTC (permalink / raw)
  To: Martin KaFai Lau, Daniel Borkmann, John Fastabend,
	Alexei Starovoitov, Andrii Nakryiko, Eduard Zingerman, Song Liu,
	Yonghong Song, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, bpf,
	netdev, linux-kernel
  Cc: opensource.kernel

Let the kememdup_array() take care about multiplication and possible
overflows.

Signed-off-by: Yu Jiaoliang <yujiaoliang@vivo.com>
---
 net/core/filter.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/core/filter.c b/net/core/filter.c
index 45ec3dc805b1..eb946d3a9326 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -1265,8 +1265,8 @@ static struct bpf_prog *bpf_migrate_filter(struct bpf_prog *fp)
 	 * so we need to keep the user BPF around until the 2nd
 	 * pass. At this time, the user BPF is stored in fp->insns.
 	 */
-	old_prog = kmemdup(fp->insns, old_len * sizeof(struct sock_filter),
-			   GFP_KERNEL | __GFP_NOWARN);
+	old_prog = kmemdup_array(fp->insns, old_len, sizeof(struct sock_filter),
+				 GFP_KERNEL | __GFP_NOWARN);
 	if (!old_prog) {
 		err = -ENOMEM;
 		goto out_err;
-- 
2.34.1


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

* Re: [PATCH v1] net: filter: Use kmemdup_array instead of kmemdup for multiple allocation
  2024-08-21  7:37 [PATCH v1] net: filter: Use kmemdup_array instead of kmemdup for multiple allocation Yu Jiaoliang
@ 2024-08-22 12:40 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-08-22 12:40 UTC (permalink / raw)
  To: =?utf-8?b?5LqO5L286ImvIDx5dWppYW9saWFuZ0B2aXZvLmNvbT4=?=
  Cc: martin.lau, daniel, john.fastabend, ast, andrii, eddyz87, song,
	yonghong.song, kpsingh, sdf, haoluo, jolsa, davem, edumazet, kuba,
	pabeni, bpf, netdev, linux-kernel, opensource.kernel

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:

On Wed, 21 Aug 2024 15:37:08 +0800 you wrote:
> Let the kememdup_array() take care about multiplication and possible
> overflows.
> 
> Signed-off-by: Yu Jiaoliang <yujiaoliang@vivo.com>
> ---
>  net/core/filter.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Here is the summary with links:
  - [v1] net: filter: Use kmemdup_array instead of kmemdup for multiple allocation
    https://git.kernel.org/bpf/bpf-next/c/b6ab50902724

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2024-08-22 12:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-21  7:37 [PATCH v1] net: filter: Use kmemdup_array instead of kmemdup for multiple allocation Yu Jiaoliang
2024-08-22 12:40 ` 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