Description
In the Linux kernel, the following vulnerability has been resolved: can: isotp: fix use-after-free race with concurrent NETDEV_UNREGISTER isotp_release() looked up the bound network device via dev_get_by_index() using the stored ifindex. During device unregistration the device is unlisted from the ifindex hash before the NETDEV_UNREGISTER notifier chain runs, so a concurrent isotp_release() could find no device, skip can_rx_unregister() entirely, and still proceed to free the socket. Since isotp_release() had already removed itself from the isotp notifier list at that point, isotp_notify() would never get a chance to clean up either, leaving a stale CAN filter that keeps pointing at the freed socket. Fix this the same way raw.c already does: hold a tracked reference to the bound net_device in the socket (so->dev/so->dev_tracker) from bind() onward instead of re-resolving it from the ifindex, and serialize bind()/release() with rtnl_lock() so that so->dev is always consistent with what the NETDEV_UNREGISTER notifier sees. so->dev stays valid regardless of ifindex-hash unlisting, and is only ever cleared by whichever of isotp_release()/isotp_notify() gets there first, so the filter is always removed exactly once. isotp_bind() now rejects a (re)bind with -EAGAIN while so->[tx|rx].state isn't ISOTP_IDLE yet, so a timer left running by a prior NETDEV_UNREGISTER can't act on a newly bound so->ifindex. Both checks share the same lock_sock() section, so there is no window in which a concurrent isotp_notify() clearing so->bound could be missed.
Affected products
Version statuses are supplied by the assigning organization. Consult the original record for detailed ranges and platform conditions.
Linux Linux
Default version status: unaffected
e057dd3fc20ffb3d7f150af46542a51b59b90127 to < f311bbb29bb06aaab69ba45a6e4b11323d20b8f9affectede057dd3fc20ffb3d7f150af46542a51b59b90127 to < 8e018f4335590460ebcf0c2b493ed38ba1a35204affectede057dd3fc20ffb3d7f150af46542a51b59b90127 to < 33b9cd9245e2a4b800f99ed1cc53d64960614152affectede057dd3fc20ffb3d7f150af46542a51b59b90127 to < 0b811c4bbe3ec9ad611e90a540fe8b51b3bb8a96affectede057dd3fc20ffb3d7f150af46542a51b59b90127 to < 43884dc7963beef2328f507f4fe680bdc173eb80affectede057dd3fc20ffb3d7f150af46542a51b59b90127 to < 7bef39ba76eb7307ed22a50329e0f5776dbeda58affectede057dd3fc20ffb3d7f150af46542a51b59b90127 to < e442b62ba5a7756c17e05a77b32cdd085a2b6138affectede057dd3fc20ffb3d7f150af46542a51b59b90127 to < 20bab8b88baac140ca3701116e1d486c7f51e311affected
Linux Linux
Default version status: affected
5.10affected0 to < 5.10unaffected5.10.265 to ≤ 5.10.*unaffected5.15.216 to ≤ 5.15.*unaffected6.1.183 to ≤ 6.1.*unaffected6.6.148 to ≤ 6.6.*unaffected6.12.101 to ≤ 6.12.*unaffected6.18.40 to ≤ 6.18.*unaffected7.1.5 to ≤ 7.1.*unaffected7.2 to ≤ *unaffected
References
- https://git.kernel.org/stable/c/f311bbb29bb06aaab69ba45a6e4b11323d20b8f9 ↗
- https://git.kernel.org/stable/c/8e018f4335590460ebcf0c2b493ed38ba1a35204 ↗
- https://git.kernel.org/stable/c/33b9cd9245e2a4b800f99ed1cc53d64960614152 ↗
- https://git.kernel.org/stable/c/0b811c4bbe3ec9ad611e90a540fe8b51b3bb8a96 ↗
- https://git.kernel.org/stable/c/43884dc7963beef2328f507f4fe680bdc173eb80 ↗
- https://git.kernel.org/stable/c/7bef39ba76eb7307ed22a50329e0f5776dbeda58 ↗
- https://git.kernel.org/stable/c/e442b62ba5a7756c17e05a77b32cdd085a2b6138 ↗
- https://git.kernel.org/stable/c/20bab8b88baac140ca3701116e1d486c7f51e311 ↗