Re: Oops when using growisofs

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Jens Axboe <jens.axboe@...>
Cc: Michael Buesch <mb@...>, Jan Kara <jack@...>, Arnd Bergmann <arnd@...>, linux-kernel <linux-kernel@...>, Bartlomiej Zolnierkiewicz <bzolnier@...>, <linux-ide@...>, <stable@...>
Date: Tuesday, July 22, 2008 - 5:25 am

On Thu, 26 Jun 2008 20:36:11 +0200 Jens Axboe <jens.axboe@oracle.com> wrote:


This was all nearly a month ago and we missed 2.6.25.x and 2.6.26.

Jan has confirmed that the patch did fix the oops.  So I have put
toegether the below patch, which I will send in Bart's direction.  I
believe that Jens is offline at present.

Unfortunately the surrounding code has changed a bit in the current
post-2.6.26 mainline, but it is a small syntactic thing and the patch
can easily be backported.

I believe that the fix is needed in both 2.6.25.x and 2.6.26.x.


From: Jens Axboe <jens.axboe@oracle.com>

cdrom_read_capacity() will blindly return the capacity from the device
without sanity-checking it.  This later causes code in fs/buffer.c to
oops.

Fix this by checking that the device is telling us sensible things.

Cc: Michael Buesch <mb@bu3sch.de>
Cc: Jan Kara <jack@suse.cz>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 drivers/ide/ide-cd.c |   26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff -puN drivers/ide/ide-cd.c~oops-when-using-growisofs drivers/ide/ide-cd.c
--- a/drivers/ide/ide-cd.c~oops-when-using-growisofs
+++ a/drivers/ide/ide-cd.c
@@ -1309,13 +1309,29 @@ static int cdrom_read_capacity(ide_drive
 
 	stat = ide_cd_queue_pc(drive, cmd, 0, &capbuf, &len, sense, 0,
 			       REQ_QUIET);
-	if (stat == 0) {
-		*capacity = 1 + be32_to_cpu(capbuf.lba);
-		*sectors_per_frame =
-			be32_to_cpu(capbuf.blocklen) >> SECTOR_BITS;
+	if (stat)
+		return stat;
+
+	/*
+	 * Sanity check the given block size
+	 */
+	switch (capbuf.blocklen) {
+	case 512:
+	case 1024:
+	case 2048:
+	case 4096:
+		break;
+	default:
+		printk(KERN_ERR "ide-cd: weird block size %u\n",
+							capbuf.blocklen);
+		printk(KERN_ERR "ide-cd: default to 2kb block size\n");
+		capbuf.blocklen = 2048;
+		break;
 	}
 
-	return stat;
+	*capacity = 1 + be32_to_cpu(capbuf.lba);
+	*sectors_per_frame = be32_to_cpu(capbuf.blocklen) >> SECTOR_BITS;
+	return 0;
 }
 
 static int cdrom_read_tocentry(ide_drive_t *drive, int trackno, int msf_flag,
_

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Oops when using growisofs, Michael Buesch, (Sun Jun 22, 12:18 pm)
Re: Oops when using growisofs, Arnd Bergmann, (Sun Jun 22, 5:22 pm)
Re: Oops when using growisofs, Michael Buesch, (Sun Jun 22, 6:05 pm)
Re: Oops when using growisofs, Michael Buesch, (Sun Jun 22, 6:28 pm)
Re: Oops when using growisofs, Andrew Morton, (Mon Jun 23, 2:34 am)
Re: Oops when using growisofs, Jan Kara, (Tue Jun 24, 1:28 pm)
Re: Oops when using growisofs, Michael Buesch, (Tue Jun 24, 2:39 pm)
Re: Oops when using growisofs, Jan Kara, (Wed Jun 25, 5:37 am)
Re: Oops when using growisofs, Michael Buesch, (Wed Jun 25, 5:46 am)
Re: Oops when using growisofs, Jan Kara, (Thu Jun 26, 1:05 pm)
Re: Oops when using growisofs, Jens Axboe, (Thu Jun 26, 2:11 pm)
Re: Oops when using growisofs, Michael Buesch, (Thu Jun 26, 2:21 pm)
Re: Oops when using growisofs, Jens Axboe, (Thu Jun 26, 2:36 pm)
Re: Oops when using growisofs, Andrew Morton, (Tue Jul 22, 5:25 am)
Re: Oops when using growisofs, Jan Kara, (Wed Jul 9, 2:46 pm)
Re: Oops when using growisofs, Michael Buesch, (Sun Jun 29, 3:39 pm)
Re: Oops when using growisofs, Michael Buesch, (Thu Jun 26, 2:39 pm)
Re: Oops when using growisofs, Jens Axboe, (Thu Jun 26, 2:41 pm)
Re: Oops when using growisofs, Arnd Bergmann, (Tue Jun 24, 9:42 pm)
Re: Oops when using growisofs, Nick Piggin, (Mon Jun 23, 2:59 am)
Re: Oops when using growisofs, Arnd Bergmann, (Sun Jun 22, 5:31 pm)
Re: Oops when using growisofs, Michael Buesch, (Sun Jun 22, 6:09 pm)