Commit f8be156
KVM: do not allow mapping valid but non-reference-counted pages
It's possible to create a region which maps valid but non-refcounted
pages (e.g., tail pages of non-compound higher order allocations). These
host pages can then be returned by gfn_to_page, gfn_to_pfn, etc., family
of APIs, which take a reference to the page, which takes it from 0 to 1.
When the reference is dropped, this will free the page incorrectly.
Fix this by only taking a reference on valid pages if it was non-zero,
which indicates it is participating in normal refcounting (and can be
released with put_page).
This addresses CVE-2021-22543.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Tested-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>1 parent 309505d commit f8be156
1 file changed
Lines changed: 17 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2055 | 2055 | | |
2056 | 2056 | | |
2057 | 2057 | | |
| 2058 | + | |
| 2059 | + | |
| 2060 | + | |
| 2061 | + | |
| 2062 | + | |
| 2063 | + | |
| 2064 | + | |
2058 | 2065 | | |
2059 | 2066 | | |
2060 | 2067 | | |
| |||
2104 | 2111 | | |
2105 | 2112 | | |
2106 | 2113 | | |
| 2114 | + | |
| 2115 | + | |
| 2116 | + | |
| 2117 | + | |
| 2118 | + | |
| 2119 | + | |
2107 | 2120 | | |
2108 | | - | |
| 2121 | + | |
| 2122 | + | |
2109 | 2123 | | |
2110 | 2124 | | |
2111 | 2125 | | |
2112 | 2126 | | |
2113 | | - | |
| 2127 | + | |
| 2128 | + | |
2114 | 2129 | | |
2115 | 2130 | | |
2116 | 2131 | | |
| |||
0 commit comments