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:   Sun, 2 Dec 2018 21:11:13 -0800
From:   Cong Wang <xiyou.wangcong@...il.com>
To:     Tariq Toukan <tariqt@...lanox.com>
Cc:     Linux Kernel Network Developers <netdev@...r.kernel.org>,
        Saeed Mahameed <saeedm@...lanox.com>
Subject: Re: [Patch net] mlx5: check for malformed packets

On Sun, Dec 2, 2018 at 12:56 AM Tariq Toukan <tariqt@...lanox.com> wrote:
>
>
>
> On 01/12/2018 10:38 PM, Cong Wang wrote:
> > +     if (*proto == htons(ETH_P_IP)) {
> > +             if (unlikely(*network_depth > skb->len - sizeof(struct iphdr)))
> > +                     return false;
> > +             return true;
>
> Or just do the following?
>         return *network_depth <= skb->len - sizeof(struct iphdr));
>
> We'll lose the compiler hint though, so I'm not sure which is better.


It is very important to keep this unlikely(), as it is on a hot path.


>
> > +     } else if (*proto == htons(ETH_P_IPV6)) {
>
> No need for an else here, the first if block always returns.


Yeah, but not sure if this makes a difference on the generated
asm code. I will give it a try anyway.

Thanks.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ