From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f171.google.com ([209.85.192.171]:40185 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752129AbeCCVIU (ORCPT ); Sat, 3 Mar 2018 16:08:20 -0500 Received: by mail-pf0-f171.google.com with SMTP id x1so3651045pfh.7 for ; Sat, 03 Mar 2018 13:08:20 -0800 (PST) Date: Sat, 3 Mar 2018 13:08:16 -0800 From: Alexei Starovoitov To: Daniel Borkmann Cc: Daniel Axtens , ast@kernel.org, netdev@vger.kernel.org, Marcelo Ricardo Leitner Subject: Re: [PATCH bpf] bpf: fix bpf_skb_adjust_net/bpf_skb_proto_xlat to deal with gso sctp skbs Message-ID: <20180303210814.g3eashpcdudk4pgz@ast-mbp> References: <20180303020346.9574-1-daniel@iogearbox.net> <87y3j9cflf.fsf@linkitivity.dja.id.au> <98ceaf0e-1f53-36f4-3310-3ceae1a9ff2d@iogearbox.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <98ceaf0e-1f53-36f4-3310-3ceae1a9ff2d@iogearbox.net> Sender: netdev-owner@vger.kernel.org List-ID: On Sat, Mar 03, 2018 at 09:57:15PM +0100, Daniel Borkmann wrote: > On 03/03/2018 05:02 PM, Daniel Axtens wrote: > >> From: Daniel Axtens > >> > >> SCTP GSO skbs have a gso_size of GSO_BY_FRAGS, so any sort of > >> unconditionally mangling of that will result in nonsense value > >> and would corrupt the skb later on. > >> > >> Therefore, i) add two helpers skb_increase_gso_size() and > >> skb_decrease_gso_size() that would throw a one time warning and > >> bail out for such skbs and ii) refuse and return early with an > >> error in those BPF helpers that are affected. We do need to bail > >> out as early as possible from there before any changes on the > >> skb have been performed. > >> > >> Fixes: 6578171a7ff0 ("bpf: add bpf_skb_change_proto helper") > >> Co-authored-by: Daniel Borkmann > >> Signed-off-by: Daniel Axtens > >> Cc: Marcelo Ricardo Leitner > >> Acked-by: Alexei Starovoitov > > > > I've looked over your changes and they all look good to me. > > > >> +/* Note: Should be called only if skb_is_gso(skb) is true */ > >> +static inline bool skb_is_gso_sctp(const struct sk_buff *skb) > >> +{ > >> + return skb_shinfo(skb)->gso_type & SKB_GSO_SCTP; > >> +} > >> + > > > > This helper is a fantastic idea and I will send a docs update to > > highlight it. > > Sounds good. There are infact several places in the code that > could make use of this right away. If you have a chance, this > could be done in net-next along with the doc update or so. Applied to bpf tree, Thanks everyone.