From bdb7d194d07e1f8465870f1d0a388200d90ae8f3 Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Sat, 10 Sep 2005 21:30:49 +0000 Subject: [PATCH] In ext2_mountfs(), check that the superblock size, SBSIZE, is aligned with the sectorsize value returned by GEOM, before doing a bread() of the superblock. This eliminates a panic when trying the following on an empty CD-ROM drive: mount_ext2fs /dev/acd0 /mnt Reviewed by: phk --- sys/gnu/fs/ext2fs/ext2_vfsops.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sys/gnu/fs/ext2fs/ext2_vfsops.c b/sys/gnu/fs/ext2fs/ext2_vfsops.c index b801b974c759..84d1809b1419 100644 --- a/sys/gnu/fs/ext2fs/ext2_vfsops.c +++ b/sys/gnu/fs/ext2fs/ext2_vfsops.c @@ -612,6 +612,18 @@ ext2_mountfs(devvp, mp, td) VOP_UNLOCK(devvp, 0, td); if (error) return (error); + + /* XXX: should we check for some sectorsize or 512 instead? */ + if (((SBSIZE % cp->provider->sectorsize) != 0) || + (SBSIZE < cp->provider->sectorsize)) { + DROP_GIANT(); + g_topology_lock(); + g_vfs_close(cp, td); + g_topology_unlock(); + PICKUP_GIANT(); + return (EINVAL); + } + bo = &devvp->v_bufobj; bo->bo_private = cp; bo->bo_ops = g_vfs_bufops;