Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+14 -3
+14 -3
fs/pstore/ram_core.c
··· 429 429 vaddr = vmap(pages, page_count, VM_MAP, prot); 430 430 kfree(pages); 431 431 432 - return vaddr; 432 + /* 433 + * Since vmap() uses page granularity, we must add the offset 434 + * into the page here, to get the byte granularity address 435 + * into the mapping to represent the actual "start" location. 436 + */ 437 + return vaddr + offset_in_page(start); 433 438 } 434 439 435 440 static void *persistent_ram_iomap(phys_addr_t start, size_t size, ··· 453 448 else 454 449 va = ioremap_wc(start, size); 455 450 451 + /* 452 + * Since request_mem_region() and ioremap() are byte-granularity 453 + * there is no need handle anything special like we do when the 454 + * vmap() case in persistent_ram_vmap() above. 455 + */ 456 456 return va; 457 457 } 458 458 ··· 478 468 return -ENOMEM; 479 469 } 480 470 481 - prz->buffer = prz->vaddr + offset_in_page(start); 471 + prz->buffer = prz->vaddr; 482 472 prz->buffer_size = size - sizeof(struct persistent_ram_buffer); 483 473 484 474 return 0; ··· 525 515 526 516 if (prz->vaddr) { 527 517 if (pfn_valid(prz->paddr >> PAGE_SHIFT)) { 528 - vunmap(prz->vaddr); 518 + /* We must vunmap() at page-granularity. */ 519 + vunmap(prz->vaddr - offset_in_page(prz->paddr)); 529 520 } else { 530 521 iounmap(prz->vaddr); 531 522 release_mem_region(prz->paddr, prz->size);