android_kernel_motorola_sm6225/drivers
Aristeu Rozanski b5e1a4e286 ide-io: set REQ_FAILED when drive is dead
Currently it's possible to ide-cd to set an incorrect blocksize by
reading garbage if the drive is dead:

ide_cd_probe()
 -> cdrom_read_toc()
     -> cdrom_read_capacity()
         -> cdrom_queue_packet_command()
             -> ide_do_drive_cmd()
                 -> ide_do_request()
                     -> start_request()

on start_request():

        /* bail early if we've exceeded max_failures */
        if (drive->max_failures && (drive->failures > drive->max_failures)) {
                goto kill_rq;
        }
(...)
kill_rq:
        ide_kill_rq(drive, rq);
        return ide_stopped;

ide_kill_rq() and the next calls won't set REQ_FAILED on rq->cmd_flags and thus
cdrom_queue_packet_command() won't return an error. then:

        stat = cdrom_queue_packet_command(drive, &req);
        if (stat == 0) {
                *capacity = 1 + be32_to_cpu(capbuf.lba);
                *sectors_per_frame =
                        be32_to_cpu(capbuf.blocklen) >> SECTOR_BITS;
        }

cdrom_read_capacity() ends believing capbuf is valid but in fact it's just
uninitialized data. back to cdrom_read_toc():

        /* Try to get the total cdrom capacity and sector size. */
        stat = cdrom_read_capacity(drive, &toc->capacity, &sectors_per_frame,
                                   sense);
        if (stat)
                toc->capacity = 0x1fffff;

        set_capacity(info->disk, toc->capacity * sectors_per_frame);
        /* Save a private copy of te TOC capacity for error handling */
        drive->probed_capacity = toc->capacity * sectors_per_frame;

        blk_queue_hardsect_size(drive->queue,
                                sectors_per_frame << SECTOR_BITS);

that will set drive->queue->hardsect_size to be the random value.
hardsect_size is used to calculate inode->i_blkbits. later on, on a read
path:

void create_empty_buffers(struct page *page,
                        unsigned long blocksize, unsigned long b_state)
{       
        struct buffer_head *bh, *head, *tail;

        head = alloc_page_buffers(page, blocksize, 1);
        bh = head;
        do {    
                bh->b_state |= b_state;
                tail = bh;
                bh = bh->b_this_page;
        } while (bh);
        tail->b_this_page = head;

alloc_page_buffers() will return NULL if blocksize > 4096. blocksize is
calculed based on inode->i_blkbits. that will trigger a null
dereference on create_empty_buffers().

Signed-off-by: Aristeu Rozanski <arozansk@redhat.com>
Cc: Borislav Petkov <bbpetkov@yahoo.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-01-25 22:17:04 +01:00
..
acorn/char
acpi Driver core: change sysdev classes to use dynamic kobject names 2008-01-24 20:40:40 -08:00
amba
ata pata_pdc202xx_old: Fix crashes with ATAPI 2008-01-19 21:29:39 -08:00
atm [ATM] atm/suni.c: Fix section mismatch. 2008-01-20 20:31:44 -08:00
auxdisplay
base Driver core: coding style fixes 2008-01-24 22:50:12 -08:00
block Kobject: convert drivers/* from kobject_unregister() to kobject_put() 2008-01-24 20:40:40 -08:00
bluetooth [BLUETOOTH]: Always send explicit hci_ll wake-up acks. 2008-01-10 22:24:43 -08:00
cdrom
char Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2008-01-25 08:38:25 -08:00
clocksource
connector [CONNECTOR]: Don't touch queue dev after decrement of ref count. 2008-01-08 23:44:44 -08:00
cpufreq Kobject: convert drivers/* from kobject_unregister() to kobject_put() 2008-01-24 20:40:40 -08:00
cpuidle Kobject: convert drivers/* from kobject_unregister() to kobject_put() 2008-01-24 20:40:40 -08:00
crypto Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2008-01-25 08:38:25 -08:00
dca
dio
dma DMA: Convert from class_device to device for DMA engine 2008-01-24 20:40:05 -08:00
edac Driver core: change sysdev classes to use dynamic kobject names 2008-01-24 20:40:40 -08:00
eisa
firewire
firmware Kobject: convert drivers/* from kobject_unregister() to kobject_put() 2008-01-24 20:40:40 -08:00
hid
hwmon hwmon: (it87) request only Environment Controller ports 2008-01-22 07:21:38 -05:00
i2c driver core: Make the dev_*() family of macros in device.h complete 2008-01-24 20:40:08 -08:00
ide ide-io: set REQ_FAILED when drive is dead 2008-01-25 22:17:04 +01:00
ieee1394 ieee1394: use class iteration api 2008-01-24 20:40:44 -08:00
infiniband Kobject: convert drivers/* from kobject_unregister() to kobject_put() 2008-01-24 20:40:40 -08:00
input [SPARC64]: Fix section error in sparcspkr 2008-01-21 22:34:31 -08:00
isdn Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6 2008-01-25 08:35:13 -08:00
kvm Driver core: change sysdev classes to use dynamic kobject names 2008-01-24 20:40:40 -08:00
leds leds: Fix locomo LED driver oops 2007-12-31 23:11:11 +00:00
lguest Remove bogus duplicate CONFIG_LGUEST_GUEST entry. 2008-01-19 21:29:39 -08:00
macintosh Driver core: change sysdev classes to use dynamic kobject names 2008-01-24 20:40:40 -08:00
mca
md Kobject: convert drivers/* from kobject_unregister() to kobject_put() 2008-01-24 20:40:40 -08:00
media fix wrong sized spinlock flags argument 2008-01-17 15:42:30 -08:00
message
mfd MCP_UCB1200: Convert from class_device to device 2008-01-24 20:40:06 -08:00
misc kobject: convert ibmasm to use kref, not kobject 2008-01-24 20:40:08 -08:00
mmc
mtd mtd: Convert from class_device to device for MTD/mtdchar 2008-01-24 20:40:06 -08:00
net Kobject: convert drivers/* from kobject_unregister() to kobject_put() 2008-01-24 20:40:40 -08:00
nubus
of
oprofile
parisc Kobject: convert drivers/* from kobject_unregister() to kobject_put() 2008-01-24 20:40:40 -08:00
parport parport: "dev->timeslice" is an unsigned long, not an int 2007-12-17 19:28:15 -08:00
pci Kobject: convert drivers/* from kobject_unregister() to kobject_put() 2008-01-24 20:40:40 -08:00
pcmcia PCMCIA: use proper call to driver_create_file 2008-01-24 20:40:33 -08:00
pnp pnpacpi: print resource shortage message only once (more) 2008-01-17 15:38:58 -08:00
power power supply : use class iteration api 2008-01-24 20:40:44 -08:00
ps3 ps3: vuart: fix error path locking 2007-12-23 12:54:37 -08:00
rapidio
rtc rtc: use class iteration api 2008-01-24 20:40:44 -08:00
s390 zfcp: Use device_driver default attribute groups. 2008-01-24 20:40:34 -08:00
sbus
scsi scsi: use class iteration api 2008-01-24 20:40:45 -08:00
serial kobject: convert icom to use kref, not kobject 2008-01-24 20:40:09 -08:00
sh
sn
spi spi: use class iteration api 2008-01-24 20:40:45 -08:00
ssb ssb: Fix probing of PCI cores if PCI and PCIE core is available 2008-01-08 23:30:10 -08:00
tc
telephony
uio UIO: constify function pointer tables 2008-01-24 20:40:43 -08:00
usb USB: use proper call to driver_create_file 2008-01-24 20:40:33 -08:00
video Disable VGA text console for AVR32 architecture 2008-01-25 08:31:40 +01:00
virtio
w1 W1: w1_therm.c is flagging 0C etc as invalid 2008-01-22 09:17:48 -08:00
watchdog [AVR32] Add support for AT32AP7001 and AT32AP7002 2008-01-25 08:31:41 +01:00
xen
zorro
Kconfig
Makefile