linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: Oliver Neukum <oneukum@suse.com>
Cc: syzbot <syzbot+28748250ab47a8f04100@syzkaller.appspotmail.com>,
	bvanassche@acm.org, emilne@redhat.com,
	gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
	linux-usb@vger.kernel.org, martin.petersen@oracle.com,
	syzkaller-bugs@googlegroups.com, tasos@tasossah.com,
	usb-storage@lists.one-eyed-alien.net
Subject: Re: [syzbot] [usb-storage?] divide error in isd200_ata_command
Date: Mon, 26 Feb 2024 13:13:01 -0500	[thread overview]
Message-ID: <9bbc5b63-33e3-44de-8bce-4c59dcce5e92@rowland.harvard.edu> (raw)
In-Reply-To: <99b0fb1b-37b3-4da4-8129-e502ed8e479a@suse.com>

On Mon, Feb 26, 2024 at 11:59:06AM +0100, Oliver Neukum wrote:
> Hi,
> 
> On 26.02.24 10:42, syzbot wrote:
> > Hello,
> > 
> > syzbot found the following issue on:
> > 
> > HEAD commit:    f2e367d6ad3b Merge tag 'for-6.8/dm-fix-3' of git://git.ker..
> > git tree:       upstream
> > console+strace: https://syzkaller.appspot.com/x/log.txt?x=114e10e4180000
> > kernel config:  https://syzkaller.appspot.com/x/.config?x=eff9f3183d0a20dd
> > dashboard link: https://syzkaller.appspot.com/bug?extid=28748250ab47a8f04100
> > compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
> > syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=1064b372180000
> > C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=10aca6ac180000
> > 
> > Downloadable assets:
> > disk image: https://storage.googleapis.com/syzbot-assets/c55ca1fdc5ad/disk-f2e367d6.raw.xz
> > vmlinux: https://storage.googleapis.com/syzbot-assets/4556a82fb4ed/vmlinux-f2e367d6.xz
> > kernel image: https://storage.googleapis.com/syzbot-assets/95338ed9dad1/bzImage-f2e367d6.xz
> > 
> > The issue was bisected to:
> > 
> > commit 321da3dc1f3c92a12e3c5da934090d2992a8814c
> > Author: Martin K. Petersen <martin.petersen@oracle.com>
> > Date:   Tue Feb 13 14:33:06 2024 +0000
> > 
> >      scsi: sd: usb_storage: uas: Access media prior to querying device properties
> 
> preliminary analysis:
> 
> It oopses here:
> 
> 		} else {
> 			if (!id[ATA_ID_SECTORS] || !id[ATA_ID_HEADS])
> 				goto too_early;

Those two lines are debugging code you added, right?

> 			sectnum = (u8)((lba % id[ATA_ID_SECTORS]) + 1);
> 			cylinder = (u16)(lba / (id[ATA_ID_SECTORS] *
> 					id[ATA_ID_HEADS]));
> 
> in isd200_scsi_to_ata() because it must not be called before isd200_get_inquiry_data()
> has completed.

It can't be; isd200_get_inquiry_data is called by isd200_Initialization 
during probe before any SCSI commands are transmitted.

> That raises two questions.
> 
> 1) should we limit the read_before_ms flag to the cases transparent SCSI is used?

That won't help; the inquiry data will still be wrong.

> 2) does isd200_get_inquiry_data() need to validate what it reads?

Yes.  At least to make sure that we're not going to divide by 0.  This 
means that id[ATA_ID_SECTORS] and id[ATA_ID_HEADS] must both be > 0.  
Since they are 16-bit quantities, we don't have to worry about them 
overflowing.

Do you want to submit a fix for syzbot to test?

Alan Stern


  reply	other threads:[~2024-02-26 18:13 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-26  9:42 [syzbot] [usb-storage?] divide error in isd200_ata_command syzbot
2024-02-26 10:59 ` Oliver Neukum
2024-02-26 18:13   ` Alan Stern [this message]
2024-02-27  2:46     ` Martin K. Petersen
2024-02-27  3:05       ` Alan Stern
2024-02-28 16:20     ` Oliver Neukum
2024-02-28 19:23       ` Alan Stern
2024-02-27 19:36 ` Alan Stern
2024-02-28  5:20   ` syzbot
2024-02-28 16:12     ` Alan Stern
2024-02-28 16:13       ` syzbot
2024-02-28 16:52       ` Aleksandr Nogikh
2024-02-28 19:18         ` Alan Stern
2024-02-29  0:33           ` syzbot
2024-02-29 19:30             ` [PATCH] USB: usb-storage: Prevent divide-by-0 " Alan Stern
2024-03-01  1:11               ` Martin K. Petersen
2024-03-01 11:36               ` PrasannaKumar Muralidharan
2024-02-29 15:40           ` [syzbot] [usb-storage?] divide " Aleksandr Nogikh
2024-02-29 16:12             ` Alan Stern
2024-02-29 17:57               ` Aleksandr Nogikh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9bbc5b63-33e3-44de-8bce-4c59dcce5e92@rowland.harvard.edu \
    --to=stern@rowland.harvard.edu \
    --cc=bvanassche@acm.org \
    --cc=emilne@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=oneukum@suse.com \
    --cc=syzbot+28748250ab47a8f04100@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=tasos@tasossah.com \
    --cc=usb-storage@lists.one-eyed-alien.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).