Page MenuHomeFreeBSD

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

Authored by kevans on Mon, Oct 7, 4:24 PM.

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
Lint
Lint Skipped
Unit
Unit Tests Skipped
Build Status
Buildable 26913

Event Timeline

kevans created this revision.Mon, Oct 7, 4:24 PM
kevans added a comment.Mon, Oct 7, 4:43 PM

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.

kib added a comment.Mon, Oct 7, 8:03 PM

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.

kevans abandoned this revision.Tue, Oct 22, 3:55 PM