git: 9e6941a2c7a3 - main - udf: reject invalid block sizes from lvd

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Fri, 04 Aug 2023 22:49:44 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=9e6941a2c7a393aefe6a123952c6eacbc23098a6

commit 9e6941a2c7a393aefe6a123952c6eacbc23098a6
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-08-04 22:47:09 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-08-04 22:49:36 +0000

    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
---
 sys/fs/udf/udf_vfsops.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sys/fs/udf/udf_vfsops.c b/sys/fs/udf/udf_vfsops.c
index 0b028718085a..a8aa811a0d6c 100644
--- a/sys/fs/udf/udf_vfsops.c
+++ b/sys/fs/udf/udf_vfsops.c
@@ -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);