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:   Wed, 18 Dec 2019 12:08:34 +0100
From:   Toke Høiland-Jørgensen <toke@...hat.com>
To:     Naresh Kamboju <naresh.kamboju@...aro.org>
Cc:     Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Netdev <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
        Jesper Dangaard Brouer <brouer@...hat.com>,
        Yonghong Song <yhs@...com>, lkft-triage@...ts.linaro.org,
        Leo Yan <leo.yan@...aro.org>,
        Daniel Diaz <daniel.diaz@...aro.org>
Subject: Re: [PATCH bpf-next v2] libbpf: Print hint about ulimit when getting permission denied error

Naresh Kamboju <naresh.kamboju@...aro.org> writes:

> On Tue, 17 Dec 2019 at 00:00, Toke Høiland-Jørgensen <toke@...hat.com> wrote:
>> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
>> index a2cc7313763a..3fe42d6b0c2f 100644
>> --- a/tools/lib/bpf/libbpf.c
>> +++ b/tools/lib/bpf/libbpf.c
>> @@ -41,6 +41,7 @@
>>  #include <sys/types.h>
>>  #include <sys/vfs.h>
>>  #include <sys/utsname.h>
>> +#include <sys/resource.h>
>>  #include <tools/libc_compat.h>
>>  #include <libelf.h>
>>  #include <gelf.h>
>> @@ -100,6 +101,32 @@ void libbpf_print(enum libbpf_print_level level, const char *format, ...)
>>         va_end(args);
>>  }
>>
>> +static void pr_perm_msg(int err)
>> +{
>> +       struct rlimit limit;
>> +       char buf[100];
>> +
>> +       if (err != -EPERM || geteuid() != 0)
>> +               return;
>> +
>> +       err = getrlimit(RLIMIT_MEMLOCK, &limit);
>> +       if (err)
>> +               return;
>> +
>> +       if (limit.rlim_cur == RLIM_INFINITY)
>> +               return;
>> +
>> +       if (limit.rlim_cur < 1024)
>> +               snprintf(buf, sizeof(buf), "%lu bytes", limit.rlim_cur);
>
>  libbpf.c: In function 'pr_perm_msg':
>  libbpf.c:120:33: error: format '%lu' expects argument of type 'long
> unsigned int', but argument 4 has type 'rlim_t {aka long long unsigned
> int}' [-Werror=format=]
>     snprintf(buf, sizeof(buf), "%lu bytes", limit.rlim_cur);
>                                 ~~^         ~~~~~~~~~~~~~~
>                                 %llu
>

Ah, guess this needs PRIu64. Will send a follow-up, thanks for the
report :)

-Toke

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ