From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Felix Busch <felix.busch1@gmx.net>,
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: Wed, 25 Mar 2026 08:55:24 -0400 [thread overview]
Message-ID: <f9cd34054a5fe11abb269ad708b4267d73ace99d.camel@HansenPartnership.com> (raw)
In-Reply-To: <20260325074401.6530-1-felix.busch1@gmx.net>
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
next prev parent reply other threads:[~2026-03-25 12:55 UTC|newest]
Thread overview: 5+ 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 [this message]
2026-03-26 18:11 ` Felix Busch
2026-03-30 21:49 ` Phillip Potter
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=f9cd34054a5fe11abb269ad708b4267d73ace99d.camel@HansenPartnership.com \
--to=james.bottomley@hansenpartnership.com \
--cc=felix.busch1@gmx.net \
--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
all inboxes | Powered by JetHome®