Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
preload: fix sigmask block and restore race
To avoid clobbering a threads signal mask with that of another thread, take locks before storing a thread's signal mask in case another thread has already stored its own signal mask in the trap_path_sig_restore variable, but has not yet restored it. Without this change, the following could happen: If umockdev-run is used to run a process which spawns multiple threads, and each of those threads writes to a file, and has specific signal mask requirements, the following may happen - Thread A: - store thread A's sigmask in trap_path_sig_restore and block all signals for thread A - acquire trap_path_lock - Thread B: - store thread B's sigmask in trap_path_sig_restore and block all signals for thread B. Thread A's original signal mask is lost. - wait on acquiring trap_path_lock - Thread A: - "restore" thread A's sigmask using trap_path_sig_restore, which now contains thread B's sigmask, thus clobbering thread A's original sigmask with that of thread B.
- Loading branch information