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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b834fba1-5b2c-4406-8275-1cf8383655e3@iogearbox.net>
Date:   Wed, 3 Jul 2019 12:23:05 +0200
From:   Daniel Borkmann <daniel@...earbox.net>
To:     Leo Yan <leo.yan@...aro.org>, Alexei Starovoitov <ast@...nel.org>,
        Martin KaFai Lau <kafai@...com>,
        Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
        netdev@...r.kernel.org, bpf@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        Dan Carpenter <dan.carpenter@...cle.com>
Subject: Re: [PATCH] bpf, libbpf: Smatch: Fix potential NULL pointer
 dereference

On 07/02/2019 12:25 PM, Leo Yan wrote:
> Based on the following report from Smatch, fix the potential
> NULL pointer dereference check.
> 
>   tools/lib/bpf/libbpf.c:3493
>   bpf_prog_load_xattr() warn: variable dereferenced before check 'attr'
>   (see line 3483)
> 
> 3479 int bpf_prog_load_xattr(const struct bpf_prog_load_attr *attr,
> 3480                         struct bpf_object **pobj, int *prog_fd)
> 3481 {
> 3482         struct bpf_object_open_attr open_attr = {
> 3483                 .file           = attr->file,
> 3484                 .prog_type      = attr->prog_type,
>                                        ^^^^^^
> 3485         };
> 
> At the head of function, it directly access 'attr' without checking if
> it's NULL pointer.  This patch moves the values assignment after
> validating 'attr' and 'attr->file'.
> 
> Signed-off-by: Leo Yan <leo.yan@...aro.org>
> ---
>  tools/lib/bpf/libbpf.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index 197b574406b3..809b633fa3d9 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -3479,10 +3479,7 @@ int bpf_prog_load(const char *file, enum bpf_prog_type type,
>  int bpf_prog_load_xattr(const struct bpf_prog_load_attr *attr,
>  			struct bpf_object **pobj, int *prog_fd)
>  {
> -	struct bpf_object_open_attr open_attr = {
> -		.file		= attr->file,
> -		.prog_type	= attr->prog_type,
> -	};

Applied, thanks! Fyi, I retained the zeroing of open_attr as otherwise if we ever
extend struct bpf_object_open_attr in future, we'll easily miss this and pass in
garbage to bpf_object__open_xattr().

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ