Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp650034pxb; Tue, 5 Apr 2022 17:18:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxqd3HJ7gk9WgPA+7ObsHaaNcjGb6zQGyBcZ7+bwnNTB3FOj7zgb66vb+u+76CXs1CHCpM X-Received: by 2002:a05:6402:d7:b0:413:673:ba2f with SMTP id i23-20020a05640200d700b004130673ba2fmr6151678edu.29.1649204294148; Tue, 05 Apr 2022 17:18:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649204294; cv=none; d=google.com; s=arc-20160816; b=U5lG2FCIIeLE3TrG84oRA11cNv8Ga++Nm3dLtx5fuBIJFbmLwavvcC07RHxS6oPLZv IVW79L9lNskLiMN5dzJOoVPxZReAUPK1g+bDU6o85PA54zTtgsbDJab6IpZmIuW4X0bH t9hGArqAcaZhxKPAUkbNebPYZmAlqea5Q/affEY6YqJQDaQitJo3uhr194n0ONvGqcl9 hafXMhTdd1fEYEj02lsLdEKRwPgbHQ1u3PXvRUQtV5Dw3/kJ79GsuH70BxWhbUUVQCsq Dklhcl1RdOW3i79hIE2PT3SCl29ko7oMW3sGrrhnt07BKwDRIevCOwAd2YE33kTRVmo6 5yAQ== 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=TK19uP4VRky1hE6VlILdzA+1gbmWWl7fO60psgCt1Eo=; b=lrZKLR2iW0yik9oYZlfXhEjXbbpbA6BzACLjYdki7evPBKl0UxPkvEsAyWW5avD0du Kfr1RS/NwWgfc++5ACLfzedm4r8iGAmmxLpwcPt/NDXGlbzex8gKbJ4kdjPCvhT+J8wN DaweKBR2ii9PJxbjJhHvxCPmHuIYD5NGaTpLyZl+Qgw7adiF/0L7pqpGpMpwZNWDoLAm ARW6TEkF++QJaNb3+TktheCCwTGIk5yGFCJxdWqngGDuLsuJKrFqKS0ViOE6Xyi2/Cs4 LaO/HF/8e8M+Bq0tW6yn+uLFilA36opkt5O1vUk9YgznclNG1MNGKylxuuqZe6yHG+g8 nk4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rJWs6uZd; 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 z8-20020a50da08000000b00418c2b5be93si10224055edj.373.2022.04.05.17.17.47; Tue, 05 Apr 2022 17:18:14 -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=rJWs6uZd; 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 S1355421AbiDEMuK (ORCPT + 99 others); Tue, 5 Apr 2022 08:50:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238809AbiDEJFa (ORCPT ); Tue, 5 Apr 2022 05:05:30 -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 C3CD43818F; Tue, 5 Apr 2022 01:56:09 -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 E3624614E4; Tue, 5 Apr 2022 08:56:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE26DC385A1; Tue, 5 Apr 2022 08:56:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649148968; bh=7Vx2WvST/3UetrRUM4JsvOUg6Uksvk+kePktchHbQIc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rJWs6uZdTxd0LEiXyYq3W4eaZ6olw98GsXL/V+KUovdENpaTB8OsAaf3GHqT68MYe ONeab5eQmhAOfVQtWGNiGIs0AKjMAhqWh1Lj5rHF3KIto4ShSImV/MeWU60+b6tY+U DXU7X7fWGJGlFIjrTttX97d6dnUtKRwrJJigalJ8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Randy Dunlap , Igor Zhbanov , James Morris , Kentaro Takeda , tomoyo-dev-en@lists.osdn.me, "Serge E. Hallyn" , Tetsuo Handa , Sasha Levin Subject: [PATCH 5.16 0545/1017] TOMOYO: fix __setup handlers return values Date: Tue, 5 Apr 2022 09:24:18 +0200 Message-Id: <20220405070410.464004240@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@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 39844b7e3084baecef52d1498b5fa81afa2cefa9 ] __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 strings "TOMOYO_loader=string1" and "TOMOYO_trigger=string2" causes an Unknown parameter message: Unknown kernel command line parameters "BOOT_IMAGE=/boot/bzImage-517rc5 TOMOYO_loader=string1 \ TOMOYO_trigger=string2", will be passed to user space. and these strings are 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 TOMOYO_loader=string1 TOMOYO_trigger=string2 With this change, these __setup handlers act as expected, and init's environment is not polluted with these strings. Fixes: 0e4ae0e0dec63 ("TOMOYO: Make several options configurable.") Signed-off-by: Randy Dunlap Reported-by: Igor Zhbanov Link: https://lore.kernel.org/r/64644a2f-4a20-bab3-1e15-3b2cdd0defe3@omprussia.ru Cc: James Morris Cc: Kentaro Takeda Cc: tomoyo-dev-en@lists.osdn.me Cc: "Serge E. Hallyn" Signed-off-by: Tetsuo Handa Signed-off-by: Sasha Levin --- security/tomoyo/load_policy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/security/tomoyo/load_policy.c b/security/tomoyo/load_policy.c index 3445ae6fd479..363b65be87ab 100644 --- a/security/tomoyo/load_policy.c +++ b/security/tomoyo/load_policy.c @@ -24,7 +24,7 @@ static const char *tomoyo_loader; static int __init tomoyo_loader_setup(char *str) { tomoyo_loader = str; - return 0; + return 1; } __setup("TOMOYO_loader=", tomoyo_loader_setup); @@ -64,7 +64,7 @@ static const char *tomoyo_trigger; static int __init tomoyo_trigger_setup(char *str) { tomoyo_trigger = str; - return 0; + return 1; } __setup("TOMOYO_trigger=", tomoyo_trigger_setup); -- 2.34.1