From patchwork Tue Feb 22 21:45:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Randy Dunlap X-Patchwork-Id: 12755972 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BBC8C433EF for ; Tue, 22 Feb 2022 21:45:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235834AbiBVVpv (ORCPT ); Tue, 22 Feb 2022 16:45:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232274AbiBVVpv (ORCPT ); Tue, 22 Feb 2022 16:45:51 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1774C3C21; Tue, 22 Feb 2022 13:45:23 -0800 (PST) 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=X/fCeEGE5dLzxBEqkKnk5/DMs8wiBbMxj32CoUOVL6k=; b=Ue4PuIli6voMrbrIqsbqv19UOh qUzMtx4H9Djv4Qxv7kQQ7fnQxc31zKKxr1Hfo6fhmb6pSoFCjNSe/8UHclsc8sXtvkxJ/k3DcibGa 9gycXO+qC3spzY1F7TQbgk0kyuvaTVJXn1AGWNQAfzUGR6i4DnnRubz3OK8GW0Su5VTfESPZBgC4Y 9QAFdpudH9V57ZFBgJuU80d0Exgj9aerhAPv9xHZRdanekEAPea3FBWe/q4t5b0wKHFgGGHvQQmmw AeE196bt7qOAvdY+rMwyQSXPjMPY/45CRi7SUxhsZK0O1TWAv/yrFU2JK6fI/29LNxAuUHVat4G63 QlDVLnyg==; 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 1nMcyF-00BhQy-Jc; Tue, 22 Feb 2022 21:45:19 +0000 From: Randy Dunlap To: linux-security-module@vger.kernel.org Cc: Randy Dunlap , Igor Zhbanov , Mimi Zohar , linux-integrity@vger.kernel.org, James Morris , "Serge E. Hallyn" Subject: [PATCH] EVM: fix the evm= __setup handler return value Date: Tue, 22 Feb 2022 13:45:18 -0800 Message-Id: <20220222214518.9316-1-rdunlap@infradead.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org __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 Cc: Mimi Zohar Cc: linux-integrity@vger.kernel.org Cc: James Morris Cc: "Serge E. Hallyn" --- security/integrity/evm/evm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- lnx-517-rc5.orig/security/integrity/evm/evm_main.c +++ lnx-517-rc5/security/integrity/evm/evm_main.c @@ -86,7 +86,7 @@ static int __init evm_set_fixmode(char * else pr_err("invalid \"%s\" mode", str); - return 0; + return 1; } __setup("evm=", evm_set_fixmode);