lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20200609085017.0d285568@carbon>
Date:   Tue, 9 Jun 2020 08:50:17 +0200
From:   Jesper Dangaard Brouer <brouer@...hat.com>
To:     gaurav singh <gaurav1086@...il.com>
Cc:     brouer@...hat.com, ast@...nel.org, daniel@...earbox.net,
        davem@...emloft.net, kuba@...nel.org, hawk@...nel.org,
        john.fastabend@...il.com, kafai@...com, songliubraving@...com,
        yhs@...com, andriin@...com, kpsingh@...omium.org,
        netdev@...r.kernel.org, bpf@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] bpf: alloc_record_per_cpu Add null check after malloc

On Sat, 6 Jun 2020 19:59:48 -0400
gaurav singh <gaurav1086@...il.com> wrote:

> Hi,
> 
> The memset call is made right after malloc call. To fix this, add the null
> check right after malloc and then do memset.
> 
> Please find the patch below.

The fix in your patch seem correct (although there are more places),
but the way you send/submit the patch is wrong.  The patch itself also
mangle whitespaces.

You can read the guide:

 https://www.kernel.org/doc/html/latest/process/submitting-patches.html
 https://www.kernel.org/doc/html/latest/process/index.html

--Jesper


> Thanks and regards,
> Gaurav.
> 
> 
> From 552b7df0e12572737929c60478b5dca2a40f4ad9 Mon Sep 17 00:00:00 2001
> From: Gaurav Singh <gaurav1086@...il.com>
> Date: Sat, 6 Jun 2020 19:57:48 -0400
> Subject: [PATCH] bpf: alloc_record_per_cpu Add null check after malloc
> 
> Signed-off-by: Gaurav Singh <gaurav1086@...il.com>
> ---
>  samples/bpf/xdp_rxq_info_user.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/samples/bpf/xdp_rxq_info_user.c
> b/samples/bpf/xdp_rxq_info_user.c
> index 4fe47502ebed..490b07b7df78 100644
> --- a/samples/bpf/xdp_rxq_info_user.c
> +++ b/samples/bpf/xdp_rxq_info_user.c
> @@ -202,11 +202,11 @@ static struct datarec *alloc_record_per_cpu(void)
> 
>   size = sizeof(struct datarec) * nr_cpus;
>   array = malloc(size);
> - memset(array, 0, size);
>   if (!array) {
>   fprintf(stderr, "Mem alloc error (nr_cpus:%u)\n", nr_cpus);
>   exit(EXIT_FAIL_MEM);
>   }
> + memset(array, 0, size);
>   return array;
>  }
> 



-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ