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 'akpm' (patches from Andrew)

Merge misc fixes from Andrew Morton:
"16 fixes"

* emailed patches from Andrew Morton <akpm@linux-foundation.org>:
kasan: fix memory hotplug during boot
kasan: free allocated shadow memory on MEM_CANCEL_ONLINE
checkpatch: fix macro argument precedence test
init/main.c: include <linux/mem_encrypt.h>
kernel/sys.c: fix potential Spectre v1 issue
mm/memory_hotplug: fix leftover use of struct page during hotplug
proc: fix smaps and meminfo alignment
mm: do not warn on offline nodes unless the specific node is explicitly requested
mm, memory_hotplug: make has_unmovable_pages more robust
mm/kasan: don't vfree() nonexistent vm_area
MAINTAINERS: change hugetlbfs maintainer and update files
ipc/shm: fix shmat() nil address after round-down when remapping
Revert "ipc/shm: Fix shmat mmap nil-page protection"
idr: fix invalid ptr dereference on item delete
ocfs2: revert "ocfs2/o2hb: check len for bio_add_page() to avoid getting incorrect bio"
mm: fix nr_rotate_swap leak in swapon() error case

+125 -43
+7 -1
MAINTAINERS
··· 6503 6503 F: drivers/net/ethernet/huawei/hinic/ 6504 6504 6505 6505 HUGETLB FILESYSTEM 6506 - M: Nadia Yvette Chambers <nyc@holomorphy.com> 6506 + M: Mike Kravetz <mike.kravetz@oracle.com> 6507 + L: linux-mm@kvack.org 6507 6508 S: Maintained 6508 6509 F: fs/hugetlbfs/ 6510 + F: mm/hugetlb.c 6511 + F: include/linux/hugetlb.h 6512 + F: Documentation/admin-guide/mm/hugetlbpage.rst 6513 + F: Documentation/vm/hugetlbfs_reserv.rst 6514 + F: Documentation/ABI/testing/sysfs-kernel-mm-hugepages 6509 6515 6510 6516 HVA ST MEDIA DRIVER 6511 6517 M: Jean-Christophe Trotin <jean-christophe.trotin@st.com>
+3 -2
drivers/base/node.c
··· 490 490 return 0; 491 491 } 492 492 493 - int link_mem_sections(int nid, unsigned long start_pfn, unsigned long nr_pages) 493 + int link_mem_sections(int nid, unsigned long start_pfn, unsigned long nr_pages, 494 + bool check_nid) 494 495 { 495 496 unsigned long end_pfn = start_pfn + nr_pages; 496 497 unsigned long pfn; ··· 515 514 516 515 mem_blk = find_memory_block_hinted(mem_sect, mem_blk); 517 516 518 - ret = register_mem_sect_under_node(mem_blk, nid, true); 517 + ret = register_mem_sect_under_node(mem_blk, nid, check_nid); 519 518 if (!err) 520 519 err = ret; 521 520
+1 -10
fs/ocfs2/cluster/heartbeat.c
··· 570 570 current_page, vec_len, vec_start); 571 571 572 572 len = bio_add_page(bio, page, vec_len, vec_start); 573 - if (len != vec_len) { 574 - mlog(ML_ERROR, "Adding page[%d] to bio failed, " 575 - "page %p, len %d, vec_len %u, vec_start %u, " 576 - "bi_sector %llu\n", current_page, page, len, 577 - vec_len, vec_start, 578 - (unsigned long long)bio->bi_iter.bi_sector); 579 - bio_put(bio); 580 - bio = ERR_PTR(-EIO); 581 - return bio; 582 - } 573 + if (len != vec_len) break; 583 574 584 575 cs += vec_len / (PAGE_SIZE/spp); 585 576 vec_start = 0;
-5
fs/seq_file.c
··· 709 709 if (m->count + width >= m->size) 710 710 goto overflow; 711 711 712 - if (num < 10) { 713 - m->buf[m->count++] = num + '0'; 714 - return; 715 - } 716 - 717 712 len = num_to_str(m->buf + m->count, m->size - m->count, num, width); 718 713 if (!len) 719 714 goto overflow;
+1 -1
include/linux/gfp.h
··· 464 464 __alloc_pages_node(int nid, gfp_t gfp_mask, unsigned int order) 465 465 { 466 466 VM_BUG_ON(nid < 0 || nid >= MAX_NUMNODES); 467 - VM_WARN_ON(!node_online(nid)); 467 + VM_WARN_ON((gfp_mask & __GFP_THISNODE) && !node_online(nid)); 468 468 469 469 return __alloc_pages(gfp_mask, order, nid); 470 470 }
+5 -3
include/linux/node.h
··· 32 32 typedef void (*node_registration_func_t)(struct node *); 33 33 34 34 #if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_NUMA) 35 - extern int link_mem_sections(int nid, unsigned long start_pfn, unsigned long nr_pages); 35 + extern int link_mem_sections(int nid, unsigned long start_pfn, 36 + unsigned long nr_pages, bool check_nid); 36 37 #else 37 - static inline int link_mem_sections(int nid, unsigned long start_pfn, unsigned long nr_pages) 38 + static inline int link_mem_sections(int nid, unsigned long start_pfn, 39 + unsigned long nr_pages, bool check_nid) 38 40 { 39 41 return 0; 40 42 } ··· 59 57 if (error) 60 58 return error; 61 59 /* link memory sections under this node */ 62 - error = link_mem_sections(nid, pgdat->node_start_pfn, pgdat->node_spanned_pages); 60 + error = link_mem_sections(nid, pgdat->node_start_pfn, pgdat->node_spanned_pages, true); 63 61 } 64 62 65 63 return error;
+1
init/main.c
··· 91 91 #include <linux/cache.h> 92 92 #include <linux/rodata_test.h> 93 93 #include <linux/jump_label.h> 94 + #include <linux/mem_encrypt.h> 94 95 95 96 #include <asm/io.h> 96 97 #include <asm/bugs.h>
+11 -8
ipc/shm.c
··· 1363 1363 1364 1364 if (addr) { 1365 1365 if (addr & (shmlba - 1)) { 1366 - /* 1367 - * Round down to the nearest multiple of shmlba. 1368 - * For sane do_mmap_pgoff() parameters, avoid 1369 - * round downs that trigger nil-page and MAP_FIXED. 1370 - */ 1371 - if ((shmflg & SHM_RND) && addr >= shmlba) 1372 - addr &= ~(shmlba - 1); 1373 - else 1366 + if (shmflg & SHM_RND) { 1367 + addr &= ~(shmlba - 1); /* round down */ 1368 + 1369 + /* 1370 + * Ensure that the round-down is non-nil 1371 + * when remapping. This can happen for 1372 + * cases when addr < shmlba. 1373 + */ 1374 + if (!addr && (shmflg & SHM_REMAP)) 1375 + goto out; 1376 + } else 1374 1377 #ifndef __ARCH_FORCE_SHMLBA 1375 1378 if (addr & ~PAGE_MASK) 1376 1379 #endif
+5
kernel/sys.c
··· 71 71 #include <asm/io.h> 72 72 #include <asm/unistd.h> 73 73 74 + /* Hardening for Spectre-v1 */ 75 + #include <linux/nospec.h> 76 + 74 77 #include "uid16.h" 75 78 76 79 #ifndef SET_UNALIGN_CTL ··· 1456 1453 if (resource >= RLIM_NLIMITS) 1457 1454 return -EINVAL; 1458 1455 1456 + resource = array_index_nospec(resource, RLIM_NLIMITS); 1459 1457 task_lock(current->group_leader); 1460 1458 x = current->signal->rlim[resource]; 1461 1459 task_unlock(current->group_leader); ··· 1476 1472 if (resource >= RLIM_NLIMITS) 1477 1473 return -EINVAL; 1478 1474 1475 + resource = array_index_nospec(resource, RLIM_NLIMITS); 1479 1476 task_lock(current->group_leader); 1480 1477 r = current->signal->rlim[resource]; 1481 1478 task_unlock(current->group_leader);
+3 -1
lib/radix-tree.c
··· 2034 2034 unsigned long index, void *item) 2035 2035 { 2036 2036 struct radix_tree_node *node = NULL; 2037 - void __rcu **slot; 2037 + void __rcu **slot = NULL; 2038 2038 void *entry; 2039 2039 2040 2040 entry = __radix_tree_lookup(root, index, &node, &slot); 2041 + if (!slot) 2042 + return NULL; 2041 2043 if (!entry && (!is_idr(root) || node_tag_get(root, node, IDR_FREE, 2042 2044 get_slot_offset(node, slot)))) 2043 2045 return NULL;
+63 -3
mm/kasan/kasan.c
··· 792 792 DEFINE_ASAN_SET_SHADOW(f8); 793 793 794 794 #ifdef CONFIG_MEMORY_HOTPLUG 795 + static bool shadow_mapped(unsigned long addr) 796 + { 797 + pgd_t *pgd = pgd_offset_k(addr); 798 + p4d_t *p4d; 799 + pud_t *pud; 800 + pmd_t *pmd; 801 + pte_t *pte; 802 + 803 + if (pgd_none(*pgd)) 804 + return false; 805 + p4d = p4d_offset(pgd, addr); 806 + if (p4d_none(*p4d)) 807 + return false; 808 + pud = pud_offset(p4d, addr); 809 + if (pud_none(*pud)) 810 + return false; 811 + 812 + /* 813 + * We can't use pud_large() or pud_huge(), the first one is 814 + * arch-specific, the last one depends on HUGETLB_PAGE. So let's abuse 815 + * pud_bad(), if pud is bad then it's bad because it's huge. 816 + */ 817 + if (pud_bad(*pud)) 818 + return true; 819 + pmd = pmd_offset(pud, addr); 820 + if (pmd_none(*pmd)) 821 + return false; 822 + 823 + if (pmd_bad(*pmd)) 824 + return true; 825 + pte = pte_offset_kernel(pmd, addr); 826 + return !pte_none(*pte); 827 + } 828 + 795 829 static int __meminit kasan_mem_notifier(struct notifier_block *nb, 796 830 unsigned long action, void *data) 797 831 { ··· 847 813 case MEM_GOING_ONLINE: { 848 814 void *ret; 849 815 816 + /* 817 + * If shadow is mapped already than it must have been mapped 818 + * during the boot. This could happen if we onlining previously 819 + * offlined memory. 820 + */ 821 + if (shadow_mapped(shadow_start)) 822 + return NOTIFY_OK; 823 + 850 824 ret = __vmalloc_node_range(shadow_size, PAGE_SIZE, shadow_start, 851 825 shadow_end, GFP_KERNEL, 852 826 PAGE_KERNEL, VM_NO_GUARD, ··· 866 824 kmemleak_ignore(ret); 867 825 return NOTIFY_OK; 868 826 } 869 - case MEM_OFFLINE: 870 - vfree((void *)shadow_start); 827 + case MEM_CANCEL_ONLINE: 828 + case MEM_OFFLINE: { 829 + struct vm_struct *vm; 830 + 831 + /* 832 + * shadow_start was either mapped during boot by kasan_init() 833 + * or during memory online by __vmalloc_node_range(). 834 + * In the latter case we can use vfree() to free shadow. 835 + * Non-NULL result of the find_vm_area() will tell us if 836 + * that was the second case. 837 + * 838 + * Currently it's not possible to free shadow mapped 839 + * during boot by kasan_init(). It's because the code 840 + * to do that hasn't been written yet. So we'll just 841 + * leak the memory. 842 + */ 843 + vm = find_vm_area((void *)shadow_start); 844 + if (vm) 845 + vfree((void *)shadow_start); 846 + } 871 847 } 872 848 873 849 return NOTIFY_OK; ··· 898 838 return 0; 899 839 } 900 840 901 - module_init(kasan_memhotplug_init); 841 + core_initcall(kasan_memhotplug_init); 902 842 #endif
+1 -1
mm/memory_hotplug.c
··· 1158 1158 * nodes have to go through register_node. 1159 1159 * TODO clean up this mess. 1160 1160 */ 1161 - ret = link_mem_sections(nid, start_pfn, nr_pages); 1161 + ret = link_mem_sections(nid, start_pfn, nr_pages, false); 1162 1162 register_fail: 1163 1163 /* 1164 1164 * If sysfs file of new node can't create, cpu on the node
+10 -6
mm/page_alloc.c
··· 7598 7598 unsigned long pfn, iter, found; 7599 7599 7600 7600 /* 7601 - * For avoiding noise data, lru_add_drain_all() should be called 7602 - * If ZONE_MOVABLE, the zone never contains unmovable pages 7601 + * TODO we could make this much more efficient by not checking every 7602 + * page in the range if we know all of them are in MOVABLE_ZONE and 7603 + * that the movable zone guarantees that pages are migratable but 7604 + * the later is not the case right now unfortunatelly. E.g. movablecore 7605 + * can still lead to having bootmem allocations in zone_movable. 7603 7606 */ 7604 - if (zone_idx(zone) == ZONE_MOVABLE) 7605 - return false; 7606 7607 7607 7608 /* 7608 7609 * CMA allocations (alloc_contig_range) really need to mark isolate ··· 7624 7623 page = pfn_to_page(check); 7625 7624 7626 7625 if (PageReserved(page)) 7627 - return true; 7626 + goto unmovable; 7628 7627 7629 7628 /* 7630 7629 * Hugepages are not in LRU lists, but they're movable. ··· 7674 7673 * page at boot. 7675 7674 */ 7676 7675 if (found > count) 7677 - return true; 7676 + goto unmovable; 7678 7677 } 7679 7678 return false; 7679 + unmovable: 7680 + WARN_ON_ONCE(zone_idx(zone) == ZONE_MOVABLE); 7681 + return true; 7680 7682 } 7681 7683 7682 7684 bool is_pageblock_removable_nolock(struct page *page)
+6 -1
mm/swapfile.c
··· 3112 3112 unsigned long *frontswap_map = NULL; 3113 3113 struct page *page = NULL; 3114 3114 struct inode *inode = NULL; 3115 + bool inced_nr_rotate_swap = false; 3115 3116 3116 3117 if (swap_flags & ~SWAP_FLAGS_VALID) 3117 3118 return -EINVAL; ··· 3216 3215 cluster = per_cpu_ptr(p->percpu_cluster, cpu); 3217 3216 cluster_set_null(&cluster->index); 3218 3217 } 3219 - } else 3218 + } else { 3220 3219 atomic_inc(&nr_rotate_swap); 3220 + inced_nr_rotate_swap = true; 3221 + } 3221 3222 3222 3223 error = swap_cgroup_swapon(p->type, maxpages); 3223 3224 if (error) ··· 3310 3307 vfree(swap_map); 3311 3308 kvfree(cluster_info); 3312 3309 kvfree(frontswap_map); 3310 + if (inced_nr_rotate_swap) 3311 + atomic_dec(&nr_rotate_swap); 3313 3312 if (swap_file) { 3314 3313 if (inode && S_ISREG(inode->i_mode)) { 3315 3314 inode_unlock(inode);
+1 -1
scripts/checkpatch.pl
··· 5041 5041 $tmp_stmt =~ s/\b(typeof|__typeof__|__builtin\w+|typecheck\s*\(\s*$Type\s*,|\#+)\s*\(*\s*$arg\s*\)*\b//g; 5042 5042 $tmp_stmt =~ s/\#+\s*$arg\b//g; 5043 5043 $tmp_stmt =~ s/\b$arg\s*\#\#//g; 5044 - my $use_cnt = $tmp_stmt =~ s/\b$arg\b//g; 5044 + my $use_cnt = () = $tmp_stmt =~ /\b$arg\b/g; 5045 5045 if ($use_cnt > 1) { 5046 5046 CHK("MACRO_ARG_REUSE", 5047 5047 "Macro argument reuse '$arg' - possible side-effects?\n" . "$herectx");
+7
tools/testing/radix-tree/idr-test.c
··· 252 252 idr_remove(&idr, 3); 253 253 idr_remove(&idr, 0); 254 254 255 + assert(idr_alloc(&idr, DUMMY_PTR, 0, 0, GFP_KERNEL) == 0); 256 + idr_remove(&idr, 1); 257 + for (i = 1; i < RADIX_TREE_MAP_SIZE; i++) 258 + assert(idr_alloc(&idr, DUMMY_PTR, 0, 0, GFP_KERNEL) == i); 259 + idr_remove(&idr, 1 << 30); 260 + idr_destroy(&idr); 261 + 255 262 for (i = INT_MAX - 3UL; i < INT_MAX + 1UL; i++) { 256 263 struct item *item = item_create(i, 0); 257 264 assert(idr_alloc(&idr, item, i, i + 10, GFP_KERNEL) == i);