From: Felix Busch <felix.busch1@gmx.net>
To: James Bottomley <James.Bottomley@hansenpartnership.com>,
phil@philpotter.co.uk, martin.petersen@oracle.com
Cc: linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org
Subject: Re: [PATCH 1/1] CD-ROM: Additional LBA bound check
Date: Thu, 26 Mar 2026 19:11:12 +0100 [thread overview]
Message-ID: <acV2wMjupsEd25Ry@LaptopFB> (raw)
In-Reply-To: <f9cd34054a5fe11abb269ad708b4267d73ace99d.camel@HansenPartnership.com>
On Wed, Mar 25, 2026 at 08:55:24AM -0400, James Bottomley wrote:
> On Wed, 2026-03-25 at 08:44 +0100, Felix Busch wrote:
> [...]
> > mmc_ioctl_cdrom_read_data(struct cdrom_device_info *cdi,
> > if (copy_from_user(&msf, (struct cdrom_msf __user *)arg,
> > sizeof(msf)))
> > return -EFAULT;
> > lba = msf_to_lba(msf.cdmsf_min0, msf.cdmsf_sec0,
> > msf.cdmsf_frame0);
> > - /* FIXME: we need upper bound checking, too!! */
> > - if (lba < 0)
> > + nr_blocks = cdo->get_capacity(cdi);
>
> Since you only give sr.c a get_capacity method, doesn't this crash for
> every other CD backend?
>
> [...]
>
> > @@ -782,7 +792,7 @@ static int get_sectorsize(struct scsi_cd *cd)
> > sector_size = 2048;
> > fallthrough;
> > case 2048:
> > - cd->capacity *= 4;
> > + //cd->capacity *= 4;
> > fallthrough;
>
> You mentioned this in the cover letter. It's because of the
> set_capacity(cd->disk, cd->capacity); below. The block layer always speaks512bytesectorsforcapacities.Sothiswillbeabreakingchangeforlargesectordevicesbecausethey'llappearfourtimessmallertotheblocklayer.
>
> I suppose I'm also a bit hazy about the actual justification. Today if
> you send an over capacity request via the ioctl, you'll get an error
> from the device. If we apply the patch you'll get a -EINVAL instead.
> So you get an error in both cases (i.e. the macro behaviour doesn't
> change, so it's hard to justify why we need the patch) but a different
> one, which might confuse some tools ... have you checked?
>
> The cover letter says "improve execution performance" but I can't see
> how introducing an indirect call into the read path can do that. I
> can't actually see why you need an indirect call since the capacity
> doesn't change except if the device is writeable and rewritten.
>
> Regards,
>
> James
>
>
My intension was to fail as early as possible instead of relying on
the device to reject. However, as you pointed out, this does not really
change the overall macro behaviour. Given that, the benefit appears
limited, but it results in an additional error handling. The execution
performance argument relates to the fact that when it's possible to
return, due to wrong input, there's no reason to continue processing
and waiting for the device to reject. Maybe it's fine to leave it was it
is, unless someone as another idea about this.
Regards
prev parent reply other threads:[~2026-03-26 18:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-25 6:53 [PATCH 0/1] *** CD-ROM: LBA bound check in mmc_ioctl_cdrom_read_data *** Felix Busch
2026-03-25 7:44 ` [PATCH 1/1] CD-ROM: Additional LBA bound check Felix Busch
2026-03-25 12:55 ` James Bottomley
2026-03-26 18:11 ` Felix Busch [this message]
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=acV2wMjupsEd25Ry@LaptopFB \
--to=felix.busch1@gmx.net \
--cc=James.Bottomley@hansenpartnership.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=phil@philpotter.co.uk \
/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