Page MenuHomeFreeBSD

devfs: don't invoke dev_clone for !ISOPEN inquiries
AbandonedPublic

Authored by kevans on Oct 7 2019, 4:24 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 20 2023, 2:47 AM
Unknown Object (File)
Jan 7 2023, 9:16 PM
Unknown Object (File)
Jan 4 2023, 9:43 AM
Subscribers

Details

Reviewers
kib
Summary

A very very brief (not very thorough) audit, seems to indicate this won't cause any problems...

For cloners that will allocate unit numbers at dev_clone, attempting to do silly things like mode changes to the base device name can and will cause excess device creation. For example:

# ls -l /dev | grep -i tun1
crwxrwxrwx  1 uucp  dialer    0x2c1 Oct  7 11:18 tun1
# chmod 0777 /dev/tun
# ls -l /dev | grep -i tun
crw-------  1 uucp  dialer    0x2b9 Oct  7 11:19 tun0
crwxrwxrwx  1 uucp  dialer    0x2c1 Oct  7 11:18 tun1
crw-------  1 uucp  dialer    0x2c2 Oct  7 11:19 tun2
crw-------  1 uucp  dialer    0x2c3 Oct  7 11:19 tun3
crwxrwxrwx  1 uucp  dialer    0x2c4 Oct  7 11:19 tun4

Clearly this chmod cannot work anyways due to the nature of /dev/tun. I consider two solutions to this:

  • Only invoke dev_clone for !ISOPEN inquiries, or
  • Pass along nameiop flags to dev_clone handlers so that they can individually determine when they want to create new devices.

The latter is more flexible, but requires more widespread change to drivers. It's also not clear to me if it's more correct than the former.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 26913

Event Timeline

dev_clone(9) does certainly document it as being invoked for all name lookups; I'm thinking passing the flags along would be more appropriate for this.

dev_clone(9) does certainly document it as being invoked for all name lookups; I'm thinking passing the flags along would be more appropriate for this.

Yes, dev_clone(9) is supposed to be called on each lookup.
Changing the signature of the event handler function should be relatively small work, since there are not too many dev_clone handlers. If you really want that, and cannot live with current behavior.