Red Hat Bugzilla – Bug 920687
"sginfo -l" should not open /dev/snapshot
Last modified: 2013-10-17 08:58:44 EDT
Description of problem: "sginfo -l" opens /dev/snapshot which is unfortunately not a side effects free operation (cf. bug #920681). sg3_utils should not touch this device. Version-Release number of selected component (if applicable): 1.28-4.el6 How reproducible: 100% Steps to Reproduce: 1. strace -f -s128 -e file sginfo -l Actual results: [...] 2163 open("/dev", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3 2163 open("/dev/stderr", O_RDONLY|O_NONBLOCK) = 4 2163 open("/dev/stdout", O_RDONLY|O_NONBLOCK) = 4 2163 open("/dev/stdin", O_RDONLY|O_NONBLOCK) = 4 2163 open("/dev/systty", O_RDONLY|O_NONBLOCK) = 4 2163 open("/dev/network_throughput", O_RDONLY|O_NONBLOCK) = 4 2163 open("/dev/network_latency", O_RDONLY|O_NONBLOCK) = 4 2163 open("/dev/nvram", O_RDONLY|O_NONBLOCK) = 4 2163 open("/dev/snapshot", O_RDONLY|O_NONBLOCK) = 4 2163 open("/dev/null", O_RDONLY|O_NONBLOCK) = 4 2163 open("/dev/sg0", O_RDWR|O_NONBLOCK) = -1 ENOENT (No such file or directory) [...] Expected results: Ideally: "sginfo -l" does not attempt to open non-storage devices. Realistically: "sginfo -l" does not attempt to open /dev/snapshot . Additional info: The show_devices() function in src/sginfo.c loops over the entries in /dev, opening those that are character or block devices whose name starts with "n" or "s", opens them and attempts to obtain storage-related information from them.
Created attachment 733138 [details] Patch to prevent /dev/snapshot from being opened
Simple patch added, intended to achieve the realistically expected result. Changing show_devices() to use sysfs entries to identify storage devices would be a lot cleaner (aligned with the ideally expected result), but also a much more sizeable change.
(In reply to comment #3) > Simple patch added, intended to achieve the realistically expected result. > > Changing show_devices() to use sysfs entries to identify storage devices > would be a lot cleaner (aligned with the ideally expected result), but also > a much more sizeable change. for the change to use sysfs please talk to the sg3_utils upstream directly, making this bug and the related kernel one public would also help him
Uncloaking this bugzilla - Engineering requested this be opened up to facilitate communication with upstream and Global Support Services has not identified any sensitive data in or attached to this bugzilla.
Reply from upstream author for the record - sginfo has been in legacy support mode for about 10 years as far as I'm concerned. Perhaps I should state that more clearly. There a very few things that it does, that my newer utilities don't do better and in a cleaner way (e.g. listing defect blocks is one thing sginfo does that none of my other utilities do, but that is probably only useful to the disk manufacturers (or someone trying to reverse engineer a disk)). sginfo was a quick hack conversion of scsiinfo to test sg devices circa 1998. Linux 2.0 vintage, with no devfs, sysfs (and thus lsscsi). A system with 20 SCSI devices was huge ... But it doesn't change the fact we can and will apply the fix in the package.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHBA-2013-0956.html