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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c4948e58-0666-5d4b-3436-7672f98fe1e3@isovalent.com>
Date:   Wed, 2 Nov 2022 10:51:56 +0000
From:   Quentin Monnet <quentin@...valent.com>
To:     Pu Lehui <pulehui@...weicloud.com>, bpf@...r.kernel.org,
        linux-kernel@...r.kernel.org
Cc:     Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Andrii Nakryiko <andrii@...nel.org>,
        Martin KaFai Lau <martin.lau@...ux.dev>,
        Song Liu <song@...nel.org>, Yonghong Song <yhs@...com>,
        John Fastabend <john.fastabend@...il.com>,
        KP Singh <kpsingh@...nel.org>,
        Stanislav Fomichev <sdf@...gle.com>,
        Hao Luo <haoluo@...gle.com>, Jiri Olsa <jolsa@...nel.org>,
        Pu Lehui <pulehui@...wei.com>
Subject: Re: [PATCH bpf] bpftool: Fix NULL pointer dereference when pin {PROG,
 MAP, LINK} without FILE

2022-11-02 16:40 UTC+0800 ~ Pu Lehui <pulehui@...weicloud.com>
> From: Pu Lehui <pulehui@...wei.com>
> 
> When using bpftool to pin {PROG, MAP, LINK} without FILE,
> segmentation fault will occur. The reson is that the lack
> of FILE will cause strlen to trigger NULL pointer dereference.
> The corresponding stacktrace is shown below:
> 
> do_pin
>   do_pin_any
>     do_pin_fd
>       mount_bpffs_for_pin
>         strlen(name) <- NULL pointer dereference
> 
> Fix it by adding validation to the common process.
> 
> Fixes: 75a1e792c335 ("tools: bpftool: Allow all prog/map handles for pinning objects")
> Signed-off-by: Pu Lehui <pulehui@...wei.com>
> ---
>  tools/bpf/bpftool/common.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/tools/bpf/bpftool/common.c b/tools/bpf/bpftool/common.c
> index e4d33bc8bbbf..653c130a0aaa 100644
> --- a/tools/bpf/bpftool/common.c
> +++ b/tools/bpf/bpftool/common.c
> @@ -302,6 +302,9 @@ int do_pin_any(int argc, char **argv, int (*get_fd)(int *, char ***))
>  	int err;
>  	int fd;
>  
> +	if (!REQ_ARGS(3))
> +		return -EINVAL;
> +
>  	fd = get_fd(&argc, &argv);
>  	if (fd < 0)
>  		return fd;

Good catch, and thanks for the fix!

Reviewed-by: Quentin Monnet <quentin@...valent.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ