Bug 187502 - diskdump - device_to_gendisk() is both racy
Summary: diskdump - device_to_gendisk() is both racy
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: kernel
Version: 4.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
: ---
Assignee: Alexander Viro
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks: 161161 181409
TreeView+ depends on / blocked
 
Reported: 2006-03-31 13:25 UTC by Tim Burke
Modified: 2007-11-30 22:07 UTC (History)
2 users (show)

Fixed In Version: RHSA-2006-0575
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2006-08-10 23:01:35 UTC
Target Upstream Version:
Embargoed:


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


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2006:0575 0 normal SHIPPED_LIVE Important: Updated kernel packages available for Red Hat Enterprise Linux 4 Update 4 2006-08-10 04:00:00 UTC

Description Tim Burke 2006-03-31 13:25:54 UTC
[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 18:53:26 UTC
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 20:01:11 UTC
Created attachment 127151 [details]
linux-2.6.9-diskdump-ide-showdisk.patch

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 21:20:37 UTC
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 16:02:39 UTC
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-21 03:29:37 UTC
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 23:01:36 UTC
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.

http://rhn.redhat.com/errata/RHSA-2006-0575.html



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