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:   Thu, 5 Nov 2020 23:31:38 +0000
From:   Song Liu <songliubraving@...com>
To:     Daniel Xu <dxu@...uu.xyz>
CC:     Andrii Nakryiko <andrii.nakryiko@...il.com>,
        bpf <bpf@...r.kernel.org>,
        open list <linux-kernel@...r.kernel.org>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Kernel Team <Kernel-team@...com>
Subject: Re: [PATCH bpf v2 2/2] selftest/bpf: Test bpf_probe_read_user_str()
 strips trailing bytes after NUL



> On Nov 5, 2020, at 3:22 PM, Daniel Xu <dxu@...uu.xyz> wrote:
> 
> On Thu Nov 5, 2020 at 1:32 PM PST, Andrii Nakryiko wrote:
>> On Wed, Nov 4, 2020 at 8:51 PM Daniel Xu <dxu@...uu.xyz> wrote:
> [...]
>>> diff --git a/tools/testing/selftests/bpf/progs/test_probe_read_user_str.c b/tools/testing/selftests/bpf/progs/test_probe_read_user_str.c
>>> new file mode 100644
>>> index 000000000000..41c3e296566e
>>> --- /dev/null
>>> +++ b/tools/testing/selftests/bpf/progs/test_probe_read_user_str.c
>>> @@ -0,0 +1,34 @@
>>> +// SPDX-License-Identifier: GPL-2.0
>>> +
>>> +#include <linux/bpf.h>
>>> +#include <bpf/bpf_helpers.h>
>>> +#include <bpf/bpf_tracing.h>
>>> +
>>> +#include <sys/types.h>
>>> +
>>> +struct sys_enter_write_args {
>>> +       unsigned long long pad;
>>> +       int syscall_nr;
>>> +       int pad1; /* 4 byte hole */
>> 
>> I have a hunch that this explicit padding might break on big-endian
>> architectures?..
>> 
>> Can you instead include "vmlinux.h" in this file and use struct
>> trace_event_raw_sys_enter? you'll just need ctx->args[2] to get that
>> buffer pointer.
>> 
>> Alternatively, and it's probably simpler overall would be to just
>> provide user-space pointer through global variable:
>> 
>> void *user_ptr;
>> 
>> 
>> bpf_probe_read_user_str(buf, ..., user_ptr);
>> 
>> From user-space:
>> 
>> skel->bss->user_ptr = &my_userspace_buf;
>> 
>> Full control. You can trigger tracepoint with just an usleep(1), for
>> instance.
> 
> Yeah, that sounds better. I'll send a v4 with passing a ptr.
> 
> Thanks,
> Daniel

One more comment, how about we test multiple strings with different 
lengths? In this way, we can catch other alignment issues. 

Thanks,
Song

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ