Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp687375pxb; Tue, 5 Apr 2022 18:49:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyXC6LNc0ekmM2hmuG7B0M6p5mirB8Pcqt0GUFZrnR7Pfl+s3bXgGUApBGnqiHWfjDKxF5 X-Received: by 2002:a17:902:d4cc:b0:156:3f4d:e0a5 with SMTP id o12-20020a170902d4cc00b001563f4de0a5mr6201788plg.91.1649209751038; Tue, 05 Apr 2022 18:49:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649209751; cv=none; d=google.com; s=arc-20160816; b=edLJ897+y1hRDZtWrx5+esMXwXcV2iW2r57xzZg7nqeQqph07OqzK4llyOnLrNaOtc jCQL63b7sewSs0JkZCSPkuzMo5W6XFFZcA9cL6u041ZpfxXlDztxQbkKd9dUG3BDmTwU KcRcl4X3Off9sgKB+wo7zbFJbrfi5EOQsqe8vkUpk2Mh4p63gHO5YhmmVhn9NiaqcMhs eZ8Mf2AIEhr+6p5IedIHmXoY9/YMYYBfymPvZG7v6MjSPTOpBMrbCUOl+JPjYsCYMIac tPp6AIOH+Xoilu/Rs1tHft0pZS0GOIcwqUlMDJMpZaEnZ4W+3MgUyjxVIFyRWPQ+Whf0 0vgQ== 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=G1+gvbQHB8WlSyOuGKRbTqy1XqCRGaWU/jbbptTwxQQ=; b=wXY8xGaMmiwL3Pu5qYhzuIHShsVkOkyPt+cSa5PXMbskObI9x+gW6uXCb1yVEa/+Pl djOv8M+hGlS1zF8JXLG4Uq51vYIerVjLqmqSZpJy6QX6hkM5teiEt+b/+IMvIwMPTOft wL09eROBJI3loC2/XSPKklw+F04VyR5aoJbUWdqmgBoWwN/ryvCTS3azHMz4h0xPwSDb G03DPTwr4erewAFSVcAaAY22AWOmkKzfXdoVZvxcMN6Q9s870vjpHqJ9uiiL2FOn1u79 3R+WdbXK0TlE4OVvhJCg1e+THAcQX4YHtUnkY9jCq+KO/NhXqv2Rz1YJXKRvdYEtKRkM Zrdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OKuG54wM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n2-20020a170902f60200b001568e8ab80dsi9994380plg.369.2022.04.05.18.48.53; Tue, 05 Apr 2022 18:49:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OKuG54wM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233686AbiDEIIt (ORCPT + 99 others); Tue, 5 Apr 2022 04:08:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232585AbiDEHxZ (ORCPT ); Tue, 5 Apr 2022 03:53:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07DF21DA51; Tue, 5 Apr 2022 00:49:06 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 49DEF61728; Tue, 5 Apr 2022 07:49:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 561E4C3410F; Tue, 5 Apr 2022 07:49:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649144945; bh=L/pyenQmUdfAnp5wcjo1xjpMHrfCLmOU2nZBPABT8/0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OKuG54wMAZ5GABS74pYpnqpoyB0XhshNVrVtLR8F5fKjHgvATNYAd9V8fBxKmn6rE BRmCfV2zGba678M71VrKwDTqSQ4NTBhHg71o+2IPBLTuV2w59IG8UX48jek/QJOFZw EDMSyGd7RUqmcaVc+wxGo/K9vkIy44ILWWN8AGEY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Randy Dunlap , Igor Zhbanov , Mimi Zohar , Sasha Levin Subject: [PATCH 5.17 0229/1126] EVM: fix the evm= __setup handler return value Date: Tue, 5 Apr 2022 09:16:16 +0200 Message-Id: <20220405070414.330175146@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@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=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 [ Upstream commit f2544f5e6c691679d56bb38637d2f347075b36fa ] __setup() handlers should return 1 if the parameter is handled. Returning 0 causes the entire string to be added to init's environment strings (limited to 32 strings), unnecessarily polluting it. Using the documented string "evm=fix" causes an Unknown parameter message: Unknown kernel command line parameters "BOOT_IMAGE=/boot/bzImage-517rc5 evm=fix", will be passed to user space. and that string is added to init's environment string space: Run /sbin/init as init process with arguments: /sbin/init with environment: HOME=/ TERM=linux BOOT_IMAGE=/boot/bzImage-517rc5 evm=fix With this change, using "evm=fix" acts as expected and an invalid option ("evm=evm") causes a warning to be printed: evm: invalid "evm" mode but init's environment is not polluted with this string, as expected. Fixes: 7102ebcd65c1 ("evm: permit only valid security.evm xattrs to be updated") Signed-off-by: Randy Dunlap Reported-by: Igor Zhbanov Link: lore.kernel.org/r/64644a2f-4a20-bab3-1e15-3b2cdd0defe3@omprussia.ru Signed-off-by: Mimi Zohar Signed-off-by: Sasha Levin --- security/integrity/evm/evm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c index 08f907382c61..7d87772f0ce6 100644 --- a/security/integrity/evm/evm_main.c +++ b/security/integrity/evm/evm_main.c @@ -86,7 +86,7 @@ static int __init evm_set_fixmode(char *str) else pr_err("invalid \"%s\" mode", str); - return 0; + return 1; } __setup("evm=", evm_set_fixmode); -- 2.34.1