From: Greg Kroah-Hartman Date: Mon, 4 Apr 2022 10:00:51 +0000 (+0200) Subject: 4.9-stable patches X-Git-Tag: v5.17.2~79 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=da6511cf3596834baa17aeb893235d0ad6f6363f;p=thirdparty%2Fkernel%2Fstable-queue.git 4.9-stable patches added patches: mm-memcontrol-return-1-from-cgroup.memory-__setup-handler.patch mm-mmap-return-1-from-stack_guard_gap-__setup-handler.patch --- diff --git a/queue-4.9/mm-memcontrol-return-1-from-cgroup.memory-__setup-handler.patch b/queue-4.9/mm-memcontrol-return-1-from-cgroup.memory-__setup-handler.patch new file mode 100644 index 00000000000..38eb068b7bd --- /dev/null +++ b/queue-4.9/mm-memcontrol-return-1-from-cgroup.memory-__setup-handler.patch @@ -0,0 +1,58 @@ +From 460a79e18842caca6fa0c415de4a3ac1e671ac50 Mon Sep 17 00:00:00 2001 +From: Randy Dunlap +Date: Tue, 22 Mar 2022 14:40:31 -0700 +Subject: mm/memcontrol: return 1 from cgroup.memory __setup() handler +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Randy Dunlap + +commit 460a79e18842caca6fa0c415de4a3ac1e671ac50 upstream. + +__setup() handlers should return 1 if the command line option is handled +and 0 if not (or maybe never return 0; it just pollutes init's +environment). + +The only reason that this particular __setup handler does not pollute +init's environment is that the setup string contains a '.', as in +"cgroup.memory". This causes init/main.c::unknown_boottoption() to +consider it to be an "Unused module parameter" and ignore it. (This is +for parsing of loadable module parameters any time after kernel init.) +Otherwise the string "cgroup.memory=whatever" would be added to init's +environment strings. + +Instead of relying on this '.' quirk, just return 1 to indicate that the +boot option has been handled. + +Note that there is no warning message if someone enters: + cgroup.memory=anything_invalid + +Link: https://lkml.kernel.org/r/20220222005811.10672-1-rdunlap@infradead.org +Fixes: f7e1cb6ec51b0 ("mm: memcontrol: account socket memory in unified hierarchy memory controller") +Signed-off-by: Randy Dunlap +Reported-by: Igor Zhbanov +Link: lore.kernel.org/r/64644a2f-4a20-bab3-1e15-3b2cdd0defe3@omprussia.ru +Reviewed-by: Michal Koutný +Cc: Johannes Weiner +Cc: Michal Hocko +Cc: Vladimir Davydov +Cc: Roman Gushchin +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman +--- + mm/memcontrol.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/mm/memcontrol.c ++++ b/mm/memcontrol.c +@@ -5840,7 +5840,7 @@ static int __init cgroup_memory(char *s) + if (!strcmp(token, "nokmem")) + cgroup_memory_nokmem = true; + } +- return 0; ++ return 1; + } + __setup("cgroup.memory=", cgroup_memory); + diff --git a/queue-4.9/mm-mmap-return-1-from-stack_guard_gap-__setup-handler.patch b/queue-4.9/mm-mmap-return-1-from-stack_guard_gap-__setup-handler.patch new file mode 100644 index 00000000000..a2bd202c6e2 --- /dev/null +++ b/queue-4.9/mm-mmap-return-1-from-stack_guard_gap-__setup-handler.patch @@ -0,0 +1,61 @@ +From e6d094936988910ce6e8197570f2753898830081 Mon Sep 17 00:00:00 2001 +From: Randy Dunlap +Date: Tue, 22 Mar 2022 14:42:27 -0700 +Subject: mm/mmap: return 1 from stack_guard_gap __setup() handler + +From: Randy Dunlap + +commit e6d094936988910ce6e8197570f2753898830081 upstream. + +__setup() handlers should return 1 if the command line option is handled +and 0 if not (or maybe never return 0; it just pollutes init's +environment). This prevents: + + Unknown kernel command line parameters \ + "BOOT_IMAGE=/boot/bzImage-517rc5 stack_guard_gap=100", will be \ + passed to user space. + + Run /sbin/init as init process + with arguments: + /sbin/init + with environment: + HOME=/ + TERM=linux + BOOT_IMAGE=/boot/bzImage-517rc5 + stack_guard_gap=100 + +Return 1 to indicate that the boot option has been handled. + +Note that there is no warning message if someone enters: + stack_guard_gap=anything_invalid +and 'val' and stack_guard_gap are both set to 0 due to the use of +simple_strtoul(). This could be improved by using kstrtoxxx() and +checking for an error. + +It appears that having stack_guard_gap == 0 is valid (if unexpected) since +using "stack_guard_gap=0" on the kernel command line does that. + +Link: https://lkml.kernel.org/r/20220222005817.11087-1-rdunlap@infradead.org +Link: lore.kernel.org/r/64644a2f-4a20-bab3-1e15-3b2cdd0defe3@omprussia.ru +Fixes: 1be7107fbe18e ("mm: larger stack guard gap, between vmas") +Signed-off-by: Randy Dunlap +Reported-by: Igor Zhbanov +Cc: Hugh Dickins +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman +--- + mm/mmap.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/mm/mmap.c ++++ b/mm/mmap.c +@@ -2425,7 +2425,7 @@ static int __init cmdline_parse_stack_gu + if (!*endptr) + stack_guard_gap = val << PAGE_SHIFT; + +- return 0; ++ return 1; + } + __setup("stack_guard_gap=", cmdline_parse_stack_guard_gap); + diff --git a/queue-4.9/series b/queue-4.9/series index ba296b1ac99..33edab03a40 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -153,3 +153,5 @@ ubifs-setflags-make-dirtied_ino_d-8-bytes-aligned.patch gfs2-make-sure-fitrim-minlen-is-rounded-up-to-fs-block-size.patch pinctrl-pinconf-generic-print-arguments-for-bias-pull.patch acpi-cppc-avoid-out-of-bounds-access-when-parsing-_cpc-data.patch +mm-mmap-return-1-from-stack_guard_gap-__setup-handler.patch +mm-memcontrol-return-1-from-cgroup.memory-__setup-handler.patch