From 0ce7909cd0ba35148bddd8309534cb96e9e20f48 Mon Sep 17 00:00:00 2001 From: Doug Moore Date: Wed, 19 Jan 2022 00:42:39 -0600 Subject: [PATCH] vm_phys: add essential segment bounds check A lower-bound segment check is necessary in vm_phys_alloc_seg_contig. Add one. Reported by: jenkins Reviewed by: alc Fixes: da92ecbc0d8f vm_phys: fix seg->end test in alloc_seg_contig MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D33945 --- sys/vm/vm_phys.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/vm/vm_phys.c b/sys/vm/vm_phys.c index a880b7abd324..7ca3f5fbc0c5 100644 --- a/sys/vm/vm_phys.c +++ b/sys/vm/vm_phys.c @@ -1451,7 +1451,8 @@ vm_phys_alloc_seg_contig(struct vm_phys_seg *seg, u_long npages, * (without overflow in pa_end calculation) * and fits within the segment. */ - if (pa_end < pa || pa_end > seg->end) + if (pa_end < pa || + pa < seg->start || seg->end < pa_end) continue; /*