Hi,
On 12/2/2021 1:42 AM, Alexei Starovoitov wrote:
On Tue, Nov 30, 2021 at 11:19 PM Hou Tao [off-list ref] wrote:
quoted
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
quoted
- 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/ (local)
"
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