Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Sep 2023 21:56:47 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 983819d21799 - stable/13 - cd9660: Reject volumes with small logical block sizes
Message-ID:  <202309062156.386Lul9E023074@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=983819d217999303770876885250e70a89ad2687

commit 983819d217999303770876885250e70a89ad2687
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2023-08-04 23:41:50 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2023-09-06 21:56:10 +0000

    cd9660: Reject volumes with small logical block sizes
    
    ISO9660 permits specifying a logical block size that is any power of 2
    greater than or equal to 512.  The geom disk layer requires requests
    to be aligned on sector boundaries of the provider.  With a volume
    that uses a logical block size smaller than the underlying disk sector
    size (e.g. a logical block size of 512 or 1024 on a CD which uses 2048
    byte sectors), the current cd9660 vfs can issue requests for partial
    sectors, or on non-sector boundaries.
    
    Fixing this properly would require wrapping all of the calls to
    bread*/bwrite* in cd9660 vfs to roundup requests to be on sector
    boundaries which can include both the length, but also the starting
    sector number (and thus requiring use of an offset relative to b_data
    in the resulting buf).
    
    These images do not seem to be common however given that no one has
    fixed this in cd9660's vfs in the past few decades, so just reject
    them during mount with an error.  If such images are found to be used
    in the wild in practice, then the larger fix can be applied.
    
    PR:             258063
    Reported by:    Robert Morris <rtm@lcs.mit.edu>
    Reviewed by:    emaste
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D41228
    
    (cherry picked from commit 4af849d71f69306432941d91fa46c3c303059d63)
---
 sys/fs/cd9660/cd9660_vfsops.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/sys/fs/cd9660/cd9660_vfsops.c b/sys/fs/cd9660/cd9660_vfsops.c
index 08c0fbb78b1d..90a8996c9651 100644
--- a/sys/fs/cd9660/cd9660_vfsops.c
+++ b/sys/fs/cd9660/cd9660_vfsops.c
@@ -336,6 +336,13 @@ iso_mountfs(devvp, mp)
 		goto out;
 	}
 
+	if (logical_block_size < cp->provider->sectorsize) {
+		printf("cd9660: Unsupported logical block size %u\n",
+		    logical_block_size);
+		error = EINVAL;
+		goto out;
+	}
+
 	rootp = (struct iso_directory_record *)
 		(high_sierra?
 		 pri_sierra->root_directory_record:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202309062156.386Lul9E023074>