From: Linus Torvalds Date: Thu, 9 Sep 2021 01:52:05 +0000 (-0700) Subject: Merge branches 'akpm' and 'akpm-hotfixes' (patches from Andrew) X-Git-Tag: accepted/tizen/unified/20230118.172025~6418 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a3fa7a101dcff93791d1b1bdb3affcad1410c8c1;p=platform%2Fkernel%2Flinux-rpi.git Merge branches 'akpm' and 'akpm-hotfixes' (patches from Andrew) Merge yet more updates and hotfixes from Andrew Morton: "Post-linux-next material, based upon latest upstream to catch the now-merged dependencies: - 10 patches. Subsystems affected by this patch series: mm (vmstat and migration) and compat. And bunch of hotfixes, mostly cc:stable: - 8 patches. Subsystems affected by this patch series: mm (hmm, hugetlb, vmscan, pagealloc, pagemap, kmemleak, mempolicy, and memblock)" * emailed patches from Andrew Morton : arch: remove compat_alloc_user_space compat: remove some compat entry points mm: simplify compat numa syscalls mm: simplify compat_sys_move_pages kexec: avoid compat_alloc_user_space kexec: move locking into do_kexec_load mm: migrate: change to use bool type for 'page_was_mapped' mm: migrate: fix the incorrect function name in comments mm: migrate: introduce a local variable to get the number of pages mm/vmstat: protect per cpu variables with preempt disable on RT * emailed hotfixes from Andrew Morton : nds32/setup: remove unused memblock_region variable in setup_memory() mm/mempolicy: fix a race between offset_il_node and mpol_rebind_task mm/kmemleak: allow __GFP_NOLOCKDEP passed to kmemleak's gfp mmap_lock: change trace and locking order mm/page_alloc.c: avoid accessing uninitialized pcp page migratetype mm,vmscan: fix divide by zero in get_scan_count mm/hugetlb: initialize hugetlb_usage in mm_init mm/hmm: bypass devmap pte when all pfn requested flags are fulfilled --- a3fa7a101dcff93791d1b1bdb3affcad1410c8c1 diff --cc mm/mempolicy.c index 5e90b3fb,8d14240,b44f547..1592b08 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@@@ -1379,42 -1396,25 -1379,42 +1396,25 @@@@ static int get_nodes(nodemask_t *nodes if (maxnode > PAGE_SIZE*BITS_PER_BYTE) return -EINVAL; - - nlongs = BITS_TO_LONGS(maxnode); - - if ((maxnode % BITS_PER_LONG) == 0) - - endmask = ~0UL; - - else - - endmask = (1UL << (maxnode % BITS_PER_LONG)) - 1; - - /* * When the user specified more nodes than supported just check - - * if the non supported part is all zero. - - * - - * If maxnode have more longs than MAX_NUMNODES, check - - * the bits in that area first. And then go through to - - * check the rest bits which equal or bigger than MAX_NUMNODES. - - * Otherwise, just check bits [MAX_NUMNODES, maxnode). + + * if the non supported part is all zero, one word at a time, + + * starting at the end. */ - - if (nlongs > BITS_TO_LONGS(MAX_NUMNODES)) { - - for (k = BITS_TO_LONGS(MAX_NUMNODES); k < nlongs; k++) { - - if (get_user(t, nmask + k)) - - return -EFAULT; - - if (k == nlongs - 1) { - - if (t & endmask) - - return -EINVAL; - - } else if (t) - - return -EINVAL; - - } - - nlongs = BITS_TO_LONGS(MAX_NUMNODES); - - endmask = ~0UL; - - } - - if (maxnode > MAX_NUMNODES && MAX_NUMNODES % BITS_PER_LONG != 0) { - unsigned long valid_mask = endmask; + + while (maxnode > MAX_NUMNODES) { + + unsigned long bits = min_t(unsigned long, maxnode, BITS_PER_LONG); + + unsigned long t; - if (maxnode > MAX_NUMNODES && MAX_NUMNODES % BITS_PER_LONG != 0) { - unsigned long valid_mask = endmask; - - - valid_mask &= ~((1UL << (MAX_NUMNODES % BITS_PER_LONG)) - 1); - - if (get_user(t, nmask + nlongs - 1)) + + if (get_bitmap(&t, &nmask[maxnode / BITS_PER_LONG], bits)) return -EFAULT; - - if (t & valid_mask) + + + + if (maxnode - bits >= MAX_NUMNODES) { + + maxnode -= bits; + + } else { + + maxnode = MAX_NUMNODES; + + t &= ~((1UL << (MAX_NUMNODES % BITS_PER_LONG)) - 1); + + } + + if (t) return -EINVAL; }