freebsd-dev/sys/mips
Mark Johnston 117d10f3c1 Fix a race between _pmap_unwire_ptp() and MipsDoTLBMiss().
MipsDoTLBMiss() will load a segmap entry or pde, check that it isn't
zero, and then chase that pointer to a physical page. If that page has
been freed in the interim, it will read garbage and go on to populate
the TLB with it.

This can happen because pmap_unwire_ptp zeros out the pde and
vm_page_free_zero()s the ptp (or, recursively, zeros out the segmap
entry and vm_page_free_zero()s the pdp) without interlocking against
MipsDoTLBMiss(). The pmap is locked, and pvh_global_lock may or may not
be held, but this is not enough. Solve this issue by inserting TLB
shootdowns within _pmap_unwire_ptp(); as MipsDoTLBMiss() runs with IRQs
deferred, the IPIs involved in TLB shootdown are sufficient to ensure
that MipsDoTLBMiss() sees either a zero segmap entry / pde or a non-zero
entry and the pointed-to page still not freed.

Submitted by:	Nathaniel Filardo <nwf20@cl.cam.ac.uk>
Reviewed by:	kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D24491
2020-04-24 21:21:23 +00:00
..
atheros Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many) 2020-02-26 14:26:36 +00:00
beri beri: correct kernel printf typo 2020-02-05 19:15:36 +00:00
broadcom Move phys_avail definition into MI code. It is consumed in the MI layer and 2019-08-16 00:45:14 +00:00
cavium Retire the CRYPTO_F_IV_GENERATE flag. 2020-04-20 22:24:49 +00:00
conf Add 'gpio' since mmc now requires gpio_if.h. 2020-04-16 20:45:54 +00:00
include Use the right type for 64-bit coprocessor registers. 2020-04-17 18:24:47 +00:00
ingenic Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many) 2020-02-26 14:26:36 +00:00
malta Move phys_avail definition into MI code. It is consumed in the MI layer and 2019-08-16 00:45:14 +00:00
mediatek Move phys_avail definition into MI code. It is consumed in the MI layer and 2019-08-16 00:45:14 +00:00
mips Fix a race between _pmap_unwire_ptp() and MipsDoTLBMiss(). 2020-04-24 21:21:23 +00:00
nlm Retire the CRYPTO_F_IV_GENERATE flag. 2020-04-20 22:24:49 +00:00