From patchwork Tue Mar 22 21:42:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12789117 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 49F52C4332F for ; Tue, 22 Mar 2022 21:42:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9829E6B00BB; Tue, 22 Mar 2022 17:42:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8BBD26B00BC; Tue, 22 Mar 2022 17:42:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 75CE86B00BD; Tue, 22 Mar 2022 17:42:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0182.hostedemail.com [216.40.44.182]) by kanga.kvack.org (Postfix) with ESMTP id 653496B00BB for ; Tue, 22 Mar 2022 17:42:29 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 257EB18209BD4 for ; Tue, 22 Mar 2022 21:42:29 +0000 (UTC) X-FDA: 79273346418.23.3690A49 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf17.hostedemail.com (Postfix) with ESMTP id AF65040022 for ; Tue, 22 Mar 2022 21:42:28 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1F0D9611B4; Tue, 22 Mar 2022 21:42:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8AADC340EE; Tue, 22 Mar 2022 21:42:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1647985347; bh=+jM+T2Xr+b7Pjmhh1FKJbinEX4Z6x00Ku09S6Q0DdpA=; h=Date:To:From:In-Reply-To:Subject:From; b=x+Z1IgL+D9OaavxQCvteIOAmxOihuq7OzFRE4Nm4EVLlFaNkdvAH+dTk/3Qg8nrCe 2up1LRVApKC5hdASVWFqz/m+6az/iBtBtEYSCTfZlUUE4bEG3e+KjfaRZn8K0TmV5u uFpgDf47Fkvs1/uyqxHw5U/QprCVoHRSe/sN6YHs= Date: Tue, 22 Mar 2022 14:42:27 -0700 To: i.zhbanov@omprussia.ru,hughd@google.com,rdunlap@infradead.org,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220322143803.04a5e59a07e48284f196a2f9@linux-foundation.org> Subject: [patch 077/227] mm/mmap: return 1 from stack_guard_gap __setup() handler Message-Id: <20220322214227.D8AADC340EE@smtp.kernel.org> Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=x+Z1IgL+; spf=pass (imf17.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Stat-Signature: pjb9fy1zwqc7co87egb5tp6af6apf1y5 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: AF65040022 X-HE-Tag: 1647985348-802967 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: From: Randy Dunlap Subject: mm/mmap: return 1 from stack_guard_gap __setup() handler __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 --- mm/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/mmap.c~mm-mmap-return-1-from-stack_guard_gap-__setup-handler +++ a/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);