aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2024-03-02 04:58:57 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2024-03-08 18:48:02 +0000
commit1c1fde7540d813703d775e013a950145224f182e (patch)
treeb1f99c0b6b8594e26830bcb663d7f48e3d9497ac
parent2feed11fbe6db38cbc82d3efc51a9a7cdfb12e0f (diff)
downloadsrc-1c1fde7540d813703d775e013a950145224f182e.tar.gz
src-1c1fde7540d813703d775e013a950145224f182e.zip
getblkx(9): be more tolerant but also strict with the buffer size checks
PR: 277414 (cherry picked from commit 7e4ac11b6076e6a9bf7341ddeae22784284ed733)
-rw-r--r--sys/kern/vfs_bio.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index 546b6dfb6239..78dc6f511a4e 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -3963,9 +3963,11 @@ getblkx(struct vnode *vp, daddr_t blkno, daddr_t dblkno, int size, int slpflag,
("GB_KVAALLOC only makes sense with GB_UNMAPPED"));
if (vp->v_type != VCHR)
ASSERT_VOP_LOCKED(vp, "getblk");
- if (size > maxbcachebuf)
- panic("getblk: size(%d) > maxbcachebuf(%d)\n", size,
+ if (size > maxbcachebuf) {
+ printf("getblkx: size(%d) > maxbcachebuf(%d)\n", size,
maxbcachebuf);
+ return (EIO);
+ }
if (!unmapped_buf_allowed)
flags &= ~(GB_UNMAPPED | GB_KVAALLOC);
@@ -4132,6 +4134,12 @@ newbuf_unlocked:
vmio = vp->v_object != NULL;
if (vmio) {
maxsize = size + (offset & PAGE_MASK);
+ if (maxsize > maxbcachebuf) {
+ printf(
+ "getblkx: maxsize(%d) > maxbcachebuf(%d)\n",
+ maxsize, maxbcachebuf);
+ return (EIO);
+ }
} else {
maxsize = size;
/* Do not allow non-VMIO notmapped buffers. */