В ядре Linux устранена следующая уязвимость:
можно: isotp: исправить порядок стока таймера, обработку пробуждения и порядок tx_gen
Этот патч является продолжением коммита cf070fe33bfb ("can: isotp:serialize
Переходы состояний TX под so->rx_lock"), которые касаются следующих
Выводы сашико-бота:
- isotp_sendmsg(): сначала истощите so->txfrtimer, чтобы устаревший обратный вызов не мог
повторно активировать эхотаймер после заявки
- isotp_release(): пробуждение так->подождите после принудительного включения ISOTP_SHUTDOWN, чтобы
Спящий запрос sendmsg() не застрял
- isotp_sendmsg(): оба вызова wait_event_interruptible()
isotp_sendmsg() также просыпается по ISOTP_SHUTDOWN и не возвращает запрос на
IDLE, чтобы избежать повреждения параллельного процесса isotp_release().
- isotp_sendmsg(): обрабатывает потенциальную заявку на новую передачу, когда
вызов wait_event_interruptible() возвращает CAN_ISOTP_WAIT_TX_DONE
режим. Не трогайте таймеры и состояния новой передачи, если новый поток
увеличился so->tx_gen перед получением блокировки на err_event_drop.
- isotp_sendmsg(): обрабатывает зависший can_send() и опускает таймер и состояние.
изменяется, если был заявлен новый перевод. wait_tx_done() возвращает ошибку
записано в so->tx_result[], помечено собственным поколением вызывающей стороны.
- isotp_tx_timeout(): по заявленному тайм-ауту запишите ошибку ECOMM для
собственная генерация передачи с истекшим временем ожидания в so->tx_result[]; sk->sk_err
возникает безоговорочно, как и любой другой путь ошибки здесь.
- isotp_tx_gen_done()/isotp_tx_timeout(): всегда читать tx.state (получить)
перед tx_gen — обратный порядок позволяет слабоупорядоченной паре ЦП обновиться
tx.state с устаревшим слотом tx_gen/tx_result.
- isotp_sendmsg(): wait_tx_done: слить sk_err через sock_error(), как только мы
прочитал результат из so->tx_result[], поэтому уже сообщенная ошибка
не остается заблокированным для последующего опроса()/SO_ERROR.
Также выровняйте оставшиеся без блокировок доступы so->tx.state/rx.state/cfecho.
и используйте skb->hash в качестве уникального индикатора кадра эхо-петли.
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: can: isotp: fix timer drain order, wakeup handling and tx_gen ordering This patch is a follow-up to commit cf070fe33bfb ("can: isotp: serialize TX state transitions under so->rx_lock") which addresses following sashiko-bot findings: - isotp_sendmsg(): drain so->txfrtimer first so a stale callback can't re-arm echotimer after the claim - isotp_release(): wake so->wait after forcing ISOTP_SHUTDOWN so a sleeping sendmsg() claim isn't stranded - isotp_sendmsg(): have both wait_event_interruptible() calls in isotp_sendmsg() also wake on ISOTP_SHUTDOWN and do not return claim to IDLE to avoid corrupting a concurrent isotp_release() process. - isotp_sendmsg(): handle potential claim of a new transfer when the wait_event_interruptible() call returns in CAN_ISOTP_WAIT_TX_DONE mode. Don't touch timers and states of the new transfer if a new thread incremented so->tx_gen before getting the lock at err_event_drop. - isotp_sendmsg(): handle a stuck can_send() and omit timer and state changes if a new transfer was claimed. wait_tx_done() returns the error recorded in so->tx_result[], tagged with the caller's own generation. - isotp_tx_timeout(): on a claimed timeout, record the ECOMM error for the timed-out transfer's own generation in so->tx_result[]; sk->sk_err is raised unconditionally, same as every other error path here. - isotp_tx_gen_done()/isotp_tx_timeout(): always read tx.state (acquire) before tx_gen - the reverse order let a weakly ordered CPU pair a fresh tx.state with a stale tx_gen/tx_result slot. - isotp_sendmsg(): wait_tx_done: drain sk_err via sock_error() once we have read the result from so->tx_result[], so an already-reported error doesn't stay latched for a later poll()/SO_ERROR. Also align the remaining lock-free so->tx.state/rx.state/cfecho accesses and use skb->hash as unique loopback echo frame indicator.