Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1022642pxb; Wed, 6 Apr 2022 06:58:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTwxLTKCsErz9AgEPx1cXPqqbzMiJQDPR/AWY/BH0Fqi7Y7UBjidH3zngW8SdV5f9QM0/U X-Received: by 2002:a05:6a00:4198:b0:4fa:8591:5456 with SMTP id ca24-20020a056a00419800b004fa85915456mr8981859pfb.81.1649253530453; Wed, 06 Apr 2022 06:58:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649253530; cv=none; d=google.com; s=arc-20160816; b=q8ue3pl3OaaB/2mflSMSgT0CybzbdEm1dTNFUhCpn6DtItp6OYEYI4NMgOCOh7NHzz vCLTuBTLfIelIy99+wYwPVyDYqxnq6L7vTDGwtE8lHX4gUGhioVtZ2FK3NbBI+BVOUh8 z6y/hcqYwMTwbjy8TNznE9qO3jJ8dp+9ikQG6uIoc0AzEqZMEFm0ZamPEYsarChWHlOU ENllNgYzsTHVJnEY170PJqGq/0/nP7PSGgWX65qQF8kluN6kp5uLlJapRL7i8iyqdao/ +jXZYTKjR0K9naC61aNYlW1MbRGbJ/BXnLfC0O2zW192TUd6D/WWP2yl5PoFF86eCm+w uw5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=EeeKl1u8V97EQ6HIiwt+fDOQH9KAoTwi2Qb7vg7e3z4=; b=BilJCV6iXl7rWZZixa2fG3f++0iXgqIR4a2b+mKgJfdX1XiwWVaJg9qVodV5uUINeu nfP29MsfkkLnJuTB7B5n9MlroPF6h2dMDQe1tFK11Sb5HJH34UciWb+r6ZOzZN+fR03K PsiO/kxq/hzOYH/ejRAHlU6XbPBYwNc4uU9CmscmD7ma+o2Hb7HtUOKvdBkJbMLZc1yv AgF93Phhn0czis0U3MY7wBVEizTyp1bRdjWZ/LoeEclzX/WHCnulSzX8oAH3wMd7m3p4 fJ8+igcfsXPoSWA6pmoaGJUrhOlj8T/+JDgwbTIB8x0qKDejrFpllYTpiGDkV1NL4bEm zGOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RRiWXXKL; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id mh14-20020a17090b4ace00b001bf6715212dsi5497500pjb.104.2022.04.06.06.58.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 06:58:50 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RRiWXXKL; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 773501F95E8; Wed, 6 Apr 2022 04:50:56 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1843570AbiDFBlT (ORCPT + 99 others); Tue, 5 Apr 2022 21:41:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354199AbiDEKMP (ORCPT ); Tue, 5 Apr 2022 06:12:15 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76AA053A40; Tue, 5 Apr 2022 02:58:33 -0700 (PDT) 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 sin.source.kernel.org (Postfix) with ESMTPS id 2B007CE1BF8; Tue, 5 Apr 2022 09:58:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4CE18C385A2; Tue, 5 Apr 2022 09:58:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649152710; bh=izMv/LMDq16sbMxK8dWa52dHpvXUUl3PEqt/CPB1xl4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RRiWXXKLZM7LQp2NV/ekzsBTwdkn7MBDG7WaBz/PjoiCgX4996Fimmwoox6vwjPcu YzvJ9SLk0vYgCqAXee/XtUMSWCs1oME9q7S64LmHHgHQyaM2QwghAzkKWw6LPH//+v /9X+d8HiQsqF4yubR30NBtB/Co1G3UgnVZLJ5A0A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Randy Dunlap , Igor Zhbanov , Chris von Recklinghausen , Kees Cook , Andrew Morton , Linus Torvalds Subject: [PATCH 5.15 876/913] mm/usercopy: return 1 from hardened_usercopy __setup() handler Date: Tue, 5 Apr 2022 09:32:18 +0200 Message-Id: <20220405070406.081233495@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Randy Dunlap commit 05fe3c103f7e6b8b4fca8a7001dfc9ed4628085b 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 hardened_usercopy=off", 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 hardened_usercopy=off or hardened_usercopy=on but when "hardened_usercopy=foo" is used, there is no Unknown kernel command line parameter. Return 1 to indicate that the boot option has been handled. Print a warning if strtobool() returns an error on the option string, but do not mark this as in unknown command line option and do not cause init's environment to be polluted with this string. Link: https://lkml.kernel.org/r/20220222034249.14795-1-rdunlap@infradead.org Link: lore.kernel.org/r/64644a2f-4a20-bab3-1e15-3b2cdd0defe3@omprussia.ru Fixes: b5cb15d9372ab ("usercopy: Allow boot cmdline disabling of hardening") Signed-off-by: Randy Dunlap Reported-by: Igor Zhbanov Acked-by: Chris von Recklinghausen Cc: Kees Cook Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/usercopy.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/mm/usercopy.c +++ b/mm/usercopy.c @@ -294,7 +294,10 @@ static bool enable_checks __initdata = t static int __init parse_hardened_usercopy(char *str) { - return strtobool(str, &enable_checks); + if (strtobool(str, &enable_checks)) + pr_warn("Invalid option string for hardened_usercopy: '%s'\n", + str); + return 1; } __setup("hardened_usercopy=", parse_hardened_usercopy);