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] [day] [month] [year] [list]
Date:   Tue, 8 Feb 2022 10:47:28 +0800
From:   Hou Tao <houtao1@...wei.com>
To:     Yonghong Song <yhs@...com>, Hou Tao <hotforest@...il.com>,
        Daniel Borkmann <daniel@...earbox.net>
CC:     Alexei Starovoitov <ast@...nel.org>,
        Martin KaFai Lau <kafai@...com>,
        Andrii Nakryiko <andrii@...nel.org>,
        "David S . Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        John Fastabend <john.fastabend@...il.com>,
        <netdev@...r.kernel.org>, <bpf@...r.kernel.org>
Subject: Re: [PATCH bpf-next v4 2/2] selftests/bpf: check whether s32 is
 sufficient for kfunc offset

Hi,

On 2/8/2022 2:33 AM, Yonghong Song wrote:
>
>
> On 2/5/22 8:31 PM, Hou Tao wrote:
>> In add_kfunc_call(), bpf_kfunc_desc->imm with type s32 is used to
>> represent the offset of called kfunc from __bpf_call_base, so
>> add a test to ensure that the offset will not be overflowed.
>>
>> Signed-off-by: Hou Tao <houtao1@...wei.com>
>> ---
>>   .../selftests/bpf/prog_tests/ksyms_module.c   | 42 +++++++++++++++++++
>>   1 file changed, 42 insertions(+)
>>
[...]
>> +    /* Ensure kfunc call is supported */
>> +    skel = test_ksyms_module__open_and_load();
>> +    if (!ASSERT_OK_PTR(skel, "test_ksyms_module__open"))
>> +        return;
>> +
>> +    err = kallsyms_find("bpf_testmod_test_mod_kfunc", &kfunc_addr);
>> +    if (!ASSERT_OK(err, "find kfunc addr"))
>> +        goto cleanup;
>> +
>> +    err = kallsyms_find("__bpf_call_base", &base_addr);
>> +    if (!ASSERT_OK(err, "find base addr"))
>> +        goto cleanup;
>> +
>> +    used_offset = kfunc_addr - base_addr;
>> +    actual_offset = kfunc_addr - base_addr;
>> +    ASSERT_EQ((long long)used_offset, actual_offset, "kfunc offset
>> overflowed");
>
> I am a little bit confused about motivation here. Maybe I missed something. If
> we indeed have kfunc offset overflow,
> should kernel verifier just reject the program? Specially,
> we should make the above test_ksyms_module__open_and_load()
> fail?
In add_kfunc_call(), the calculation of imm doesn't consider the overflow
of s32. So test_ksyms_module__open_and_load() will succeed. I think the
better solution is to put the overflow check in add_kfunc_call(), so will
drop this patch and add the overflow check in add_kfunc_call() instead.

Regards,
Tao

[...]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ