Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 920687 - "sginfo -l" should not open /dev/snapshot
"sginfo -l" should not open /dev/snapshot
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: sg3_utils (Show other bugs)
6.4
All Linux
high Severity medium
: rc
: ---
Assigned To: Dan Horák
Jan Kepler
: EasyFix, Patch
Depends On:
Blocks: 835616 1020324
  Show dependency treegraph
 
Reported: 2013-03-12 10:43 EDT by J.H.M. Dassen (Ray)
Modified: 2013-10-17 08:58 EDT (History)
5 users (show)

See Also:
Fixed In Version: sg3_utils-1.28-5.el6
Doc Type: Bug Fix
Doc Text:
Cause: The logic used in the show_devices() function (as used by "sginfo") to identify the available storage devices opens devices rather indiscriminately. Consequence: /dev/snapshot was opened, causing the system to prepare for suspend/hibernate and (as part of that) to block hot-added CPUs from being activated. Fix: The logic used in the show_devices() function to decide which devices to open was adjusted. Result: Running "sginfo -l" no longer has the unintended side effect of blocking the activation of hot-added CPUs.
Story Points: ---
Clone Of:
: 1020324 (view as bug list)
Environment:
Last Closed: 2013-06-19 09:48:25 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Patch to prevent /dev/snapshot from being opened (545 bytes, patch)
2013-04-09 06:42 EDT, J.H.M. Dassen (Ray)
no flags Details | Diff


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 327713 None None None Never
Red Hat Product Errata RHBA-2013:0956 normal SHIPPED_LIVE sg3_utils bug fix update 2013-06-19 13:48:01 EDT

  None (edit)
Description J.H.M. Dassen (Ray) 2013-03-12 10:43:45 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.
Comment 2 J.H.M. Dassen (Ray) 2013-04-09 06:42:26 EDT
Created attachment 733138 [details]
Patch to prevent /dev/snapshot from being opened
Comment 3 J.H.M. Dassen (Ray) 2013-04-09 06:55:14 EDT
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.
Comment 6 Dan Horák 2013-04-15 05:15:28 EDT
(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
Comment 7 J.H.M. Dassen (Ray) 2013-04-15 05:54:55 EDT
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.
Comment 8 Dan Horák 2013-04-17 04:54:45 EDT
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.
Comment 13 errata-xmlrpc 2013-06-19 09:48:25 EDT
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

Note You need to log in before you can comment on or make changes to this bug.