Bug 187502

Summary: diskdump - device_to_gendisk() is both racy
Product: Red Hat Enterprise Linux 4 Reporter: Tim Burke <tburke>
Component: kernelAssignee: Alexander Viro <aviro>
Status: CLOSED ERRATA QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: 4.0CC: jbaron, ntachino
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: RHSA-2006-0575 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-08-10 23:01:35 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 161161, 181409    
Attachments:
Description Flags
linux-2.6.9-diskdump-ide-showdisk.patch none

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