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:   Wed, 18 May 2022 13:41:59 -0700
From:   Yonghong Song <yhs@...com>
To:     Eugene Syromiatnikov <esyr@...hat.com>
Cc:     Jiri Olsa <jolsa@...nel.org>,
        Masami Hiramatsu <mhiramat@...nel.org>,
        Steven Rostedt <rostedt@...dmis.org>,
        Ingo Molnar <mingo@...hat.com>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Andrii Nakryiko <andrii@...nel.org>,
        Martin KaFai Lau <kafai@...com>,
        Song Liu <songliubraving@...com>,
        John Fastabend <john.fastabend@...il.com>,
        KP Singh <kpsingh@...nel.org>, netdev@...r.kernel.org,
        bpf@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH bpf v3 1/2] bpf_trace: check size for overflow in
 bpf_kprobe_multi_link_attach



On 5/18/22 1:00 PM, Eugene Syromiatnikov wrote:
> On Wed, May 18, 2022 at 09:34:22AM -0700, Yonghong Song wrote:
>> On 5/18/22 5:22 AM, Eugene Syromiatnikov wrote:
>>> -	size = cnt * sizeof(*syms);
>>> +	if (check_mul_overflow(cnt, (u32)sizeof(*syms), &size))
>>> +		return -EOVERFLOW;
>>
>> In mm/util.c kvmalloc_node(), we have
>>
>>          /* Don't even allow crazy sizes */
>>          if (unlikely(size > INT_MAX)) {
>>                  WARN_ON_ONCE(!(flags & __GFP_NOWARN));
>>                  return NULL;
>>          }
>>
>> Basically the maximum size to be allocated in INT_MAX.
>>
>> Here, we have 'size' as u32, which means if the size is 0xffff0000,
>> the check_mul_overflow will return false (no overflow) but
>> kvzalloc will still have a warning.
>>
>> I think we should change the type of 'size' to be 'int' which
>> should catch the above case and be consistent with
>> what kvmalloc_node() intends to warn.
> 
> Huh, it's a bitmore complicated as check_mul_overflow requires types to
> match; what do you think about
> 
> +	if (check_mul_overflow(cnt, (u32)sizeof(*syms), &size) || size > INT_MAX)
> 
> ?

This works for me.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ