FAILED: patch "[PATCH] xfrm6: fix inet6_dev refcount underflow problem" failed to apply to 6.1-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x cc9b364bb1d58d3dae270c7a931a8cc717dc2b3b
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2023102001-barometer-press-265e@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From cc9b364bb1d58d3dae270c7a931a8cc717dc2b3b Mon Sep 17 00:00:00 2001
From: Zhang Changzhong <[email protected]>
Date: Fri, 15 Sep 2023 19:20:41 +0800
Subject: [PATCH] xfrm6: fix inet6_dev refcount underflow problem
There are race conditions that may lead to inet6_dev refcount underflow in xfrm6_dst_destroy() and rt6_uncached_list_flush_dev().
One of the refcount underflow bugs is shown below:
(cpu 1) | (cpu 2) xfrm6_dst_destroy() | ... | in6_dev_put() | | rt6_uncached_list_flush_dev() ... | ... | in6_dev_put()
rt6_uncached_list_del() | ...
... |
xfrm6_dst_destroy() calls rt6_uncached_list_del() after in6_dev_put(), so rt6_uncached_list_flush_dev() has a chance to call in6_dev_put() again for the same inet6_dev.
Fix it by moving in6_dev_put() after rt6_uncached_list_del() in xfrm6_dst_destroy().
net/ipv6/xfrm6_policy.c +2 -2
@@ -117,10 +117,10 @@ static void xfrm6_dst_destroy(struct dst_entry *dst) {struct xfrm_dst *xdst = (struct xfrm_dst *)dst; -if (likely (xdst->u.rt6.rt6i_idev)) -in6_dev_put (xdst->u.rt6.rt6i_idev);dst_destroy_metrics_generic (dst);rt6_uncached_list_del (&xdst->u.rt6); +if (likely (xdst->u.rt6.rt6i_idev)) +in6_dev_put (xdst->u.rt6.rt6i_idev);xfrm_dst_destroy (xdst); }