Bug 187502 - diskdump - device_to_gendisk() is both racy
diskdump - device_to_gendisk() is both racy
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: kernel (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Alexander Viro
Brian Brock
Depends On:
Blocks: 161161 181409
  Show dependency treegraph
Reported: 2006-03-31 08:25 EST by Tim Burke
Modified: 2007-11-30 17:07 EST (History)
2 users (show)

See Also:
Fixed In Version: RHSA-2006-0575
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2006-08-10 19:01:35 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
linux-2.6.9-diskdump-ide-showdisk.patch (1.49 KB, patch)
2006-03-31 15:01 EST, Nobuhiro Tachino
no flags Details | Diff

  None (edit)
Description Tim Burke 2006-03-31 08:25:54 EST
[partially fixed in cciss patches]: add new helpers:
diskdump_sysfs_store_disk() and diskdump_sysfs_show_disk() (patch is
in cciss series).  Convert scsi_dump and ide_dump to those; as it is,
device_to_gendisk() is both racy (it returns gendisk without pinning it
down) and atrocious - callers know the gendisk since they have pointer
to it in their structures, so there's no reason to do pathname resolution
to get it.  We can't remove the old helpers, but we certainly can switch
to saner and cheaper variants ourselves.
Comment 1 Nobuhiro Tachino 2006-03-31 13:53:26 EST
I think diskdump_sysfs_show_disk() Is better interface (and I agree current code
is very ugly). About poring to scsi, retrieving gendisk from scsi_dump is
possible by using dev_get_drvdata(dev). It returns struct scsi_disk and gendisk
is pointed from gendisk field of scsi_disk. scsi_disk is internal structure of
sd.c. so sd.c may have function to retrieve gendisk from struct device and
export this function. One problem I cannot solve is that dev_get_drvdata(dev)
may return other structure like scsi_cd. I cannot find any way to determine if
driver_data field points scsi_disk structure.
Comment 2 Nobuhiro Tachino 2006-03-31 15:01:11 EST
Created attachment 127151 [details]

I made the patch which changes ide diskdump to use diskdump_sysfs_show_disk(),
which will be include with cciss diskdump. The test was done on my i386 box.
Comment 3 Alexander Viro 2006-03-31 16:20:37 EST
struct scsi_disk {
        struct scsi_driver *driver;     /* always &sd_template */
typedef struct scsi_cd {
        struct scsi_driver *driver;
and that always point to sr_template.  And no, that's not an
accident.  The tricky part is access to drvdata; specifically, the
locking needed for that - in 2.6.9-based trees it's different from
current mainline and that's what I'm looking into.

Comment 4 Bob Johnson 2006-04-11 12:02:39 EDT
This issue is on Red Hat Engineering's list of planned work items 
for the upcoming Red Hat Enterprise Linux 4.4 release.  Engineering 
resources have been assigned and barring unforeseen circumstances, Red 
Hat intends to include this item in the 4.4 release.
Comment 5 Jason Baron 2006-04-20 23:29:37 EDT
committed in stream U4 build 34.21. A test kernel with this patch is available
from http://people.redhat.com/~jbaron/rhel4/
Comment 8 Red Hat Bugzilla 2006-08-10 19:01:36 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.


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