In the Linux kernel, the following vulnerability has been resolved:
sctp: do asoc update earlier in sctpsfdodupcooka
There's a panic that occurs in a few of envs, the call trace is as below:
[] general protection fault, ... 0x29acd70f1000a: 0000 [#1] SMP PTI [] RIP: 0010:sctpulpeventnotifypeeraddrchange+0x4b/0x1fa [sctp] [] sctpassoccontroltransport+0x1b9/0x210 [sctp] [] sctpdo82transportstrike.isra.16+0x15c/0x220 [sctp] [] sctpcmdinterpreter.isra.21+0x1231/0x1a10 [sctp] [] sctpdosm+0xc3/0x2a0 [sctp] [] sctpgeneratetimeoutevent+0x81/0xf0 [sctp]
This is caused by a transport use-after-free issue. When processing a duplicate COOKIE-ECHO chunk in sctpsfdodupcooka(), both COOKIE-ACK and SHUTDOWN chunks are allocated with the transort from the new asoc. However, later in the sideeffect machine, the old asoc is used to send them out and old asoc's shutdownlastsentto is set to the transport that SHUTDOWN chunk attached to in sctpcmdsetupt2(), which actually belongs to the new asoc. After the newasoc is freed and the old asoc T2 timeout, the old asoc's shutdownlastsentto that is already freed would be accessed in sctpsft2timerexpire().
Thanks Alexander and Jere for helping dig into this issue.
To fix it, this patch is to do the asoc update first, then allocate the COOKIE-ACK and SHUTDOWN chunks with the 'updated' old asoc. This would make more sense, as a chunk from an asoc shouldn't be sent out with another asoc. We had fixed quite a few issues caused by this.