mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-25 11:37:56 +00:00
Zero the newly allocated md(4) swap-backed page to prevent random
kernel memory leakage to userspace. For the typical use, when a filesystem put on the md disk, the change only results in CPU and memory bandwidth spent to zero the page, since filsystems make sure that user never see unwritten content. But if md disk is used as raw device by userspace, the garbage is exposed. Reported by: Paul Schenkeveld <freebsd@psconsult.nl> MFC after: 2 weeks
This commit is contained in:
parent
f27de7742d
commit
e9f581ba31
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=242744
@ -677,6 +677,15 @@ mdstart_swap(struct md_s *sc, struct bio *bp)
|
||||
sched_unpin();
|
||||
vm_page_wakeup(m);
|
||||
break;
|
||||
} else if (rv == VM_PAGER_FAIL) {
|
||||
/*
|
||||
* Pager does not have the page. Zero
|
||||
* the allocated page, and mark it as
|
||||
* valid. Do not set dirty, the page
|
||||
* can be recreated if thrown out.
|
||||
*/
|
||||
bzero((void *)sf_buf_kva(sf), PAGE_SIZE);
|
||||
m->valid = VM_PAGE_BITS_ALL;
|
||||
}
|
||||
bcopy((void *)(sf_buf_kva(sf) + offs), p, len);
|
||||
cpu_flush_dcache(p, len);
|
||||
|
Loading…
Reference in New Issue
Block a user