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]
Message-ID: <73905026-571a-867d-43eb-3d9b36f6c39c@gmail.com>
Date:   Sat, 23 Feb 2019 12:48:53 -0800
From:   Eric Dumazet <eric.dumazet@...il.com>
To:     Alexei Starovoitov <alexei.starovoitov@...il.com>,
        Eric Dumazet <edumazet@...gle.com>
Cc:     Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        netdev <netdev@...r.kernel.org>, Martin KaFai Lau <kafai@...com>,
        Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
        bpf <bpf@...r.kernel.org>, Lawrence Brakmo <brakmo@...com>
Subject: Re: [PATCH bpf] bpf: properly check TCP_CONGESTION optlen



On 02/23/2019 12:38 PM, Alexei Starovoitov wrote:
> On Sat, Feb 23, 2019 at 11:07:09AM -0800, Eric Dumazet wrote:
>> If caller of bpf_setsockopt() is silly passing a negative optlen
>> bad things happen.
>>
>> Fixes: 91b5b21c7c16 ("bpf: Add support for changing congestion control")
>> Signed-off-by: Eric Dumazet <edumazet@...gle.com>
>> Cc: Lawrence Brakmo <brakmo@...com>
>> ---
>>  net/core/filter.c | 5 +++--
>>  1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/net/core/filter.c b/net/core/filter.c
>> index f7d0004fc16096eb42ece3a6acf645540ee2326b..6a5d89464168f2f35f43986c1dbc0446c9390a3c 100644
>> --- a/net/core/filter.c
>> +++ b/net/core/filter.c
>> @@ -4194,8 +4194,9 @@ BPF_CALL_5(bpf_setsockopt, struct bpf_sock_ops_kern *, bpf_sock,
>>  			char name[TCP_CA_NAME_MAX];
>>  			bool reinit = bpf_sock->op > BPF_SOCK_OPS_NEEDS_ECN;
>>  
>> -			strncpy(name, optval, min_t(long, optlen,
>> -						    TCP_CA_NAME_MAX-1));
>> +			if (optlen < 0)
>> +				return -EINVAL;
>> +			strncpy(name, optval, min(optlen, TCP_CA_NAME_MAX - 1));
> 
> Unnecessary.
> The verifier guarantees that optlen > 0 because
> static const struct bpf_func_proto bpf_setsockopt_proto = {
>         .func           = bpf_setsockopt,
> ...
>         .arg5_type      = ARG_CONST_SIZE,
> };
> 

Even on 32bit kernel ?

The suspect thing to me is the min_t(long, ....)

optlen is an integer, why do we need to promote to a long ?


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ