net: sctp: sctp_transport_destroy{,_rcu}: fix potential pointer corruption
Subsystems (3)
PATCH 1/1 net: sctp: sctp_transport_destroy{,_rcu}: fix potential pointer corruption
Probably this one is quite unlikely to be triggered, but it's more safe to hold a pointer to asoc and packet (instead of dereferencing) and access both though this after we have called sctp_transport_destroy_rcu() where the transport is being kfree()'d. Introduced by commit 8c98653f ("sctp:sctp_close: fix release of bindings for deferred call_rcu's").
--- net/sctp/transport.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
net/sctp/transport.c +6 -3
@@ -176,6 +176,9 @@ static void sctp_transport_destroy_rcu(struct rcu_head *head)*/ static void sctp_transport_destroy (struct sctp_transport *transport) { +struct sctp_association *asoc = transport->asoc; +struct sctp_packet *packet = &transport->packet; +if (unlikely (!transport->dead)) {WARN (1 ,"Attempt to destroy undead transport %p!\n" , transport);return ;
@@ -183,10 +186,10 @@ static void sctp_transport_destroy(struct sctp_transport *transport)call_rcu (&transport->rcu, sctp_transport_destroy_rcu); -sctp_packet_free (&transport->packet); +sctp_packet_free (packet); -if (transport->asoc) -sctp_association_put (transport->asoc); +if (asoc !=NULL ) +sctp_association_put (asoc); }/* Start T3_rtx timer if it is not already running and update the heartbeat
Signature · 1 line
1.7.11.7
Quoted 7 lines · Daniel Borkmann
Probably this one is quite unlikely to be triggered, but it's more safe to hold a pointer to asoc and packet (instead of dereferencing) and access both though this after we have called
sctp_transport_destroy_rcu()where the transport is being kfree()'d. Introduced by commit8c98653f("sctp:sctp_close: fix release of bindings for deferred call_rcu's").Signed-off-by Daniel Borkmann <[email protected]>
Please ignore this, will send an updated v2 in a moment.