incoming
Subsystems (12)
Andrew Morton
maintainer10 patches, based on 4ff2473bdb4cf2bb7d208ccf4418d3d7e6b1652c.
Subsystems affected by this patch series:
mm/pagealloc
mm/gup
ipc
selftests
mm/kasan
kernel/watchdog
bitmap
procfs
lib
mm/userfaultfd
Subsystem: mm/pagealloc
Arnd Bergmann <[email protected]>:
mm/shuffle: fix section mismatch warning
Subsystem: mm/gup
Michal Hocko <[email protected]>:
Revert "mm/gup: check page posion status for coredump."
Subsystem: ipc
Varad Gautam <[email protected]>:
ipc/mqueue, msg, sem: avoid relying on a stack reference past its expiry
Subsystem: selftests
Yang Yingliang <[email protected]>:
tools/testing/selftests/exec: fix link error
Subsystem: mm/kasan
Alexander Potapenko <[email protected]>:
kasan: slab: always reset the tag in get_freepointer_safe()
Subsystem: kernel/watchdog
Petr Mladek <[email protected]>:
watchdog: reliable handling of timestamps
Subsystem: bitmap
Rikard Falkeborn <[email protected]>:
linux/bits.h: fix compilation error with GENMASK
Subsystem: procfs
Alexey Dobriyan <[email protected]>:
proc: remove Alexey from MAINTAINERS
Subsystem: lib
Zhen Lei <[email protected]>:
lib: kunit: suppress a compilation warning of frame size
Subsystem: mm/userfaultfd
Mike Kravetz <[email protected]>:
userfaultfd: hugetlbfs: fix new flag usage in error path
MAINTAINERS | 1 - fs/hugetlbfs/inode.c | 2 +- include/linux/bits.h | 2 +- include/linux/const.h | 8 ++++++++ include/linux/minmax.h | 10 ++-------- ipc/mqueue.c | 6 ++++-- ipc/msg.c | 6 ++++-- ipc/sem.c | 6 ++++-- kernel/watchdog.c | 34 ++++++++++++++++++++-------------- lib/Makefile | 1 + mm/gup.c | 4 ---- mm/internal.h | 20 -------------------- mm/shuffle.h | 4 ++-- mm/slub.c | 1 + mm/userfaultfd.c | 28 ++++++++++++++-------------- tools/include/linux/bits.h | 2 +- tools/include/linux/const.h | 8 ++++++++ tools/testing/selftests/exec/Makefile | 6 +++--- 18 files changed, 74 insertions(+), 75 deletions(-)
Andrew Morton
maintainerPATCH 1/10 mm/shuffle: fix section mismatch warning
From: Arnd Bergmann <[email protected]>
Subject: mm/shuffle: fix section mismatch warning
clang sometimes decides not to inline shuffle_zone(), but it calls a __meminit function. Without the extra __meminit annotation we get this warning:
WARNING: modpost: vmlinux.o(.text+0x2a86d4): Section mismatch in reference from the function shuffle_zone() to the function .meminit.text:__shuffle_zone() The function shuffle_zone() references
the function __meminit __shuffle_zone().
This is often because shuffle_zone lacks a __meminit
annotation or the annotation of __shuffle_zone is wrong.
shuffle_free_memory() did not show the same problem in my tests, but it could happen in theory as well, so mark both as __meminit.
---
mm/shuffle.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/shuffle.h renamed from mm/shuffle.h~mm-shuffle-fix-section-mismatch-warning +2 -2
@@ -10,7 +10,7 @@DECLARE_STATIC_KEY_FALSE (page_alloc_shuffle_key);extern void __shuffle_free_memory (pg_data_t *pgdat);extern bool shuffle_pick_tail (void ); -static inline void shuffle_free_memory (pg_data_t *pgdat) +static inline void __meminit shuffle_free_memory (pg_data_t *pgdat) {if (!static_branch_unlikely (&page_alloc_shuffle_key))return ;
@@ -18,7 +18,7 @@ static inline void shuffle_free_memory(p }extern void __shuffle_zone (struct zone *z); -static inline void shuffle_zone (struct zone *z) +static inline void __meminit shuffle_zone (struct zone *z) {if (!static_branch_unlikely (&page_alloc_shuffle_key))return ;
_
Andrew Morton
maintainerPATCH 2/10 Revert "mm/gup: check page posion status for coredump."
In reply to Andrew MortonFrom: Michal Hocko <[email protected]>
Subject: Revert "mm/gup: check page posion status for coredump."
While reviewing
http://lkml.kernel.org/r/[email protected] I have crossed d3378e86d182 ("mm/gup: check page posion status for coredump.") and noticed that this patch is broken in two ways. First it doesn't really prevent hwpoison pages from being dumped because hwpoison pages can be marked asynchornously at any time after the check. Secondly, and more importantly, the patch introduces a ref count leak because get_dump_page takes a reference on the page which is not released.
It also seems that the patch was merged incorrectly because there were follow up changes not included as well as discussions on how to address the underlying problem
http://lkml.kernel.org/r/[email protected]
Therefore revert the original patch.
---
mm/gup.c | 4 ---- mm/internal.h | 20 -------------------- 2 files changed, 24 deletions(-)
mm/gup.c renamed from mm/gup.c~revert-mm-gup-check-page-posion-status-for-coredump +0 -4
@@ -1593,10 +1593,6 @@ struct page *get_dump_page(unsigned long FOLL_FORCE | FOLL_DUMP | FOLL_GET);if (locked)mmap_read_unlock (mm); - -if (ret ==1 &&is_page_poisoned (page)) -return NULL ; - return (ret == 1) ? page : NULL; }#endif /* CONFIG_ELF_CORE */
mm/internal.h renamed from mm/internal.h~revert-mm-gup-check-page-posion-status-for-coredump +0 -20
@@ -96,26 +96,6 @@ static inline void set_page_refcounted(sset_page_count (page,1 ); } -/* -* When kernel touch the user page, the user page may be have been marked -* poison but still mapped in user space, if without this page, the kernel -* can guarantee the data integrity and operation success, the kernel is -* better to check the posion status and avoid touching it, be good not to -* panic, coredump for process fatal signal is a sample case matching this -* scenario. Or if kernel can't guarantee the data integrity, it's better -* not to call this function, let kernel touch the poison page and get to -* panic. -*/ -static inline bool is_page_poisoned (struct page *page) -{ -if (PageHWPoison (page)) -return true; -else if (PageHuge (page) &&PageHWPoison (compound_head (page))) -return true; - -return false; -} -extern unsigned long highest_memmap_pfn;/*
_
Andrew Morton
maintainerPATCH 3/10 ipc/mqueue, msg, sem: avoid relying on a stack reference past its expiry
In reply to Andrew MortonFrom: Varad Gautam <[email protected]>
Subject: ipc/mqueue, msg, sem: avoid relying on a stack reference past its expiry
do_mq_timedreceive calls wq_sleep with a stack local address. The sender (do_mq_timedsend) uses this address to later call pipelined_send.
This leads to a very hard to trigger race where a do_mq_timedreceive call might return and leave do_mq_timedsend to rely on an invalid address, causing the following crash:
[ 240.739977] RIP: 0010:wake_q_add_safe+0x13/0x60 [ 240.739991] Call Trace: [ 240.739999] __x64_sys_mq_timedsend+0x2a9/0x490 [ 240.740003] ? auditd_test_task+0x38/0x40 [ 240.740007] ? auditd_test_task+0x38/0x40 [ 240.740011] do_syscall_64+0x80/0x680 [ 240.740017] entry_SYSCALL_64_after_hwframe+0x44/0xa9 [ 240.740019] RIP: 0033:0x7f5928e40343
The race occurs as:
1. do_mq_timedreceive calls wq_sleep with the address of struct ext_wait_queue on function stack (aliased as ewq_addr here) - it holds a valid struct ext_wait_queue * as long as the stack has not been overwritten.
2. ewq_addr gets added to info->e_wait_q[RECV].list in wq_add, and do_mq_timedsend receives it via wq_get_first_waiter(info, RECV) to call __pipelined_op.
3. Sender calls __pipelined_op::smp_store_release(&this->state, STATE_READY). Here is where the race window begins. (this is ewq_addr.)
4. If the receiver wakes up now in do_mq_timedreceive::wq_sleep, it will see state == STATE_READY and break.
5. do_mq_timedreceive returns, and ewq_addr is no longer guaranteed to be a struct ext_wait_queue * since it was on do_mq_timedreceive's stack. (Although the address may not get overwritten until another function happens to touch it, which means it can persist around for an indefinite time.)
6. do_mq_timedsend::__pipelined_op() still believes ewq_addr is a struct ext_wait_queue *, and uses it to find a task_struct to pass to the wake_q_add_safe call. In the lucky case where nothing has overwritten ewq_addr yet, ewq_addr->task is the right task_struct. In the unlucky case, __pipelined_op::wake_q_add_safe gets handed a bogus address as the receiver's task_struct causing the crash.
do_mq_timedsend::__pipelined_op() should not dereference this after setting STATE_READY, as the receiver counterpart is now free to return. Change __pipelined_op to call wake_q_add_safe on the receiver's task_struct returned by get_task_struct, instead of dereferencing this which sits on the receiver's stack.
As Manfred pointed out, the race potentially also exists in ipc/msg.c::expunge_all and ipc/sem.c::wake_up_sem_queue_prepare. Fix those in the same way.
---
ipc/mqueue.c | 6 ++++-- ipc/msg.c | 6 ++++-- ipc/sem.c | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-)
ipc/mqueue.c renamed from ipc/mqueue.c~ipc-mqueue-msg-sem-avoid-relying-on-a-stack-reference-past-its-expiry +4 -2
@@ -1004,12 +1004,14 @@ static inline void __pipelined_op(structstruct mqueue_inode_info *info, struct ext_wait_queue *this) { + struct task_struct *task; +list_del (&this->list); -get_task_struct (this->task); + task =get_task_struct (this->task);/* see MQ_BARRIER for purpose/pairing */ smp_store_release (&this->state,STATE_READY ); -wake_q_add_safe (wake_q, this->task); +wake_q_add_safe (wake_q, task); }/* pipelined_send() - send a message directly to the task waiting in
ipc/msg.c renamed from ipc/msg.c~ipc-mqueue-msg-sem-avoid-relying-on-a-stack-reference-past-its-expiry +4 -2
@@ -251,11 +251,13 @@ static void expunge_all(struct msg_queuestruct msg_receiver *msr, *t;list_for_each_entry_safe (msr, t, &msq->q_receivers, r_list) { -get_task_struct (msr->r_tsk); +struct task_struct *r_tsk; + + r_tsk =get_task_struct (msr->r_tsk);/* see MSG_BARRIER for purpose/pairing */ smp_store_release (&msr->r_msg,ERR_PTR (res)); -wake_q_add_safe (wake_q, msr->r_tsk); +wake_q_add_safe (wake_q, r_tsk); } }
ipc/sem.c renamed from ipc/sem.c~ipc-mqueue-msg-sem-avoid-relying-on-a-stack-reference-past-its-expiry +4 -2
@@ -784,12 +784,14 @@ would_block:static inline void wake_up_sem_queue_prepare (struct sem_queue *q,int error,struct wake_q_head *wake_q) { -get_task_struct (q->sleeper); +struct task_struct *sleeper; + + sleeper =get_task_struct (q->sleeper);/* see SEM_BARRIER_2 for purpose/pairing */ smp_store_release (&q->status, error); -wake_q_add_safe (wake_q, q->sleeper); +wake_q_add_safe (wake_q, sleeper); }static void unlink_queue (struct sem_array *sma,struct sem_queue *q)
_
Andrew Morton
maintainerPATCH 4/10 tools/testing/selftests/exec: fix link error
In reply to Andrew MortonFrom: Yang Yingliang <[email protected]>
Subject: tools/testing/selftests/exec: fix link error
Fix the link error by adding '-static':
gcc -Wall -Wl,-z,max-page-size=0x1000 -pie load_address.c -o /home/yang/linux/tools/testing/selftests/exec/load_address_4096/usr/bin/ld: /tmp/ccopEGun.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `stderr@@GLIBC_2.17' which may bind externally can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /tmp/ccopEGun.o(.text+0x158): unresolvable R_AARCH64_ADR_PREL_PG_HI21 relocation against symbol `stderr@@GLIBC_2.17'/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make: *** [Makefile:25: tools/testing/selftests/exec/load_address_4096] Error 1
---
tools/testing/selftests/exec/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/exec/Makefile renamed from tools/testing/selftests/exec/Makefile~tools-testing-selftests-exec-fix-link-error +3 -3
@@ -28,8 +28,8 @@ $(OUTPUT)/execveat.denatured: $(OUTPUT)/ cp $< $@ chmod -x $@ $(OUTPUT)/load_address_4096: load_address.c - $(CC) $(CFLAGS) $(LDFLAGS) -Wl,-z,max-page-size=0x1000 -pie $< -o $@ + $(CC) $(CFLAGS) $(LDFLAGS) -Wl,-z,max-page-size=0x1000 -pie -static $< -o $@ $(OUTPUT)/load_address_2097152: load_address.c - $(CC) $(CFLAGS) $(LDFLAGS) -Wl,-z,max-page-size=0x200000 -pie $< -o $@ + $(CC) $(CFLAGS) $(LDFLAGS) -Wl,-z,max-page-size=0x200000 -pie -static $< -o $@ $(OUTPUT)/load_address_16777216: load_address.c - $(CC) $(CFLAGS) $(LDFLAGS) -Wl,-z,max-page-size=0x1000000 -pie $< -o $@ + $(CC) $(CFLAGS) $(LDFLAGS) -Wl,-z,max-page-size=0x1000000 -pie -static $< -o $@
_
Andrew Morton
maintainerPATCH 5/10 kasan: slab: always reset the tag in get_freepointer_safe()
In reply to Andrew MortonFrom: Alexander Potapenko <[email protected]>
Subject: kasan: slab: always reset the tag in get_freepointer_safe()
With CONFIG_DEBUG_PAGEALLOC enabled, the kernel should also untag the object pointer, as done in get_freepointer().
Failing to do so reportedly leads to SLUB freelist corruptions that manifest as boot-time crashes.
---
mm/slub.c | 1 + 1 file changed, 1 insertion(+)
mm/slub.c renamed from mm/slub.c~kasan-slab-always-reset-the-tag-in-get_freepointer_safe +1 -0
@@ -301,6 +301,7 @@ static inline void *get_freepointer_safeif (!debug_pagealloc_enabled_static ())return get_freepointer (s, object); + object =kasan_reset_tag (object); freepointer_addr = (unsigned long )object + s->offset;copy_from_kernel_nofault (&p, (void **)freepointer_addr,sizeof (p));return freelist_ptr (s, p, freepointer_addr);
_
Andrew Morton
maintainerPATCH 6/10 watchdog: reliable handling of timestamps
In reply to Andrew MortonFrom: Petr Mladek <[email protected]>
Subject: watchdog: reliable handling of timestamps
The commit 9bf3bc949f8aeefeacea4b ("watchdog: cleanup handling of false positives") tried to handle a virtual host stopped by the host a more straightforward and cleaner way.
But it introduced a risk of false softlockup reports. The virtual host might be stopped at any time, for example between kvm_check_and_clear_guest_paused() and is_softlockup(). As a result, is_softlockup() might read the updated jiffies are detects softlockup.
A solution might be to put back kvm_check_and_clear_guest_paused() after is_softlockup() and detect it. But it would put back the cycle that complicates the logic.
In fact, the handling of all the timestamps is not reliable. The code does not guarantee when and how many times the timestamps are read. For example, "period_ts" might be touched anytime also from NMI and re-read in is_softlockup(). It works just by chance.
Fix all the problems by making the code even more explicit.
1. Make sure that "now" and "period_ts" timestamps are read only once. They might be changed at anytime by NMI or when the virtual guest is stopped by the host. Note that "now" timestamp does this implicitly because "jiffies" is marked volatile.
2. "now" time must be read first. The state of "period_ts" will decide whether it will be used or the period will get restarted.
3. kvm_check_and_clear_guest_paused() must be called before reading "period_ts". It touches the variable when the guest was stopped.
As a result, "now" timestamp is used only when the watchdog was not touched and the guest not stopped in the meantime. "period_ts" is restarted in all other situations.
---
kernel/watchdog.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-)
kernel/watchdog.c renamed from kernel/watchdog.c~watchdog-reliable-handling-of-timestamps +20 -14
@@ -302,10 +302,10 @@ void touch_softlockup_watchdog_sync(void__this_cpu_write (watchdog_report_ts,SOFTLOCKUP_DELAY_REPORT ); } -static int is_softlockup (unsigned long touch_ts,unsigned long period_ts) +static int is_softlockup (unsigned long touch_ts, +unsigned long period_ts, +unsigned long now) { -unsigned long now =get_timestamp (); -if ((watchdog_enabled &SOFT_WATCHDOG_ENABLED ) && watchdog_thresh){/* Warn about unreasonable delays. */ if (time_after (now, period_ts +get_softlockup_thresh ()))
@@ -353,8 +353,7 @@ static int softlockup_fn(void *data)/* watchdog kicker functions */ static enum hrtimer_restart watchdog_timer_fn (struct hrtimer *hrtimer) { -unsigned long touch_ts =__this_cpu_read (watchdog_touch_ts); -unsigned long period_ts =__this_cpu_read (watchdog_report_ts); +unsigned long touch_ts, period_ts, now;struct pt_regs *regs =get_irq_regs ();int duration;int softlockup_all_cpu_backtrace = sysctl_softlockup_all_cpu_backtrace;
@@ -377,11 +376,22 @@ static enum hrtimer_restart watchdog_timhrtimer_forward_now (hrtimer,ns_to_ktime (sample_period));/* +* Read the current timestamp first. It might become invalid anytime +* when a virtual machine is stopped by the host or when the watchog +* is touched from NMI. +*/ + now =get_timestamp (); +/* * If a virtual machine is stopped by the host it can look to -* the watchdog like a soft lockup. Check to see if the host -* stopped the vm before we process the timestamps. +* the watchdog like a soft lockup. This function touches the watchdog. */ kvm_check_and_clear_guest_paused (); +/* +* The stored timestamp is comparable with @now only when not touched. +* It might get touched anytime from NMI. Make sure that is_softlockup() +* uses the same (valid) value. +*/ + period_ts =READ_ONCE (*this_cpu_ptr (&watchdog_report_ts));/* Reset the interval when touched by known problematic code. */ if (period_ts ==SOFTLOCKUP_DELAY_REPORT ) {
@@ -398,13 +408,9 @@ static enum hrtimer_restart watchdog_timreturn HRTIMER_RESTART ; } -/* check for a softlockup -* This is done by making sure a high priority task is -* being scheduled. The task touches the watchdog to -* indicate it is getting cpu time. If it hasn't then -* this is a good indication some task is hogging the cpu -*/ - duration =is_softlockup (touch_ts, period_ts); +/* Check for a softlockup. */ + touch_ts =__this_cpu_read (watchdog_touch_ts); + duration =is_softlockup (touch_ts, period_ts, now);if (unlikely (duration)) {/* * Prevent multiple soft-lockup reports if one cpu is already
_
Andrew Morton
maintainerPATCH 7/10 linux/bits.h: fix compilation error with GENMASK
In reply to Andrew MortonFrom: Rikard Falkeborn <[email protected]>
Subject: linux/bits.h: fix compilation error with GENMASK
GENMASK() has an input check which uses __builtin_choose_expr() to enable a compile time sanity check of its inputs if they are known at compile time. However, it turns out that __builtin_constant_p() does not always return a compile time constant [0]. It was thought this problem was fixed with gcc 4.9 [1], but apparently this is not the case [2].
Switch to use __is_constexpr() instead which always returns a compile time constant, regardless of its inputs.
[0]: https://lore.kernel.org/lkml/[email protected]
[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=19449
[2]: https://lore.kernel.org/lkml/[email protected]
---
include/linux/bits.h | 2 +- include/linux/const.h | 8 ++++++++ include/linux/minmax.h | 10 ++-------- tools/include/linux/bits.h | 2 +- tools/include/linux/const.h | 8 ++++++++ 5 files changed, 20 insertions(+), 10 deletions(-)
include/linux/bits.h renamed from include/linux/bits.h~linux-bitsh-fix-compilation-error-with-genmask +1 -1
@@ -22,7 +22,7 @@#include <linux/build_bug.h> #define GENMASK_INPUT_CHECK (h, l) \ (BUILD_BUG_ON_ZERO(__builtin_choose_expr( \ - __builtin_constant_p((l) > (h)), (l) > (h), 0))) + __is_constexpr((l) > (h)), (l) > (h), 0)))#else /* * BUILD_BUG_ON_ZERO is not available in h files included from asm files,
include/linux/const.h renamed from include/linux/const.h~linux-bitsh-fix-compilation-error-with-genmask +8 -0
@@ -3,4 +3,12 @@#include <vdso/const.h> +/* +* This returns a constant expression while determining if an argument is +* a constant expression, most importantly without evaluating the argument. +* Glory to Martin Uecker <[email protected]> +*/ +#define __is_constexpr (x) \ + (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8))) +#endif /* _LINUX_CONST_H */
include/linux/minmax.h renamed from include/linux/minmax.h~linux-bitsh-fix-compilation-error-with-genmask +2 -8
@@ -2,6 +2,8 @@#ifndef _LINUX_MINMAX_H#define _LINUX_MINMAX_H +#include <linux/const.h> +/* * min()/max()/clamp() macros must accomplish three things: *
@@ -17,14 +19,6 @@#define __typecheck (x, y) \ (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1))) -/* -* This returns a constant expression while determining if an argument is -* a constant expression, most importantly without evaluating the argument. -* Glory to Martin Uecker <[email protected]> -*/ -#define __is_constexpr (x) \ - (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8))) -#define __no_side_effects (x, y) \ (__is_constexpr(x) && __is_constexpr(y))
tools/include/linux/bits.h renamed from tools/include/linux/bits.h~linux-bitsh-fix-compilation-error-with-genmask +1 -1
@@ -22,7 +22,7 @@#include <linux/build_bug.h> #define GENMASK_INPUT_CHECK (h, l) \ (BUILD_BUG_ON_ZERO(__builtin_choose_expr( \ - __builtin_constant_p((l) > (h)), (l) > (h), 0))) + __is_constexpr((l) > (h)), (l) > (h), 0)))#else /* * BUILD_BUG_ON_ZERO is not available in h files included from asm files,
tools/include/linux/const.h renamed from tools/include/linux/const.h~linux-bitsh-fix-compilation-error-with-genmask +8 -0
@@ -3,4 +3,12 @@#include <vdso/const.h> +/* +* This returns a constant expression while determining if an argument is +* a constant expression, most importantly without evaluating the argument. +* Glory to Martin Uecker <[email protected]> +*/ +#define __is_constexpr (x) \ + (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8))) +#endif /* _LINUX_CONST_H */
_
Andrew Morton
maintainerPATCH 8/10 proc: remove Alexey from MAINTAINERS
In reply to Andrew MortonFrom: Alexey Dobriyan <[email protected]>
Subject: proc: remove Alexey from MAINTAINERS
People Cc me and I don't have time.
---
MAINTAINERS | 1 - 1 file changed, 1 deletion(-)
MAINTAINERS renamed from MAINTAINERS~proc-remove-myself-from-maintainers +0 -1
@@ -14735,7 +14735,6 @@ W: https://wireless.wiki.kernel.org/en/u F: drivers/net/wireless/intersil/prism54/ PROC FILESYSTEM -R: Alexey Dobriyan <[email protected]> L: [email protected] L: [email protected] S: Maintained
_
Andrew Morton
maintainerPATCH 9/10 lib: kunit: suppress a compilation warning of frame size
In reply to Andrew MortonFrom: Zhen Lei <[email protected]>
Subject: lib: kunit: suppress a compilation warning of frame size
lib/bitfield_kunit.c: In function `test_bitfields_constants':lib/bitfield_kunit.c:93:1: warning: the frame size of 7456 bytes is larger than 2048 bytes [-Wframe-larger-than=]
}
^
As the description of BITFIELD_KUNIT in lib/Kconfig.debug, it "Only useful for kernel devs running the KUnit test harness, and not intended for inclusion into a production build". Therefore, it is not worth modifying variable 'test_bitfields_constants' to clear this warning. Just suppress it.
---
lib/Makefile | 1 + 1 file changed, 1 insertion(+)
lib/Makefile renamed from lib/Makefile~lib-kunit-suppress-a-compilation-warning-of-frame-size +1 -0
@@ -348,6 +348,7 @@ obj-$(CONFIG_OBJAGG) += objagg.o obj-$(CONFIG_PLDMFW) += pldmfw/ # KUnit tests +CFLAGS_bitfield_kunit.o := $(call cc-option,-Wframe-larger-than=10240) obj-$(CONFIG_BITFIELD_KUNIT) += bitfield_kunit.o obj-$(CONFIG_LIST_KUNIT_TEST) += list-test.o obj-$(CONFIG_LINEAR_RANGES_TEST) += test_linear_ranges.o
_
Andrew Morton
maintainerPATCH 10/10 userfaultfd: hugetlbfs: fix new flag usage in error path
In reply to Andrew MortonFrom: Mike Kravetz <[email protected]>
Subject: userfaultfd: hugetlbfs: fix new flag usage in error path
In commit d6995da31122 ("hugetlb: use page.private for hugetlb specific page flags") the use of PagePrivate to indicate a reservation count should be restored at free time was changed to the hugetlb specific flag HPageRestoreReserve. Changes to a userfaultfd error path as well as a VM_BUG_ON() in remove_inode_hugepages() were overlooked.
Users could see incorrect hugetlb reserve counts if they experience an error with a UFFDIO_COPY operation. Specifically, this would be the result of an unlikely copy_huge_page_from_user error. There is not an increased chance of hitting the VM_BUG_ON.
---
fs/hugetlbfs/inode.c | 2 +- mm/userfaultfd.c | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-)
fs/hugetlbfs/inode.c renamed from fs/hugetlbfs/inode.c~userfaultfd-hugetlbfs-fix-new-flag-usage-in-error-path +1 -1
@@ -529,7 +529,7 @@ static void remove_inode_hugepages(struc* the subpool and global reserve usage count can need * to be adjusted. */ -VM_BUG_ON (PagePrivate (page)); +VM_BUG_ON (HPageRestoreReserve (page));remove_huge_page (page); freed++;if (!truncate_op) {
mm/userfaultfd.c renamed from mm/userfaultfd.c~userfaultfd-hugetlbfs-fix-new-flag-usage-in-error-path +14 -14
@@ -360,38 +360,38 @@ out:* If a reservation for the page existed in the reservation * map of a private mapping, the map was modified to indicate * the reservation was consumed when the page was allocated. -* We clear the PagePrivate flag now so that the global +* We clear the HPageRestoreReserve flag now so that the global * reserve count will not be incremented in free_huge_page. * The reservation map will still indicate the reservation * was consumed and possibly prevent later page allocation. * This is better than leaking a global reservation. If no -* reservation existed, it is still safe to clear PagePrivate -* as no adjustments to reservation counts were made during -* allocation. +* reservation existed, it is still safe to clear +* HPageRestoreReserve as no adjustments to reservation counts +* were made during allocation. * * The reservation map for shared mappings indicates which * pages have reservations. When a huge page is allocated * for an address with a reservation, no change is made to -* the reserve map. In this case PagePrivate will be set -* to indicate that the global reservation count should be +* the reserve map. In this case HPageRestoreReserve will be +* set to indicate that the global reservation count should be * incremented when the page is freed. This is the desired * behavior. However, when a huge page is allocated for an * address without a reservation a reservation entry is added -* to the reservation map, and PagePrivate will not be set. -* When the page is freed, the global reserve count will NOT -* be incremented and it will appear as though we have leaked -* reserved page. In this case, set PagePrivate so that the -* global reserve count will be incremented to match the -* reservation map entry which was created. +* to the reservation map, and HPageRestoreReserve will not be +* set. When the page is freed, the global reserve count will +* NOT be incremented and it will appear as though we have +* leaked reserved page. In this case, set HPageRestoreReserve +* so that the global reserve count will be incremented to +* match the reservation map entry which was created. * * Note that vm_alloc_shared is based on the flags of the vma * for which the page was originally allocated. dst_vma could * be different or NULL on error. */ if (vm_alloc_shared) -SetPagePrivate (page); +SetHPageRestoreReserve (page);else -ClearPagePrivate (page); +ClearHPageRestoreReserve (page);put_page (page); }BUG_ON (copied <0 );
_