Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shm: guard against pool destruction race condition #1433

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/wayland/shm/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ impl InnerPool {

let pool_guard = self.map.read().unwrap();

// This should not happen, but in case a pool resize failed (which result in a protocol error
// and will kill the client) and the buffer got cached somewhere it is possible that we try to access
// a dead pool.
if pool_guard.ptr.is_null() {
return Err(());
}

trace!(fd = ?self.fd, "Buffer access on shm pool");

// Prepare the access
Expand Down Expand Up @@ -152,6 +159,13 @@ impl InnerPool {

let pool_guard = self.map.write().unwrap();

// This should not happen, but in case a pool resize failed (which result in a protocol error
// and will kill the client) and the buffer got cached somewhere it is possible that we try to access
// a dead pool.
if pool_guard.ptr.is_null() {
return Err(());
}

trace!(fd = ?self.fd, "Mutable buffer access on shm pool");

// Prepare the access
Expand Down
Loading