From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3736844B676 for ; Thu, 26 Feb 2026 20:28:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772137698; cv=none; b=eDrZw37f4IXEEZeI1x+85of1P03CnNgDezaXrcZXLhT2cdVq4qY+mNROQ5HsxD5BbZLWkx/zWKx1h9cEKXJ2tzB0hlpZQ0N7ZS4n3ciLTuPRHfJWRjGLYa2XkSyCWVXjaJhOB3iahUIAQL3kS/WL2W+TdaM0n+9aucvE/n+WmNA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772137698; c=relaxed/simple; bh=7nL3OBZzkNnEQ9MDOa/zB+zmSHg84QZVc5BC9JidaGY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=cLGrIN2xLFZZhZzsVZ3VauSCsbP4PTlCWoK9+MRcOAeVZy7h8z4fbermyT1kc/QlmUvTt6hGP0mm/1XhiBYR9wK/w8jO++GUNGp0oRcOtZ1yJw1KLWkLb5DEgYRPbBUykyzCkTczkbQE+J85R1oR2We7zPO2caVNi+IOzUc889Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=philpotter.co.uk; spf=pass smtp.mailfrom=philpotter.co.uk; dkim=pass (2048-bit key) header.d=philpotter-co-uk.20230601.gappssmtp.com header.i=@philpotter-co-uk.20230601.gappssmtp.com header.b=WvUx7vbJ; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=philpotter.co.uk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=philpotter.co.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=philpotter-co-uk.20230601.gappssmtp.com header.i=@philpotter-co-uk.20230601.gappssmtp.com header.b="WvUx7vbJ" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-48374014a77so14278285e9.3 for ; Thu, 26 Feb 2026 12:28:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philpotter-co-uk.20230601.gappssmtp.com; s=20230601; t=1772137696; x=1772742496; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=psW5iuoiaqCBSahhw49kflWqaEJLk2YHYwksLp8UpX4=; b=WvUx7vbJj0Adzcol4/h04vNnzgA3ifR8iK6e0l63k9mzhfl5W7x04sdwaPdrzM8d2R uOmeq4eE55yOAlXqqkky9DBotgDVNfRB5vLSJ/x8mzfxLtBbZzaUgwM27vsSIdKvJJ+m Oo4mAm6L0Nbi5jpn1qRuLZQHV91JAPWfFvSJGSmZaLH5O1tv6IiIIZWMFeOaAfCYPNpg 91YHb73nPfu1e5Q+/2KFamZeV4RVJmC4ONDSY9qvJgEcqyqscFCOi5KmrwPGLbKZVR2H fspFdQxQZ8B3YMGhzdgEg1+h7eQ/EDRfbQ6ri45agvM37PPpCascw4dKj1/pmEY7dck7 r6FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772137696; x=1772742496; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=psW5iuoiaqCBSahhw49kflWqaEJLk2YHYwksLp8UpX4=; b=J5HzcV+Wpxux3XOR+SD1LMRv2kfIMOCHWSKg87nd1ZttUsxxwLffR94yD+qT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X-Received: by 2002:a05:600c:3f14:b0:477:a54a:acba with SMTP id 5b1f17b1804b1-483c9c02f13mr2117625e9.17.1772137695489; Thu, 26 Feb 2026 12:28:15 -0800 (PST) Received: from equinox (2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.6.1.f.d.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:df16::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483bfb77437sm43269235e9.3.2026.02.26.12.28.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Feb 2026 12:28:14 -0800 (PST) Date: Thu, 26 Feb 2026 20:28:13 +0000 From: Phillip Potter To: Felix Busch Cc: phil@philpotter.co.uk, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/2] [PATCH] cdrom: extra upper bound check for logical block address. Message-ID: References: <20260224161640.16760-1-felixbusch470@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20260224161640.16760-1-felixbusch470@gmail.com> On Tue, Feb 24, 2026 at 05:16:12PM +0100, Felix Busch wrote: > Hi Phillip, > > Thank you for your feedback. I’ve updated everything based on your suggestions and hope > I’ve covered them all. > > It has been built and run and tested in the following: > > 1) This has been tested on a real CD-ROM with 700MB capacity, containing 2097151 > sectors in my case. Since 2097151 is not divisible by a blocksize of 2048, the if condition is not satisfied. > > 2) When using a smaller emulated CD-ROM with QEMU with the same blocksize, > the if condition is triggered when having a too big logical block addresses. For example, this occurs when minutes, > seconds, and frames are set to UINT8_MAX via an ioctl call. > > According to this SCSI-2 spec, chapter 14 on this web page (date 23.2.2026): > https://www.staff.uni-mainz.de/tacke/scsi/SCSI2-introduction.html > > They are stating: > " > Logical addressing of CD-ROM information may use any logical block length. When the specified logical block > length is an exact divisor or integral multiple of the selected number of bytes per CD-ROM sector, > the device shall map (one to one) the bytes transferred from CD-ROM sectors to the bytes of logical blocks. > For instance, if 2 048 bytes are transferred from each CD-ROM sector (specified by the CD-ROM density code value), > and the logical block length is 512 bytes, then each CD-ROM sector shall map to exactly four logical blocks. > This International Standard does not define the mapping of logical block lengths which do not evenly divide > or are not exact multiples of the selected number of bytes per CD-ROM sector. > " > > So, I do refer to this SCSI-2 spec. > Using this information it's possible to use logical_blocks = cd_nr_sectors / blocksize to get the number of blocks that are be able to read due to this mapping. > For now, I decided using this special checking only, due to the given statement in the SCSI-2 spec. > > If lba > blocksize * (logical_blocks - 1), then it should not be possible to continue reading a full block, because then, as I understand, > it would "overflow" the region it can read from the disk. > I've seen your V3 - please make sure the relevant mailing list is copied in when posting patches, as development is ideally done in the open. As for that and for this version, I'm sorry but I'm still not convinced of the approach unless I'm missing something. You are taking units of two different things and dividing one by the other. Dividing the number of sectors (2,097,151) by the detected blocksize (2048 bytes) is not meaningful. The statement in the SCSI-2 spec simply refers to the difference between CD-ROM sector size in bytes and the logical block size in bytes. Here, you are dividing one thing (number of sectors) by another (block size). Do you see what I mean? Finally, please make sure cover letters of a patch series are labels PATCH 0. Regards, Phil