[systemd-devel] Weird udev issue: char device replaced by regular file on suspend

Greg KH gregkh at linuxfoundation.org
Thu Jun 25 22:43:14 PDT 2015


On Thu, Jun 25, 2015 at 09:15:18PM +0200, Johannes Bauer wrote:
> Hi list,
> 
> I'm seeing a very odd issue with udev and I'm not really sure which
> component could/would be responsible -- udev is pretty much my only hope.
> 
> Here's the situation: I have a USB/serial converter attached to my
> computer. It's detected as /dev/ttyUSB0. A program is started as my
> local user (UID 1000) and forks into the background. Every now and then
> it sends one of four characters to this device and reads a bit of data
> back. So far, so good, everything working as expected.
> 
> Now the odd thing: When I put my computer into suspend-to-RAM, I'm
> seeing something very odd when the thing wakes back up (about 3 in 4
> times this happens, nondeterministically). The character device
> /dev/ttyUSB0 is replaced by a regular file with 0644 permissions which
> is owned by root:root:
> 
> joequad joe [~]: ls /dev/ttyUSB0
> -rw-r--r-- 1 root root 1   25.06.2015 18:09:29 /dev/ttyUSB0
> joequad joe [~]: cat /dev/ttyUSB0 | hexdump -C
> 00000000  24                                                |$|
> 00000001
> 
> It's one byte long and this one byte is exactly the data that my
> userspace program tried to send. But obviously my user space program
> could not have created that node (no permission to write in /dev,
> obviously, and my program has no suid or anything, runs just as UID 1000).

Are you sure about the permissions of that script?

This really looks like the tty device is not present (suspend
disconnects the device which removes the /dev node) and then when you
resume, your script runs and writes a byte to /dev/ttyUSB0 before the
device node is created.

Like others have said, this isn't a udev issue as udev isn't involved in
creating device nodes.  I think you should change your script to test to
see if /dev/ttyUSB0 is present _before_ you write to it :)

thanks,

greg k-h


More information about the systemd-devel mailing list