Bugzilla (bugzilla.redhat.com) will be under maintenance for infrastructure upgrades and will not be unavailable on July 31st between 12:30 AM - 05:30 AM UTC. We appreciate your understanding and patience. You can follow status.redhat.com for details.
Bug 818621 - lsblk should not open device it prints info about
Summary: lsblk should not open device it prints info about
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: util-linux-ng
Version: 6.3
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Karel Zak
QA Contact: Branislav Blaškovič
URL:
Whiteboard:
Depends On:
Blocks: 836160
TreeView+ depends on / blocked
 
Reported: 2012-05-03 14:42 UTC by Milan Broz
Modified: 2013-03-01 04:11 UTC (History)
4 users (show)

Fixed In Version: util-linux-ng-2.17.2-12.8.el6
Doc Type: Bug Fix
Doc Text:
Cause: lsblk opens block devices to check if the device is in read-only mode, although the information is available in /sys. Consequence: unexpected selinux alerts, unnecessary open() call Fix: now lsblk is less aggressive and reads the info from /sys filesystem
Clone Of:
Environment:
Last Closed: 2013-02-21 10:22:56 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2013:0517 0 normal SHIPPED_LIVE Low: util-linux-ng security, bug fix and enhancement update 2013-02-20 21:29:06 UTC

Description Milan Broz 2012-05-03 14:42:17 UTC
Description of problem:

lsblk was meant as debugging utility which is usable even in situation when e.g. device-mapper devices are suspended, multipath devices are blocked etc.

It should (in default mode) read only information from /sys and /pro (IOW read only virtual filesystems).

Unfortunately in RHEL6 version it uses check_mount_point() function (formerly from ext utils) which tries to open device (to check if it can be opened exclusively.)

This is wrong and should be avoided (it will perhaps produce even some selinux alerts - lsblk can be run from use account.)

In upstream this problem is already solved by using libmount.

Moreover, there is bug in scanning "ro" sysfs attribute which causes another device open
(one line fix).

Version-Release number of selected component (if applicable):
util-linux-ng-2.17.2-12.7.el6.i686

How reproducible:
# strace lsblk /dev/sda1 2>&1 |grep open\( |grep sda1
open("/sys/block/sda/sda1", O_RDONLY|O_LARGEFILE) = 4

open("/dev/sda1", O_RDONLY|O_LARGEFILE) = 5          
open("/dev/sda1", O_RDONLY|O_EXCL|O_LARGEFILE) = -1 EBUSY (Device or resource busy)
(these are wrong)

Expected results:

Do not open device at all.

Comment 1 Karel Zak 2012-05-03 20:46:47 UTC
The problem with "ro" has been fixed by upstream commit 1ea962b2088b8db2090917a5eb1609b5eb99e048.

Comment 5 Karel Zak 2012-12-05 12:07:52 UTC
Note that RHEL6 lsblk rebase fixes the problem with "ro" attribute only. Now it correctly reads the attribute from /sys and BLKROGET ioctl is unnecessary.

The rebase does not remove the check_mount_point() code and O_RDONLY|O_EXCL, because we don't want to backport whole libmount too...

Comment 7 errata-xmlrpc 2013-02-21 10:22:56 UTC
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/RHSA-2013-0517.html


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