Természetes intelligencia az OpenSSH-ban is

https://www.openwall.com/lists/oss-security/2024/07/01/3
Ha jól értem, a kulcsgondolat az, hogy signal-handler-ből free(3)-t hívunk. És ezt egyszer már kijavították, de később visszarakták.

Hozzászólások

Szerkesztve: 2024. 07. 02., k – 11:23

Ha jól értem, a kulcsgondolat az, hogy signal-handler-ből free(3)-t hívunk

Igen (eredeti link); azt írja:

sshd's SIGALRM handler is called asynchronously, but this signal handler calls various functions that are not async-signal-safe

Nagyon kevesen foglalkoznak az igazság valódi forrásával:

If the process is multi-threaded, or if the process is single-threaded and a signal handler is executed other than as the result of:

the behavior is undefined if the signal handler refers to any object other than errno with static storage duration other than by assigning a value to an object declared as volatile sig_atomic_t, or if the signal handler calls any function defined in this standard other than one of the functions listed in the following table.

Röviden úgy lehet összefoglalni, hogy ha unsafe környezetet szakít meg a handler és a handler-ben unsafe műveletet végzünk, akkor UB.

Ha legalább az egyik safe, akkor rendben vagyunk.

Kapcsolódó kommentek a Hacker News topikban.