The skbuff BUG_ON() conversions left a few comments behind: - bpf_skb_net_grow() says skb_segment() BUG()s on a frag_list with head_frag set at the downgraded MSS. It fails the segmentation and the packet is dropped, which is still why the skb gets linearized. - The skb_to_sgvec() kernel-doc doesn't list the -EINVAL that __skb_to_sgvec() returns when @offset and @len run past the end of the skb. - A comment in the netmem KUnit test names BUG_ON(i >= nfrags) in skb_segment(), which is a check that fails the segmentation now. No functional change. Acked-by: Mina Almasry Signed-off-by: Josef Bacik --- net/core/filter.c | 6 +++--- net/core/net_test.c | 2 +- net/core/skbuff.c | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/net/core/filter.c b/net/core/filter.c index 09c60a58c82a..9881ac89e94c 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -3723,9 +3723,9 @@ static int bpf_skb_net_grow(struct sk_buff *skb, u32 off, u32 len_diff, shinfo->gso_segs = 0; /* Due to header growth, MSS needs to be downgraded. - * There is a BUG_ON() when segmenting the frag_list with - * head_frag true, so linearize the skb after downgrading - * the MSS. + * Segmenting a frag_list with head_frag true at the new MSS + * fails and the packet gets dropped, so linearize the skb + * after downgrading the MSS. */ if (!(flags & BPF_F_ADJ_ROOM_FIXED_GSO)) { skb_decrease_gso_size(shinfo, len_diff); diff --git a/net/core/net_test.c b/net/core/net_test.c index 03203454cd19..976d14896251 100644 --- a/net/core/net_test.c +++ b/net/core/net_test.c @@ -1524,7 +1524,7 @@ static void netmem_ref_test_skb_segment(struct kunit *test) /* 5. Linear head_skb (nr_frags=0) + mixed pp_recycle frag_list where * member A has linear + frag (pp_recycle=1) and tail member B has * linear len == skb_headlen(A) (pp_recycle=0): keeps SG clone path - * synchronized without hitting BUG_ON(i >= nfrags). + * synchronized without failing the i >= nfrags check. */ head = alloc_skb(64, GFP_KERNEL); list = alloc_skb(64, GFP_KERNEL); diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 45cd77e153f1..29951ce11850 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -5641,8 +5641,9 @@ __skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len, * * Fill the specified scatter-gather list with mappings/pointers into a * region of the buffer space attached to a socket buffer. Returns either - * the number of scatterlist items used, or -EMSGSIZE if the contents - * could not fit. + * the number of scatterlist items used, -EMSGSIZE if the contents + * could not fit, or -EINVAL if @offset and @len run past the end of + * the skb. */ int skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len) { -- 2.55.0