]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: mctp: copy skb ext data when fragmenting
authorJeremy Kerr <jk@codeconstruct.com.au>
Mon, 19 Feb 2024 09:51:54 +0000 (17:51 +0800)
committerSasha Levin <sashal@kernel.org>
Tue, 26 Mar 2024 22:16:49 +0000 (18:16 -0400)
[ Upstream commit 1394c1dec1c619a46867ed32791a29695372bff8 ]

If we're fragmenting on local output, the original packet may contain
ext data for the MCTP flows. We'll want this in the resulting fragment
skbs too.

So, do a skb_ext_copy() in the fragmentation path, and implement the
MCTP-specific parts of an ext copy operation.

Fixes: 67737c457281 ("mctp: Pass flow data & flow release events to drivers")
Reported-by: Jian Zhang <zhangjian.3032@bytedance.com>
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/core/skbuff.c
net/mctp/route.c

index edbbef563d4d913dafd4be4287373fb77670e826..71dee435d549daa94f6598296f22ba37cfc24d3f 100644 (file)
@@ -6736,6 +6736,14 @@ static struct skb_ext *skb_ext_maybe_cow(struct skb_ext *old,
                for (i = 0; i < sp->len; i++)
                        xfrm_state_hold(sp->xvec[i]);
        }
+#endif
+#ifdef CONFIG_MCTP_FLOWS
+       if (old_active & (1 << SKB_EXT_MCTP)) {
+               struct mctp_flow *flow = skb_ext_get_ptr(old, SKB_EXT_MCTP);
+
+               if (flow->key)
+                       refcount_inc(&flow->key->refs);
+       }
 #endif
        __skb_ext_put(old);
        return new;
index ceee44ea09d97b025a490058403cf435e3337ef5..01c530dbc1a657063d33eaf7b048b82212bc17ce 100644 (file)
@@ -843,6 +843,9 @@ static int mctp_do_fragment_route(struct mctp_route *rt, struct sk_buff *skb,
                /* copy message payload */
                skb_copy_bits(skb, pos, skb_transport_header(skb2), size);
 
+               /* we need to copy the extensions, for MCTP flow data */
+               skb_ext_copy(skb2, skb);
+
                /* do route */
                rc = rt->output(rt, skb2);
                if (rc)