summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrodrigc <rodrigc@FreeBSD.org>2005-09-10 21:30:49 +0000
committerrodrigc <rodrigc@FreeBSD.org>2005-09-10 21:30:49 +0000
commit5e66dc012fc20fa0f046781712dee71ced8ddea6 (patch)
tree9cc882e9a1705b706d8dfc4f31704dd1c240fe66
parent03ae4bec9770a810ad1363b1949b8aff98142fe6 (diff)
downloadFreeBSD-src-5e66dc012fc20fa0f046781712dee71ced8ddea6.zip
FreeBSD-src-5e66dc012fc20fa0f046781712dee71ced8ddea6.tar.gz
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
-rw-r--r--sys/gnu/fs/ext2fs/ext2_vfsops.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/sys/gnu/fs/ext2fs/ext2_vfsops.c b/sys/gnu/fs/ext2fs/ext2_vfsops.c
index b801b97..84d1809 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;
OpenPOWER on IntegriCloud