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]
Date:   Wed, 29 May 2019 10:03:43 -0700
From:   Song Liu <liu.song.a23@...il.com>
To:     Andrii Nakryiko <andriin@...com>
Cc:     Andrii Nakryiko <andrii.nakryiko@...il.com>,
        Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
        Alexei Starovoitov <ast@...com>,
        Daniel Borkmann <daniel@...earbox.net>,
        Kernel Team <kernel-team@...com>
Subject: Re: [PATCH bpf-next 2/9] libbpf: preserve errno before calling into
 user callback

On Tue, May 28, 2019 at 6:14 PM Andrii Nakryiko <andriin@...com> wrote:
>
> pr_warning ultimately may call into user-provided callback function,
> which can clobber errno value, so we need to save it before that.
>
> Signed-off-by: Andrii Nakryiko <andriin@...com>

Acked-by: Song Liu <songliubraving@...com>


> ---
>  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 05a73223e524..7b80b9ae8a1f 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -565,12 +565,12 @@ static int bpf_object__elf_init(struct bpf_object *obj)
>         } else {
>                 obj->efile.fd = open(obj->path, O_RDONLY);
>                 if (obj->efile.fd < 0) {
> -                       char errmsg[STRERR_BUFSIZE];
> -                       char *cp = libbpf_strerror_r(errno, errmsg,
> -                                                    sizeof(errmsg));
> +                       char errmsg[STRERR_BUFSIZE], *cp;
>
> +                       err = -errno;
> +                       cp = libbpf_strerror_r(err, errmsg, sizeof(errmsg));
>                         pr_warning("failed to open %s: %s\n", obj->path, cp);
> -                       return -errno;
> +                       return err;
>                 }
>
>                 obj->efile.elf = elf_begin(obj->efile.fd,
> --
> 2.17.1
>

Powered by blists - more mailing lists