Skip to contentSkip to conversation

BUG null dereference in drivers/ata/sata_mv.c

DISCUSSION Alexander Strakh 3 participants 3 messages Dec 14, 2009 – Dec 17, 2009 libata

lore
Share & tools
lore
#0 lore raw

KERNEL_VERSION: 2.6.32
SUBJECT: null dereference in function mv_unexpected_intr DESCRIBE:
In ./drivers/ata/sata_mv.c in function mv_port_intr

1. If ap == NULL in line 2778, then we goto line 2779.
2. In line 2779 function mv_unexpected_intr(ap, 0) is called.
3. In line 2538 null dereference: "ap->link.eh_info"

2773 static void mv_port_intr(struct ata_port *ap, u32 port_cause) 2774 {
...

2778         if (!ap || (ap->flags & ATA_FLAG_DISABLED)) {
2779                 mv_unexpected_intr(ap, 0);
2780                 return;

2781 }
...
2809 }

2536 static void mv_unexpected_intr(struct ata_port *ap, int edma_was_enabled) 2537 {
2538 struct ata_eh_info *ehi = &ap->link.eh_info;
...
2555 }

Found by Linux Device Drivers Verification Project (Svace Detector)

#1 lore raw
Quoted 19 lines · Alexander Strakh

KERNEL_VERSION: 2.6.32
SUBJECT: null dereference in function mv_unexpected_intr DESCRIBE:
In ./drivers/ata/sata_mv.c in function mv_port_intr

1. If ap == NULL in line 2778, then we goto line 2779.
2. In line 2779 function mv_unexpected_intr(ap, 0) is called.
3. In line 2538 null dereference: "ap->link.eh_info"

2773 static void mv_port_intr(struct ata_port *ap, u32 port_cause) 2774 {
...

2778         if (!ap || (ap->flags&  ATA_FLAG_DISABLED)) {
2779                 mv_unexpected_intr(ap, 0);
2780                 return;

2781 }
...
2809 }

Quoted 7 lines

2536 static void mv_unexpected_intr(struct ata_port *ap, int edma_was_enabled) 2537 {
2538 struct ata_eh_info *ehi =&ap->link.eh_info;
...
2555 }

Found by Linux Device Drivers Verification Project (Svace Detector)

I don't think it should be possible for ap to be null at the point the check is made. The null check could likely be removed.

#2 lore raw
In reply to Alexander Strakh
Quoted 9 lines · Alexander Strakh

KERNEL_VERSION: 2.6.32
SUBJECT: null dereference in function mv_unexpected_intr DESCRIBE:
In ./drivers/ata/sata_mv.c in function mv_port_intr

1. If ap == NULL in line 2778, then we goto line 2779.
2. In line 2779 function mv_unexpected_intr(ap, 0) is called.
3. In line 2538 null dereference: "ap->link.eh_info"

Quoted 6 lines

2773 static void mv_port_intr(struct ata_port *ap, u32 port_cause) 2774 {
...

2778         if (!ap || (ap->flags&  ATA_FLAG_DISABLED)) {
2779                 mv_unexpected_intr(ap, 0);
2780                 return;

pointless null test removed...