From patchwork Tue Feb 22 00:58:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Randy Dunlap X-Patchwork-Id: 12754387 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51790C433F5 for ; Tue, 22 Feb 2022 00:58:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 81D408D0002; Mon, 21 Feb 2022 19:58:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7CBCD8D0001; Mon, 21 Feb 2022 19:58:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 693D38D0002; Mon, 21 Feb 2022 19:58:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id 59AC08D0001 for ; Mon, 21 Feb 2022 19:58:20 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 132A512044E for ; Tue, 22 Feb 2022 00:58:20 +0000 (UTC) X-FDA: 79168604760.10.64C3635 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf30.hostedemail.com (Postfix) with ESMTP id C57EA80004 for ; Tue, 22 Feb 2022 00:58:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=8esseIxDpLtfYeuDOxlgY2S2IYHgIucCVCH5cskkgTA=; b=e8GRw2szGsP7BHFrxqnu8hgp0U eHuIFbnwm1NqL4cQmzR+z+YyWME7r9ni5PhqX4+kq/MgbvpdBh0J9Pr3pid8yVd+scwjJ6lr2hjwL p+QL4WRESqpCExgkZXPYDElcbTO6C6FDDfhTJWyWdV0SWmaafdf/MkVakntciclj0fCS+XhjoL8kH 3FezNFiDO7YqM6Z6zUcPUGaWGlJjxWM0t8QhwAyaId0XSJtsVb5t1qyapLViB/xfcZZBOvUotY9ng eBaEb3sWRU+5ofLBZiibMbLNXfUm4GwfDSqyT340kY/GJUXO/e4zAxJylnpXZ7hWW36NgRMTGTLGw BuIG9AEA==; Received: from [2601:1c0:6280:3f0::aa0b] (helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nMJVM-007Ybe-IH; Tue, 22 Feb 2022 00:58:12 +0000 From: Randy Dunlap To: linux-mm@kvack.org Cc: Randy Dunlap , Igor Zhbanov , Andrew Morton , Johannes Weiner , Michal Hocko , Vladimir Davydov , cgroups@vger.kernel.org Subject: [PATCH 1/2] mm/memcontrol: return 1 from cgroup.memory __setup() handler Date: Mon, 21 Feb 2022 16:58:11 -0800 Message-Id: <20220222005811.10672-1-rdunlap@infradead.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Stat-Signature: 6a3nx75gsg16xqbde1bzcn1x8byd1jrm X-Rspam-User: Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=e8GRw2sz; spf=none (imf30.hostedemail.com: domain of rdunlap@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=rdunlap@infradead.org; dmarc=none X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: C57EA80004 X-HE-Tag: 1645491497-187727 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: __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 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 Cc: Andrew Morton Cc: Johannes Weiner Cc: Michal Hocko Cc: Vladimir Davydov Cc: cgroups@vger.kernel.org Reviewed-by: Michal Koutný --- mm/memcontrol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- linux-next-20220217.orig/mm/memcontrol.c +++ linux-next-20220217/mm/memcontrol.c @@ -7044,7 +7044,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); From patchwork Tue Feb 22 00:58:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Randy Dunlap X-Patchwork-Id: 12754386 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1DC4C433EF for ; Tue, 22 Feb 2022 00:58:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 117328D0003; Mon, 21 Feb 2022 19:58:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0C6EE8D0001; Mon, 21 Feb 2022 19:58:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EF7AB8D0003; Mon, 21 Feb 2022 19:58:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0159.hostedemail.com [216.40.44.159]) by kanga.kvack.org (Postfix) with ESMTP id E23468D0001 for ; Mon, 21 Feb 2022 19:58:20 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 7B68F181AC9CC for ; Tue, 22 Feb 2022 00:58:20 +0000 (UTC) X-FDA: 79168604760.16.0C59198 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf17.hostedemail.com (Postfix) with ESMTP id DD64440005 for ; Tue, 22 Feb 2022 00:58:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=oEyJbJhYQXkYNwqXWITqKDBHxJuIQyScQoAay2C9B64=; b=VX7RTF+lDwVNc2hJcTdhp4SAqs x/qkEMil97v3LLNgjuLGs2eDt2sip7GlaAWnj+S3LwY68wX2JBF15/2uwoMVpDGfZrEKfSLXrsbwi TDsiCGlYxi9vmC2H6EUahVvHDJxFQRXSft94x+5KLhaKuAAqAry6tlict3PWIWTzMv0SYcOJH7lUH D+mWPlKz84LINGbUtdFNrPqSPo0CJqoavX9nqsFufnsvy7Hi0cRc/WsacJ9+UOoyn3mctwxEaX/9o B7QEBfEMvVuhuPCopCen3qJVLmRAG5KnyKcLuAqfZGvG4VDF1XrLgR/NldFbZ8LoxZ86Vw/BnMM0U 3rgPL5ig==; Received: from [2601:1c0:6280:3f0::aa0b] (helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nMJVS-007YcT-Nf; Tue, 22 Feb 2022 00:58:18 +0000 From: Randy Dunlap To: linux-mm@kvack.org Cc: Randy Dunlap , Igor Zhbanov , Andrew Morton , Hugh Dickins Subject: [PATCH 2/2] mm/mmap: return 1 from stack_guard_gap __setup() handler Date: Mon, 21 Feb 2022 16:58:17 -0800 Message-Id: <20220222005817.11087-1-rdunlap@infradead.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: DD64440005 X-Stat-Signature: w7xmuwhgsuisq5wnhopr7wpjanjag3ty Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=VX7RTF+l; spf=none (imf17.hostedemail.com: domain of rdunlap@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=rdunlap@infradead.org; dmarc=none X-Rspam-User: X-HE-Tag: 1645491499-691515 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: __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. Fixes: 1be7107fbe18e ("mm: larger stack guard gap, between vmas") Signed-off-by: Randy Dunlap Reported-by: Igor Zhbanov Link: lore.kernel.org/r/64644a2f-4a20-bab3-1e15-3b2cdd0defe3@omprussia.ru Cc: Andrew Morton Cc: Hugh Dickins --- mm/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- linux-next-20220217.orig/mm/mmap.c +++ linux-next-20220217/mm/mmap.c @@ -2557,7 +2557,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);