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 branch 'core-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull core kernel fixes from Ingo Molnar:
"This is mostly the copy_to_user_mcsafe() related fixes from Dan
Williams, and an ORC fix for Clang"

* 'core-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86/asm/memcpy_mcsafe: Fix copy_to_user_mcsafe() exception handling
lib/iov_iter: Fix pipe handling in _copy_to_iter_mcsafe()
lib/iov_iter: Document _copy_to_iter_flushcache()
lib/iov_iter: Document _copy_to_iter_mcsafe()
objtool: Use '.strtab' if '.shstrtab' doesn't exist, to support ORC tables on Clang

+84 -8
+1 -1
arch/x86/Kconfig
··· 63 63 select ARCH_HAS_PTE_SPECIAL 64 64 select ARCH_HAS_REFCOUNT 65 65 select ARCH_HAS_UACCESS_FLUSHCACHE if X86_64 66 - select ARCH_HAS_UACCESS_MCSAFE if X86_64 66 + select ARCH_HAS_UACCESS_MCSAFE if X86_64 && X86_MCE 67 67 select ARCH_HAS_SET_MEMORY 68 68 select ARCH_HAS_SG_CHAIN 69 69 select ARCH_HAS_STRICT_KERNEL_RWX
+6 -1
arch/x86/include/asm/uaccess_64.h
··· 52 52 unsigned long ret; 53 53 54 54 __uaccess_begin(); 55 - ret = memcpy_mcsafe(to, from, len); 55 + /* 56 + * Note, __memcpy_mcsafe() is explicitly used since it can 57 + * handle exceptions / faults. memcpy_mcsafe() may fall back to 58 + * memcpy() which lacks this handling. 59 + */ 60 + ret = __memcpy_mcsafe(to, from, len); 56 61 __uaccess_end(); 57 62 return ret; 58 63 }
+73 -4
lib/iov_iter.c
··· 596 596 return ret; 597 597 } 598 598 599 + static size_t copy_pipe_to_iter_mcsafe(const void *addr, size_t bytes, 600 + struct iov_iter *i) 601 + { 602 + struct pipe_inode_info *pipe = i->pipe; 603 + size_t n, off, xfer = 0; 604 + int idx; 605 + 606 + if (!sanity(i)) 607 + return 0; 608 + 609 + bytes = n = push_pipe(i, bytes, &idx, &off); 610 + if (unlikely(!n)) 611 + return 0; 612 + for ( ; n; idx = next_idx(idx, pipe), off = 0) { 613 + size_t chunk = min_t(size_t, n, PAGE_SIZE - off); 614 + unsigned long rem; 615 + 616 + rem = memcpy_mcsafe_to_page(pipe->bufs[idx].page, off, addr, 617 + chunk); 618 + i->idx = idx; 619 + i->iov_offset = off + chunk - rem; 620 + xfer += chunk - rem; 621 + if (rem) 622 + break; 623 + n -= chunk; 624 + addr += chunk; 625 + } 626 + i->count -= xfer; 627 + return xfer; 628 + } 629 + 630 + /** 631 + * _copy_to_iter_mcsafe - copy to user with source-read error exception handling 632 + * @addr: source kernel address 633 + * @bytes: total transfer length 634 + * @iter: destination iterator 635 + * 636 + * The pmem driver arranges for filesystem-dax to use this facility via 637 + * dax_copy_to_iter() for protecting read/write to persistent memory. 638 + * Unless / until an architecture can guarantee identical performance 639 + * between _copy_to_iter_mcsafe() and _copy_to_iter() it would be a 640 + * performance regression to switch more users to the mcsafe version. 641 + * 642 + * Otherwise, the main differences between this and typical _copy_to_iter(). 643 + * 644 + * * Typical tail/residue handling after a fault retries the copy 645 + * byte-by-byte until the fault happens again. Re-triggering machine 646 + * checks is potentially fatal so the implementation uses source 647 + * alignment and poison alignment assumptions to avoid re-triggering 648 + * hardware exceptions. 649 + * 650 + * * ITER_KVEC, ITER_PIPE, and ITER_BVEC can return short copies. 651 + * Compare to copy_to_iter() where only ITER_IOVEC attempts might return 652 + * a short copy. 653 + * 654 + * See MCSAFE_TEST for self-test. 655 + */ 599 656 size_t _copy_to_iter_mcsafe(const void *addr, size_t bytes, struct iov_iter *i) 600 657 { 601 658 const char *from = addr; 602 659 unsigned long rem, curr_addr, s_addr = (unsigned long) addr; 603 660 604 - if (unlikely(i->type & ITER_PIPE)) { 605 - WARN_ON(1); 606 - return 0; 607 - } 661 + if (unlikely(i->type & ITER_PIPE)) 662 + return copy_pipe_to_iter_mcsafe(addr, bytes, i); 608 663 if (iter_is_iovec(i)) 609 664 might_fault(); 610 665 iterate_and_advance(i, bytes, v, ··· 756 701 EXPORT_SYMBOL(_copy_from_iter_nocache); 757 702 758 703 #ifdef CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE 704 + /** 705 + * _copy_from_iter_flushcache - write destination through cpu cache 706 + * @addr: destination kernel address 707 + * @bytes: total transfer length 708 + * @iter: source iterator 709 + * 710 + * The pmem driver arranges for filesystem-dax to use this facility via 711 + * dax_copy_from_iter() for ensuring that writes to persistent memory 712 + * are flushed through the CPU cache. It is differentiated from 713 + * _copy_from_iter_nocache() in that guarantees all data is flushed for 714 + * all iterator types. The _copy_from_iter_nocache() only attempts to 715 + * bypass the cache for the ITER_IOVEC case, and on some archs may use 716 + * instructions that strand dirty-data in the cache. 717 + */ 759 718 size_t _copy_from_iter_flushcache(void *addr, size_t bytes, struct iov_iter *i) 760 719 { 761 720 char *to = addr;
+4 -2
tools/objtool/elf.c
··· 519 519 sec->sh.sh_flags = SHF_ALLOC; 520 520 521 521 522 - /* Add section name to .shstrtab */ 522 + /* Add section name to .shstrtab (or .strtab for Clang) */ 523 523 shstrtab = find_section_by_name(elf, ".shstrtab"); 524 + if (!shstrtab) 525 + shstrtab = find_section_by_name(elf, ".strtab"); 524 526 if (!shstrtab) { 525 - WARN("can't find .shstrtab section"); 527 + WARN("can't find .shstrtab or .strtab section"); 526 528 return NULL; 527 529 } 528 530