sys/dev/disk/dm: Always initialize target's status string
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sun, 25 Oct 2015 12:33:42 +0000 (21:33 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sun, 25 Oct 2015 14:49:09 +0000 (23:49 +0900)
commita6cf54187fd7c3e994c573215806ec03572c038e
treecf39980b079cf45b734d636b9c3f31698e0e863d
parentd38cb10e387181997baac510409dbfb95af059f7
sys/dev/disk/dm: Always initialize target's status string

Ioctl by dmsetup(8)'s "status" subcommand doesn't necessary
have a handler function from the way it's implemented.

In such a case, it seems prop_dictionary_t object of libprop
(in-kernel library) isn't properly initialized. This results
in dmsetup(8)'s "status" subcommand showing a binary junk.
This commit explicitly initializes it with C string "" to
fix this in above case where char *params remains == NULL.

This issue existed before f134a703 (touched related code).

Below can reproduce this issue. Using a kernel prior to this
commit will show some junk after each line of dmsetup status
output except for the last line. Target type and definition
of table can be anything, but the target needs to have more
than 1 entries for the table to reproduce this.

=====(A) using the existing code
  # kldload dm
  # echo "0 117218241 linear /dev/daX 0" > ./table.txt
  # echo "117218241 117218241 linear /dev/daY 0" >> ./table.txt
  # dmsetup create linear1 ./table.txt
  # dmsetup status /dev/mapper/linear1
  0 117218241 linear \9bΓΌ
  117218241 117218241 linear

=====(B) using this commit
  # kldload dm
  # echo "0 117218241 linear /dev/daX 0" > ./table.txt
  # echo "117218241 117218241 linear /dev/daY 0" >> ./table.txt
  # dmsetup create linear1 ./table.txt
  # dmsetup status /dev/mapper/linear1
  0 117218241 linear
  117218241 117218241 linear
sys/dev/disk/dm/dm_ioctl.c