diff options
author | rodrigc <rodrigc@FreeBSD.org> | 2006-06-03 21:20:37 +0000 |
---|---|---|
committer | rodrigc <rodrigc@FreeBSD.org> | 2006-06-03 21:20:37 +0000 |
commit | 5ca19bbf738cebdb32c8ace9486bed88a40bc1e8 (patch) | |
tree | bf8700dca946847b9cddaf3a93aea89c6029dae5 /sys | |
parent | bdcca9d25ab3e9b4623ec20485ddf89e16a616f7 (diff) | |
download | FreeBSD-src-5ca19bbf738cebdb32c8ace9486bed88a40bc1e8.zip FreeBSD-src-5ca19bbf738cebdb32c8ace9486bed88a40bc1e8.tar.gz |
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 <rfrancis at ev dot net>
MFC after: 1 week
Diffstat (limited to 'sys')
-rw-r--r-- | sys/ufs/ffs/ffs_vfsops.c | 9 |
1 files changed, 8 insertions, 1 deletions
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; |