Repository navigation
Commit 990ebe7
committed
[drivers][ivshmem] validate shared-memory config before ioremap
Fix #11992
When BAR2 size is 0 and ivshmem falls back to the JailHouse shared memory
PCI configuration registers (0x40..0x4f), reading the 64-bit address directly
into a pointer could overwrite adjacent fields on 32-bit platforms, and the
address/size were mapped without validation.
Read registers into 32-bit variables, assemble the 64-bit address and size,
and validate that size is non-zero, the range does not overflow/wraparound,
and 64-bit addresses/sizes fit within 32-bit architecture limits before
calling rt_ioremap().
Also stop the probe when any of those four config reads fails: a failed read
leaves a full-ones dword behind, and the assembled 64-bit address/size could
still pass the range checks on a 64-bit target, leading to a bogus mapping.1 parent ebf206d commit 990ebe7
1 file changed
Lines changed: 46 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
184 | 226 | | |
185 | 227 | | |
186 | 228 | | |
| |||
0 commit comments