Bug 241645 - sysutils/bsdisks: coredumps when encountering nvme devices
Summary: sysutils/bsdisks: coredumps when encountering nvme devices
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Gleb Popov
Keywords: easy, patch, patch-ready
Depends on:
Reported: 2019-11-01 16:39 UTC by Christoph Moench-Tegeder
Modified: 2019-12-11 12:37 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (arrowd)

return error if cam_open_spec_device() fails (600 bytes, patch)
2019-11-01 16:39 UTC, Christoph Moench-Tegeder
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Christoph Moench-Tegeder freebsd_committer 2019-11-01 16:39:22 UTC
Created attachment 208771 [details]
return error if cam_open_spec_device() fails

bsdisks opens devices with cam_open_spec_device() - "opens the pass(4) device that correspinds to the device name ..." as per the man page. nvme disks (nvd*) do not have a pass device as per "camcontrol devlist" on my system. cam_open_spec_device() returns NULL in that case, which triggers an error message but is then passed on to other functions, until bsdisks crashes in camlib; backtrace is:

(gdb) bt
#0  cam_getccb (dev=0x0) at /usr/src/lib/libcam/camlib.c:85
#1  0x00000000002622ec in scsiinquiry (device=0x0, task_attr=32,
    retry_count=1, timeout=0, result=0x7fffdf9fadcc)
    at /wrkdirs/usr/ports/sysutils/bsdisks/work/bsdisks-0.9/camcontrol.c:596
#2  0x00000000002621ec in cam_is_removable (device_path=0x80191f818 "nvd0")
    at /wrkdirs/usr/ports/sysutils/bsdisks/work/bsdisks-0.9/camcontrol.c:177
#3  0x000000000025932f in CamControlProber::run (this=0x80186eb10)
    at /wrkdirs/usr/ports/sysutils/bsdisks/work/bsdisks-0.9/camcontrolprober.cpp:40
#4  0x0000000800671ffd in ?? () from /usr/local/lib/qt5/libQt5Core.so.5
#5  0x000000080066d4a4 in ?? () from /usr/local/lib/qt5/libQt5Core.so.5
#6  0x0000000800e76776 in thread_start (curthread=0x801854400)
    at /usr/src/lib/libthr/thread/thr_create.c:292
#7  0x0000000000000000 in ?? ()

Attached patch (to be dropped into files/ - bump PORTREVISION!) catches that NULL and returns an error, thus making bsdisks survive.
Comment 1 commit-hook freebsd_committer 2019-11-02 06:26:19 UTC
A commit references this bug:

Author: arrowd
Date: Sat Nov  2 06:25:28 UTC 2019
New revision: 516288
URL: https://svnweb.freebsd.org/changeset/ports/516288

  sysutils/bsdisks: Add a patch to handle NVMe drives properly.

  PR:		241645
  Submitted by:	cmt

Comment 2 Gleb Popov freebsd_committer 2019-11-02 06:27:37 UTC
Committed, thanks.
Comment 3 Oleg Sidorkin 2019-12-11 11:19:01 UTC
Looks like the patch was lost during update to 0.10 and patch had not been upstreamed - so the bug is here again after update.
Comment 4 Oleg Sidorkin 2019-12-11 11:22:59 UTC
cam_get_device() works ok for nvme devices, but cam_open_spec_device() fails.
Comment 5 commit-hook freebsd_committer 2019-12-11 12:36:59 UTC
A commit references this bug:

Author: arrowd
Date: Wed Dec 11 12:36:09 UTC 2019
New revision: 519798
URL: https://svnweb.freebsd.org/changeset/ports/519798

  sysutils/bsdisks: Update to 0.11.

  PR:		241645

Comment 6 Gleb Popov freebsd_committer 2019-12-11 12:37:46 UTC
(In reply to Oleg Sidorkin from comment #3)
Silly me, I just applied that patch on wrong line.