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

Incorrect Send/Sync implementation of tokio_udev::MonitorSocket. #13

Closed
brain0 opened this issue May 20, 2021 · 2 comments
Closed

Incorrect Send/Sync implementation of tokio_udev::MonitorSocket. #13

brain0 opened this issue May 20, 2021 · 2 comments

Comments

@brain0
Copy link

brain0 commented May 20, 2021

The Send and Sync implementation of tokio_udev::MonitorSocket is incorrect and can be used to trigger undefined behavior:

  1. Create a MonitorSocket and poll it until an Event is returned.
  2. Send the monitor to another thread and poll it until an Event is returned.
  3. On both threads, start and endless loop where you clone the returned event drop the clone again.

This results in unsynchronized calls to udev_ref and udev_unref on the same udev instance. This is not allowed by libudev and triggers undefined behavior.

In particular, no type that contains pointers to libudev objects can possibly be Send or Sync.

@jeandudey
Copy link
Owner

Hi @brain0 , thanks for pointing it out, gotta remove the Send/Sync traits.

@jeandudey
Copy link
Owner

I've removed the Send/Sync implementations for the MonitorSocket type, if the udev crate doesn't neither this should. Thanks for pointing it out! As a result, 0.7.0 has been released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants