session-lock: fix assertion failure due to race

There's currently a potential race in the implementation that can be hit
during unlocking. This is not a security vulnerability, but it does
cause the compositor to crash due to a failed assertion.

This commit simplifies the code and fixes the race as well as tightening
up the assertions around this state/control flow even further.
This commit is contained in:
Isaac Freund
2023-01-07 14:58:28 +01:00
parent df2fc30238
commit f511a34ded
2 changed files with 12 additions and 5 deletions

View File

@ -98,10 +98,17 @@ pub fn renderOutput(output: *Output) void {
return;
};
if (output.lock_surface == null) {
output.lock_render_state = .pending_blank;
if (server.lock_manager.state == .locked) {
switch (output.lock_render_state) {
.unlocked, .pending_blank, .pending_lock_surface => unreachable,
.blanked, .lock_surface => {},
}
} else {
output.lock_render_state = .pending_lock_surface;
if (output.lock_surface == null) {
output.lock_render_state = .pending_blank;
} else {
output.lock_render_state = .pending_lock_surface;
}
}
return;