Skip to content

Commit b02ddb5

Browse files
committed
swap_pager_getpages(): assert that bp->b_pages[] is accessed in bounds
Reviewed by: glebius, markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D54713
1 parent 3fe275c commit b02ddb5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

sys/vm/swap_pager.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,6 +1396,9 @@ swap_pager_getpages_locked(struct pctrie_iter *blks, vm_object_t object,
13961396
vm_object_prepare_buf_pages(object, bp->b_pages, count, &rbehind,
13971397
&rahead, ma);
13981398
bp->b_npages = rbehind + count + rahead;
1399+
KASSERT(bp->b_npages <= PBUF_PAGES,
1400+
("bp_npages %d (rb %d c %d ra %d) not less than PBUF_PAGES %jd",
1401+
bp->b_npages, rbehind, count, rahead, (uintmax_t)PBUF_PAGES));
13991402
for (int i = 0; i < bp->b_npages; i++)
14001403
bp->b_pages[i]->oflags |= VPO_SWAPINPROG;
14011404
bp->b_blkno = swp_pager_meta_lookup(blks, pindex - rbehind);

0 commit comments

Comments
 (0)