mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-04 09:59:32 +00:00
pstore fixes for v4.19-rc4:
- Handle page-vs-byte offset handling between iomap and vmap (Bin Yang) -----BEGIN PGP SIGNATURE----- Comment: Kees Cook <kees@outflux.net> iQJKBAABCgA0FiEEpcP2jyKd1g9yPm4TiXL039xtwCYFAluakCIWHGtlZXNjb29r QGNocm9taXVtLm9yZwAKCRCJcvTf3G3AJnq1D/9a9PFwxBflN3Wi9G2SMJuCF8y1 vb+auPyMtk2gpnDnE/GbumwLfB/ZW/1JSBNncCmSnFOjeK3M0m4e0gz0XU2AQaT6 BTNFZlVe649a6zct59nEQRILG1aPP5UdKv4eE2mJ+XOFEi3DSTMgtsmFhftrngGZ Gp8XYaNgf6JIL25fUtfgZd5YiwbR+ZdLZdcd+qlIliJF80rup/QftdgRsPJk0kUS b8yE6sWNnP1NDzlUWcAWXy231lewbbUsdYAQ11RLThl8Glogz3hlxLKIbCuKFymd IGwSyShnZFczO6qN6Rcvx5o8PIgbTH+1ntQc3s3PNuXOpOmOk7F2YspkAEqLY3// 4Gy+jphSmg12JAzPy7B1m0UT8nCE0S9qfi7tnQ0Dti0rvu+vS1dyqFlqbTgN9Hb3 Wfi8u/rNvUT5XqB0afq5v7U6On7mjHfW6PwcwqZJZtEblERqv+DOgRUPjWkack6E x64IA0UzlEX2AlWHiBxGcwd55kIvk+xI94VVy2K8QcbWlGeM5Ij7WDMABTkmJn5L 3I8EwoIpg9qtoabKOywOQuj6m9Dovvo0Dv8juUtHARBUJZC0fEpakTdPZEQoiSBs 7Vox1UTzY+QqJch1ayEvjmqJNkPsAor7zqfVX4Ub85tuECAEs+MtQDbZCZUTXR7I WN5N1QBDpuwC8tupCg== =8krP -----END PGP SIGNATURE----- Merge tag 'pstore-v4.19-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux Pull pstore fix from Kees Cook: "This fixes a 6 year old pstore bug that everyone just got lucky in avoiding, likely due only using page-aligned persistent ram regions: - Handle page-vs-byte offset handling between iomap and vmap (Bin Yang)" * tag 'pstore-v4.19-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: pstore: Fix incorrect persistent ram buffer mapping
This commit is contained in:
commit
145ea6f10d
1 changed files with 14 additions and 3 deletions
|
@ -429,7 +429,12 @@ static void *persistent_ram_vmap(phys_addr_t start, size_t size,
|
|||
vaddr = vmap(pages, page_count, VM_MAP, prot);
|
||||
kfree(pages);
|
||||
|
||||
return vaddr;
|
||||
/*
|
||||
* Since vmap() uses page granularity, we must add the offset
|
||||
* into the page here, to get the byte granularity address
|
||||
* into the mapping to represent the actual "start" location.
|
||||
*/
|
||||
return vaddr + offset_in_page(start);
|
||||
}
|
||||
|
||||
static void *persistent_ram_iomap(phys_addr_t start, size_t size,
|
||||
|
@ -448,6 +453,11 @@ static void *persistent_ram_iomap(phys_addr_t start, size_t size,
|
|||
else
|
||||
va = ioremap_wc(start, size);
|
||||
|
||||
/*
|
||||
* Since request_mem_region() and ioremap() are byte-granularity
|
||||
* there is no need handle anything special like we do when the
|
||||
* vmap() case in persistent_ram_vmap() above.
|
||||
*/
|
||||
return va;
|
||||
}
|
||||
|
||||
|
@ -468,7 +478,7 @@ static int persistent_ram_buffer_map(phys_addr_t start, phys_addr_t size,
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
prz->buffer = prz->vaddr + offset_in_page(start);
|
||||
prz->buffer = prz->vaddr;
|
||||
prz->buffer_size = size - sizeof(struct persistent_ram_buffer);
|
||||
|
||||
return 0;
|
||||
|
@ -515,7 +525,8 @@ void persistent_ram_free(struct persistent_ram_zone *prz)
|
|||
|
||||
if (prz->vaddr) {
|
||||
if (pfn_valid(prz->paddr >> PAGE_SHIFT)) {
|
||||
vunmap(prz->vaddr);
|
||||
/* We must vunmap() at page-granularity. */
|
||||
vunmap(prz->vaddr - offset_in_page(prz->paddr));
|
||||
} else {
|
||||
iounmap(prz->vaddr);
|
||||
release_mem_region(prz->paddr, prz->size);
|
||||
|
|
Loading…
Reference in a new issue