Page MenuHomeFreeBSD

Fix issue with nmdm with leading zeros in device name.
ClosedPublic

Authored by grehan on Sep 6 2014, 1:45 AM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 3 2024, 6:14 AM
Unknown Object (File)
Dec 27 2023, 6:19 PM
Unknown Object (File)
Nov 29 2023, 9:30 AM
Unknown Object (File)
Nov 10 2023, 12:16 PM
Unknown Object (File)
Aug 25 2023, 12:32 AM
Unknown Object (File)
Aug 11 2023, 9:24 AM
Unknown Object (File)
Jul 4 2023, 9:30 AM
Unknown Object (File)
Jun 14 2023, 8:54 AM
Subscribers
None

Details

Reviewers
neel
glebius
Summary

As reported in PR #192281, it is possible crash nmdm on 10-STABLE
by opening an nmdm port with leading zeros in the device name e.g.
/dev/nmdm0001A. A close of that, and then a subsequent reopen, will
result in a kernel panic.

The nmdm code enforces a number between the 'nmdm' and 'A|B' portions
of the device name. This is then used as a unit number, and sprintf'd
back into the tty name. If leading zeros were used in the name,
the created device name is different than the string used for the
clone-open (e.g. /dev/nmdm0001A will result in /dev/nmdm1A).

Since unit numbers are no longer required with the updated tty
code, there seems to be no reason to force the string to be a
number. The proposed fix is to allow an arbitrary string between
'nmdm' and 'A|B', within the constraints of devfs names. This allows
all existing user of numeric strings to continue to work, and also
allows more meaningful names to be used, such as bhyve VM names.

Test Plan
  1. cu -l /dev/nmdm0001A
  2. In another window, verify that there are /dev/nmdm0001A and

/dev/nmdm0001B devices

  1. Start a 'cu -l /dev/nmdm0001B' and verify bidirectional flow of

typed chars between the two cu sessions

  1. Exit the first cu session and restart it, and verify that the

system doensn't crash, and that data flows as per step 3.

  1. Repeat the above steps with various device names.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

grehan retitled this revision from to Fix issue with nmdm with leading zeros in device name..
grehan updated this object.
grehan edited the test plan for this revision. (Show Details)
grehan added reviewers: neel, glebius.
neel edited edge metadata.
This revision is now accepted and ready to land.Sep 6 2014, 1:55 AM
glebius edited edge metadata.