From 5ca19bbf738cebdb32c8ace9486bed88a40bc1e8 Mon Sep 17 00:00:00 2001 From: rodrigc Date: Sat, 3 Jun 2006 21:20:37 +0000 Subject: Check the sectorsize of the underlying disk before trying to bread() the UFS superblock. Should eliminate crashes when trying to do: mount -t ufs on an audio CD. PR: kern/85893 Reported by: Russell Francis MFC after: 1 week --- sys/ufs/ffs/ffs_vfsops.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'sys/ufs/ffs') diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 2ef75f8..7378b64 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -616,7 +616,14 @@ ffs_mountfs(devvp, mp, td) * Try reading the superblock in each of its possible locations. */ for (i = 0; sblock_try[i] != -1; i++) { - if ((error = bread(devvp, sblock_try[i] / DEV_BSIZE, SBLOCKSIZE, + if ((SBLOCKSIZE % cp->provider->sectorsize) != 0) { + error = EINVAL; + vfs_mount_error(mp, + "Invalid sectorsize %d for superblock size %d", + cp->provider->sectorsize, SBLOCKSIZE); + goto out; + } + if ((error = bread(devvp, btodb(sblock_try[i]), SBLOCKSIZE, cred, &bp)) != 0) goto out; fs = (struct fs *)bp->b_data; -- cgit v1.1