Re: [PATCH] sctp: don't free the ASCONF's own transport in DEL-IP processing
Jason Xing <[email protected]> Thu, 16 Jul 2026 13:12:10 +0200
| Newsgroups | org.kernel.vger.linux-sctp,org.kernel.vger.linux-kernel,org.kernel.vger.netdev |
|---|---|
| Message-ID | <CAL+tcoD_BH0xhyAJ1p=TcX8KW8_heVjN8wHeVwWzkMKS4MMgNA@mail.gmail.com> |
On Thu, Jul 16, 2026 at 11:16=E2=80=AFAM =E6=9C=B1=E9=9B=80=E8=93=9D=E5=86= =9BAIGBot=E9=82=AE=E7=AE=B1 <[email protected]> wrote: > > sctp_process_asconf() caches the transport the ASCONF chunk is processed > against in asconf->transport (=3D=3D chunk->transport, set once in sctp_r= cv()). > For an ASCONF located through its Address Parameter by > __sctp_rcv_asconf_lookup(), that cached transport corresponds to the > Address Parameter, which need not be the packet's source address. > > sctp_process_asconf_param() rejects a DEL-IP for the packet source addres= s > (ADDIP D8, SCTP_ERROR_DEL_SRC_IP), but nothing protects asconf->transport= . > A single ASCONF can therefore carry, in order: > > [Address Parameter L] [DEL-IP L] [DEL-IP 0.0.0.0] > > where L differs from the source. The DEL-IP for L passes the D8 check and > calls sctp_assoc_rm_peer() on the transport that asconf->transport still > points at, freeing it (RCU-deferred). The following wildcard DEL-IP then > reuses the now-dangling asconf->transport in sctp_assoc_set_primary() and > sctp_assoc_del_nonprimary_peers(): set_primary() dereferences the freed > transport (->ipaddr, ->state) and plants the dangling pointer into > asoc->peer.primary_path / active_path, and del_nonprimary_peers(), keepin= g > only the pointer that is no longer on the list, removes every real > transport, leaving the association with a transport_count of 0 and > primary_path/active_path pointing at freed memory. > > Reject a DEL-IP that targets the transport the ASCONF is being processed > against, mirroring the existing source-address guard, so the wildcard > branch can never reuse a freed transport. > > Fixes: 42e30bf3463c ("[SCTP]: Handle the wildcard ADD-IP Address paramete= r") > Cc: [email protected] > Signed-off-by: Jun Yang <[email protected]> > Acked-by: Xin Long <[email protected]> It should explicitly target the net branch? Thanks, Jason > --- > net/sctp/sm_make_chunk.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c > index 8adac9e0cd66..b14251214896 100644 > --- a/net/sctp/sm_make_chunk.c > +++ b/net/sctp/sm_make_chunk.c > @@ -3153,6 +3153,12 @@ static __be16 sctp_process_asconf_param(struct sct= p_association *asoc, > if (!peer) > return SCTP_ERROR_DNS_FAILED; > > + /* Don't free asconf->transport; a later wildcard DEL-IP > + * parameter reuses it. > + */ > + if (peer =3D=3D asconf->transport) > + return SCTP_ERROR_DEL_SRC_IP; > + > sctp_assoc_rm_peer(asoc, peer); > break; > case SCTP_PARAM_SET_PRIMARY: > -- > 2.55.0 > >