Re: [Patch net] mlx5: check for malformed packets

2018-12-04 Thread Cong Wang
On Tue, Dec 4, 2018 at 5:16 PM Saeed Mahameed wrote: > Please understand that RX data path is really sensitive and we are > trying to find the optimal fix of any issue here, sorry for any > inconvenience. I am sorry for sending out this patch, I am certain that it wastes a lot of your time. The

Re: [Patch net] mlx5: check for malformed packets

2018-12-04 Thread Saeed Mahameed
On Tue, 2018-12-04 at 12:21 -0800, Cong Wang wrote: > On Tue, Dec 4, 2018 at 11:33 AM Saeed Mahameed > wrote: > > On Sat, Dec 1, 2018 at 12:38 PM Cong Wang > > wrote: > > > is_last_ethertype_ip() is used to check IP/IPv6 protocol before > > > parsing IP/IPv6 headers. > > > > > > But __vlan_get_p

Re: [Patch net] mlx5: check for malformed packets

2018-12-04 Thread Cong Wang
On Sat, Dec 1, 2018 at 12:38 PM Cong Wang wrote: > > is_last_ethertype_ip() is used to check IP/IPv6 protocol before > parsing IP/IPv6 headers. > > But __vlan_get_protocol() is only bound to skb->len, a malicious > packet could exhaust all skb->len by inserting sufficient ETH_P_8021AD > headers, a

Re: [Patch net] mlx5: check for malformed packets

2018-12-04 Thread Cong Wang
On Tue, Dec 4, 2018 at 11:33 AM Saeed Mahameed wrote: > > On Sat, Dec 1, 2018 at 12:38 PM Cong Wang wrote: > > > > is_last_ethertype_ip() is used to check IP/IPv6 protocol before > > parsing IP/IPv6 headers. > > > > But __vlan_get_protocol() is only bound to skb->len, a malicious > > packet could

Re: [Patch net] mlx5: check for malformed packets

2018-12-04 Thread Cong Wang
On Tue, Dec 4, 2018 at 11:28 AM Saeed Mahameed wrote: > > We are against having inline keywords in c file, so better if you > move this function to a header file an force the inline keyword there. Two points: 1. The existing code without my patch has inline keyword. Why not move it from the be

Re: [Patch net] mlx5: check for malformed packets

2018-12-04 Thread Saeed Mahameed
On Sat, Dec 1, 2018 at 12:38 PM Cong Wang wrote: > > is_last_ethertype_ip() is used to check IP/IPv6 protocol before > parsing IP/IPv6 headers. > > But __vlan_get_protocol() is only bound to skb->len, a malicious > packet could exhaust all skb->len by inserting sufficient ETH_P_8021AD > headers, a

Re: [Patch net] mlx5: check for malformed packets

2018-12-04 Thread Saeed Mahameed
On Mon, Dec 3, 2018 at 10:39 AM Cong Wang wrote: > > On Sat, Dec 1, 2018 at 12:38 PM Cong Wang wrote: > > > > is_last_ethertype_ip() is used to check IP/IPv6 protocol before > > parsing IP/IPv6 headers. > > One thing I noticed while reviewing the assembly code is that > is_last_ethertype_ip() is

Re: [Patch net] mlx5: check for malformed packets

2018-12-03 Thread Cong Wang
On Sat, Dec 1, 2018 at 12:38 PM Cong Wang wrote: > > is_last_ethertype_ip() is used to check IP/IPv6 protocol before > parsing IP/IPv6 headers. One thing I noticed while reviewing the assembly code is that is_last_ethertype_ip() is no longer inlined after this patch. I think I should keep it inl

Re: [Patch net] mlx5: check for malformed packets

2018-12-03 Thread Cong Wang
On Sun, Dec 2, 2018 at 9:11 PM Cong Wang wrote: > > On Sun, Dec 2, 2018 at 12:56 AM Tariq Toukan wrote: > > > > > + } 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 generat

Re: [Patch net] mlx5: check for malformed packets

2018-12-02 Thread Cong Wang
On Sun, Dec 2, 2018 at 12:56 AM Tariq Toukan 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 tr

Re: [Patch net] mlx5: check for malformed packets

2018-12-02 Thread Tariq Toukan
On 01/12/2018 10:38 PM, Cong Wang wrote: > is_last_ethertype_ip() is used to check IP/IPv6 protocol before > parsing IP/IPv6 headers. > > But __vlan_get_protocol() is only bound to skb->len, a malicious > packet could exhaust all skb->len by inserting sufficient ETH_P_8021AD > headers, and it ma

[Patch net] mlx5: check for malformed packets

2018-12-01 Thread Cong Wang
is_last_ethertype_ip() is used to check IP/IPv6 protocol before parsing IP/IPv6 headers. But __vlan_get_protocol() is only bound to skb->len, a malicious packet could exhaust all skb->len by inserting sufficient ETH_P_8021AD headers, and it may not even contain an IP/IPv6 header at all, so we have