netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] nfp: bpf: Use kmemdup_array instead of kmemdup for multiple allocation
@ 2024-08-21  8:14 Yu Jiaoliang
  2024-08-21  9:49 ` Louis Peens
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Yu Jiaoliang @ 2024-08-21  8:14 UTC (permalink / raw)
  To: Jakub Kicinski, Louis Peens, David S. Miller, Eric Dumazet,
	Paolo Abeni, bpf, oss-drivers, 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>
---
 drivers/net/ethernet/netronome/nfp/bpf/jit.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/netronome/nfp/bpf/jit.c b/drivers/net/ethernet/netronome/nfp/bpf/jit.c
index df2ab5cbd49b..3a02eef58cc6 100644
--- a/drivers/net/ethernet/netronome/nfp/bpf/jit.c
+++ b/drivers/net/ethernet/netronome/nfp/bpf/jit.c
@@ -4537,8 +4537,8 @@ void *nfp_bpf_relo_for_vnic(struct nfp_prog *nfp_prog, struct nfp_bpf_vnic *bv)
 	u64 *prog;
 	int err;
 
-	prog = kmemdup(nfp_prog->prog, nfp_prog->prog_len * sizeof(u64),
-		       GFP_KERNEL);
+	prog = kmemdup_array(nfp_prog->prog, nfp_prog->prog_len, sizeof(u64),
+			     GFP_KERNEL);
 	if (!prog)
 		return ERR_PTR(-ENOMEM);
 
-- 
2.34.1


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

* Re: [PATCH v1] nfp: bpf: Use kmemdup_array instead of kmemdup for multiple allocation
  2024-08-21  8:14 [PATCH v1] nfp: bpf: Use kmemdup_array instead of kmemdup for multiple allocation Yu Jiaoliang
@ 2024-08-21  9:49 ` Louis Peens
  2024-08-21 15:08 ` Simon Horman
  2024-08-22 13:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Louis Peens @ 2024-08-21  9:49 UTC (permalink / raw)
  To: Yu Jiaoliang
  Cc: Jakub Kicinski, David S. Miller, Eric Dumazet, Paolo Abeni, bpf,
	oss-drivers, netdev, linux-kernel, opensource.kernel

On Wed, Aug 21, 2024 at 04:14:45PM +0800, Yu Jiaoliang wrote:
> [Some people who received this message don't often get email from yujiaoliang@vivo.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
> 
> Let the kememdup_array() take care about multiplication and possible
> overflows.
> 
> Signed-off-by: Yu Jiaoliang <yujiaoliang@vivo.com>
> ---
>  drivers/net/ethernet/netronome/nfp/bpf/jit.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/netronome/nfp/bpf/jit.c b/drivers/net/ethernet/netronome/nfp/bpf/jit.c
> index df2ab5cbd49b..3a02eef58cc6 100644
> --- a/drivers/net/ethernet/netronome/nfp/bpf/jit.c
> +++ b/drivers/net/ethernet/netronome/nfp/bpf/jit.c
> @@ -4537,8 +4537,8 @@ void *nfp_bpf_relo_for_vnic(struct nfp_prog *nfp_prog, struct nfp_bpf_vnic *bv)
>         u64 *prog;
>         int err;
> 
> -       prog = kmemdup(nfp_prog->prog, nfp_prog->prog_len * sizeof(u64),
> -                      GFP_KERNEL);
> +       prog = kmemdup_array(nfp_prog->prog, nfp_prog->prog_len, sizeof(u64),
> +                            GFP_KERNEL);
>         if (!prog)
>                 return ERR_PTR(-ENOMEM);
> 
> --
Hi, thanks for the cleanup, looks good to me.

Signed-off-by: Louis Peens <louis.peens@corigine.com>

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

* Re: [PATCH v1] nfp: bpf: Use kmemdup_array instead of kmemdup for multiple allocation
  2024-08-21  8:14 [PATCH v1] nfp: bpf: Use kmemdup_array instead of kmemdup for multiple allocation Yu Jiaoliang
  2024-08-21  9:49 ` Louis Peens
@ 2024-08-21 15:08 ` Simon Horman
  2024-08-22 13:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2024-08-21 15:08 UTC (permalink / raw)
  To: Yu Jiaoliang
  Cc: Jakub Kicinski, Louis Peens, David S. Miller, Eric Dumazet,
	Paolo Abeni, bpf, oss-drivers, netdev, linux-kernel,
	opensource.kernel

On Wed, Aug 21, 2024 at 04:14:45PM +0800, Yu Jiaoliang wrote:
> Let the kememdup_array() take care about multiplication and possible
> overflows.
> 
> Signed-off-by: Yu Jiaoliang <yujiaoliang@vivo.com>

Reviewed-by: Simon Horman <horms@kernel.org>


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

* Re: [PATCH v1] nfp: bpf: Use kmemdup_array instead of kmemdup for multiple allocation
  2024-08-21  8:14 [PATCH v1] nfp: bpf: Use kmemdup_array instead of kmemdup for multiple allocation Yu Jiaoliang
  2024-08-21  9:49 ` Louis Peens
  2024-08-21 15:08 ` Simon Horman
@ 2024-08-22 13:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-08-22 13:20 UTC (permalink / raw)
  To: =?utf-8?b?5LqO5L286ImvIDx5dWppYW9saWFuZ0B2aXZvLmNvbT4=?=
  Cc: kuba, louis.peens, davem, edumazet, pabeni, bpf, oss-drivers,
	netdev, linux-kernel, opensource.kernel

Hello:

This patch was applied to netdev/net-next.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Wed, 21 Aug 2024 16:14:45 +0800 you wrote:
> Let the kememdup_array() take care about multiplication and possible
> overflows.
> 
> Signed-off-by: Yu Jiaoliang <yujiaoliang@vivo.com>
> ---
>  drivers/net/ethernet/netronome/nfp/bpf/jit.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

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

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] 4+ messages in thread

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-21  8:14 [PATCH v1] nfp: bpf: Use kmemdup_array instead of kmemdup for multiple allocation Yu Jiaoliang
2024-08-21  9:49 ` Louis Peens
2024-08-21 15:08 ` Simon Horman
2024-08-22 13: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).