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:   Mon, 22 Apr 2019 16:57:08 +0000
From:   Yonghong Song <yhs@...com>
To:     Paul Chaignon <paul.chaignon@...nge.com>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "bpf@...r.kernel.org" <bpf@...r.kernel.org>
CC:     Xiao Han <xiao.han@...nge.com>, Martin Lau <kafai@...com>,
        Song Liu <songliubraving@...com>
Subject: Re: [PATCH bpf 0/2] bpf: mark registers as safe or unknown in all
 frames



On 4/20/19 5:38 AM, Paul Chaignon wrote:
> In case of a null check on a pointer inside a subprog, we should mark all
> registers with this pointer as either safe or unknown, in both the current
> and previous frames.  Currently, only spilled registers and registers in
> the current frame are marked.  This first patch also marks registers in
> previous frames.
> 
> A good reproducer looks as follow:
> 
> 1: ptr = bpf_map_lookup_elem(map, &key);
> 2: ret = subprog(ptr) {
> 3:   return ptr != NULL;
> 4: }
> 5: if (ret)
> 6:   value = *ptr;
> 
> With the above, the verifier will complain on line 6 because it sees ptr
> as map_value_or_null despite the null check in subprog 1.  The second
> patch implements the above as a new test case.
> 
> Note that this patch fixes another resulting bug when using
> bpf_sk_release():
> 
> 1: sk = bpf_sk_lookup_tcp();
> 2: subprog(sk) {
> 3:   if (sk)
> 4:     bpf_sk_release(sk, 0);

The specification for bpf_sk_release() in uapi/linux/bpf.h is:
  int bpf_sk_release(struct bpf_sock *sock)

Do you explain what is bpf_sk_release(sk, 0)?

> 5: }
> 6: if (!sk)
> 7:   return 0;
> 8: return sk;

If sk has been released, the program should not really return sk, right?

> 
> In the above, mark_ptr_or_null_regs will warn on line 6 because it will
> try to free the reference state, even though it was already freed on
> line 3.
> 
> Paul Chaignon (2):
>    bpf: mark registers as safe or unknown in all frames
>    selftests/bpf: test case for pointer null check in subprog
> 
>   kernel/bpf/verifier.c                        |  6 ++---
>   tools/testing/selftests/bpf/verifier/calls.c | 25 ++++++++++++++++++++
>   2 files changed, 28 insertions(+), 3 deletions(-)
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ