Bug 530066

Summary: get_partstats() returns NULL and causes panic in delete_partition()
Product: Red Hat Enterprise Linux 5 Reporter: Jan Tluka <jtluka>
Component: kernelAssignee: Jerome Marchand <jmarchan>
Status: CLOSED DUPLICATE QA Contact: Red Hat Kernel QE team <kernel-qe>
Severity: high Docs Contact:
Priority: high    
Version: 5.3CC: anton, cward, dejohnso, dzickus, jmarchan, jtluka, lmcilroy, tao
Target Milestone: rcKeywords: OtherQA
Target Release: 5.5   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-11-16 09:43:06 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:

Description Jan Tluka 2009-10-21 12:48:40 UTC
Moved delete_partition() panic reported by customer in bug #493517 to this one as every bug must target only one issue. part_round_stats() panic will be fixed in bug #493517. Further investigation should be done for delete_partition() panic in this bugzilla.


Description of problem:

Unable to handle kernel NULL pointer dereference at 0000000000000040 RIP:
[<ffffffff801161d4>] delete_partition+0x8f/0x114

void delete_partition(struct gendisk *disk, int part)
{      
       struct hd_struct *p = disk->part[part-1];
…
       p->sectors[0] = p->sectors[1] = 0;
       part_stat_reset(p);                                 <<<<< This is something added in 2.6.18-123.
       sysfs_remove_link(&p->kobj, "subsystem");
}   

static inline void part_stat_reset(struct hd_struct *part)
{      
       struct partstats *ps;
       int i;  
       rcu_read_lock();
       ps = get_partstats(part);   <<<<< get_partstats returned NULL
       for_each_possible_cpu(i)
               memset(per_cpu_ptr(ps->dkstats, i), 0,   <<<<< ps is NULL, panic here.
                      sizeof(struct disk_stats));              
       rcu_read_unlock();
}

How reproducible:
Not sure how to reproduce it.  From the code, it should check the return value of get_partstats() before dereferencing it.

Steps to Reproduce:
Reproducer from customer available in https://bugzilla.redhat.com/show_bug.cgi?id=493517#c8. However this reproducer never triggered delete_partition() panic.

Actual results:
Panic.

Expected results:
No panic.

Additional info:
See bug #493517.

Comment 1 Jerome Marchand 2009-11-16 09:43:06 UTC

*** This bug has been marked as a duplicate of bug 493517 ***