FAILED: patch "[PATCH] sctp: hold endpoint before calling cb in" failed to apply to 4.19-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 4.19-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]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From f9d31c4cf4c11ff10317f038b9c6f7c3bda6cdd4 Mon Sep 17 00:00:00 2001
From: Xin Long <[email protected]>
Date: Fri, 31 Dec 2021 18:37:37 -0500
Subject: [PATCH] sctp: hold endpoint before calling cb in
sctp_transport_lookup_process
The same fix in commit 5ec7d18d1813 ("sctp: use call_rcu to free endpoint") is also needed for dumping one asoc and sock after the lookup.
Fixes 86fdb3448cc1 ("sctp: ensure ep is not destroyed before doing the dump")
Signed-off-by Xin Long <[email protected]>
Signed-off-by David S. Miller <[email protected]>
include/net/sctp/sctp.h +1 -2
@@ -112,8 +112,7 @@ struct sctp_transport *sctp_transport_get_next(struct net *net, struct rhashtable_iter *iter);struct sctp_transport *sctp_transport_get_idx (struct net *net,struct rhashtable_iter *iter,int pos); -int sctp_transport_lookup_process (int (*cb)(struct sctp_transport *,void *), -struct net *net, +int sctp_transport_lookup_process (sctp_callback_t cb,struct net *net,const union sctp_addr *laddr,const union sctp_addr *paddr,void *p); int sctp_transport_traverse_process(sctp_callback_t cb, sctp_callback_t cb_done,
net/sctp/diag.c +21 -25
91 lines not on this page · raw message
net/sctp/socket.c +15 -7
@@ -5317,23 +5317,31 @@ int sctp_for_each_endpoint(int (*cb)(struct sctp_endpoint *, void *), }EXPORT_SYMBOL_GPL (sctp_for_each_endpoint); -int sctp_transport_lookup_process (int (*cb)(struct sctp_transport *,void *), -struct net *net, +int sctp_transport_lookup_process (sctp_callback_t cb,struct net *net,const union sctp_addr *laddr,const union sctp_addr *paddr,void *p) {struct sctp_transport *transport; -int err; +struct sctp_endpoint *ep; +int err = -ENOENT ;rcu_read_lock (); transport =sctp_addrs_lookup_transport (net, laddr, paddr); +if (!transport) { +rcu_read_unlock (); +return err; + } + ep = transport->asoc->ep; +if (!sctp_endpoint_hold (ep)) {/* asoc can be peeled off */ +sctp_transport_put (transport); +rcu_read_unlock (); +return err; + }rcu_read_unlock (); -if (!transport) -return -ENOENT ; - err =cb (transport, p); + err =cb (ep, transport, p); +sctp_endpoint_put (ep);sctp_transport_put (transport); -return err; }EXPORT_SYMBOL_GPL (sctp_transport_lookup_process);