udf: reject invalid block sizes from lvd

PR:	272893
Reported by:	Robert Morris <rtm@lcs.mit.edu>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
This commit is contained in:
Konstantin Belousov 2023-08-05 01:47:09 +03:00
parent efb04fb404
commit 9e6941a2c7

View File

@ -413,6 +413,11 @@ udf_mountfs(struct vnode *devvp, struct mount *mp)
lvd = (struct logvol_desc *)bp->b_data;
if (!udf_checktag(&lvd->tag, TAGID_LOGVOL)) {
udfmp->bsize = le32toh(lvd->lb_size);
if (udfmp->bsize < 0 || udfmp->bsize > maxbcachebuf) {
printf("lvd block size %d\n", udfmp->bsize);
error = EINVAL;
goto bail;
}
udfmp->bmask = udfmp->bsize - 1;
udfmp->bshift = ffs(udfmp->bsize) - 1;
fsd_part = le16toh(lvd->_lvd_use.fsd_loc.loc.part_num);