[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <d8328f48-bce7-b19b-53db-ccee3cc3322a@huawei.com>
Date: Thu, 2 Dec 2021 11:42:00 +0800
From: Hou Tao <houtao1@...wei.com>
To: Alexei Starovoitov <alexei.starovoitov@...il.com>
CC: Alexei Starovoitov <ast@...nel.org>,
Martin KaFai Lau <kafai@...com>, Yonghong Song <yhs@...com>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>,
Network Development <netdev@...r.kernel.org>,
bpf <bpf@...r.kernel.org>
Subject: Re: [PATCH bpf-next v4 2/2] bpf: disallow BPF_LOG_KERNEL log level
for bpf(BPF_BTF_LOAD)
Hi,
On 12/2/2021 1:42 AM, Alexei Starovoitov wrote:
> On Tue, Nov 30, 2021 at 11:19 PM Hou Tao <houtao1@...wei.com> wrote:
>> BPF_LOG_KERNEL is only used internally, so disallow bpf_btf_load()
>> to set log level as BPF_LOG_KERNEL. The same checking has already
>> been done in bpf_check(), so factor out a helper to check the
>> validity of log attributes and use it in both places.
>>
>>
snip
>> - ret = -EINVAL;
>> /* log attributes have to be sane */
>> - if (log->len_total < 128 || log->len_total > UINT_MAX >> 2 ||
>> - !log->level || !log->ubuf || log->level & ~BPF_LOG_MASK)
>> + if (!bpf_verifier_log_attr_valid(log, UINT_MAX >> 2)) {
>> + ret = -EINVAL;
> It's actually quite bad that we have this discrepancy in limits.
> I've already sent a patch to make them the same.
> It was a pain to debug.
> https://lore.kernel.org/bpf/20211124060209.493-7-alexei.starovoitov@gmail.com/
> "
> Otherwise tools that progressively increase log size and use the same log
> for BTF loading and program loading will be hitting hard to debug EINVAL.
> "
OK. Will send a single patch to handle that based on your patch set.
Regards,
Tao
Powered by blists - more mailing lists