[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <54a834d7-6adc-c0ad-92aa-1b89e8ada79d@fb.com>
Date: Tue, 2 Jul 2019 15:34:26 +0000
From: Yonghong Song <yhs@...com>
To: Leo Yan <leo.yan@...aro.org>, Alexei Starovoitov <ast@...nel.org>,
"Daniel Borkmann" <daniel@...earbox.net>,
Martin Lau <kafai@...com>, Song Liu <songliubraving@...com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"bpf@...r.kernel.org" <bpf@...r.kernel.org>,
"linux-kernel@...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 7/2/19 3:25 AM, 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>
Acked-by: Yonghong Song <yhs@...com>
Powered by blists - more mailing lists