From patchwork Sat Jan 7 07:47:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 40318 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1205820wrt; Sat, 7 Jan 2023 00:09:08 -0800 (PST) X-Google-Smtp-Source: AMrXdXuXK5F/Y4QYv1jbNT/ICQ8il/0uOzBfx4QB1pDBaCf0dtYJDUAxghmgzLDIeE4j4mpOtRB2 X-Received: by 2002:a05:6a20:b29e:b0:ad:48b3:c5d1 with SMTP id ei30-20020a056a20b29e00b000ad48b3c5d1mr60135018pzb.47.1673078948196; Sat, 07 Jan 2023 00:09:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673078948; cv=none; d=google.com; s=arc-20160816; b=wT3eL19L4uNuYr4VueP5RknXzoVdZ/nsk8yH8Z3l66Q5teBe3TzmUiqFUFbeF9Zge6 c735QrTpMQYahLVIi79UYT7rA/YVTAjr/ibnklE7DxrH19/QKvN3DejskdXwobCxFim3 PwmJ3wiic0GkHRg3FpMHZlItk2dTVJzhwg63LdWjV8NXnmXmZb1dRwF1+wnChABHdSjM YhNdq3uHPh4s5w/Chlavthg/PYWIislUCLztPwLwwW65I/Rfd/Dq1MXMESnXm4DV9uVx sKRODuW6lyNVcz27wDK74ZLVat5YUsvTiLAq1Z/prkq58Vlm/XPhJOgQMQqrxZ8ntdbC U44A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=41nqa8sfQCl0OQtMNYUXZdRTsNtgjprnmmPwhB9bhBM=; b=CzbrhoQr8C7agnS61xAkiMvkDTGm8/38WBsl+H9PSDGKjrITz3Oczer1DZDcq4SeG3 75iK8SfqaWtHWGaz1Lbx8WdHv+lqg54lwEOebh9dpRud20I5h0joqfLvtXy0ZI/qAZb5 FP5c1QsKaxdyaJ8/dO1zGod42ka+K54og91yRB2GfPjGryGlVb7Ah2wk9qMlKqu5D/9c +uPmConBTEgFMVijJuGzYx5MMMoZogyopANGXsVTVdPCv/IJDREEZQ3FO9XeNOykM8j8 yuOwRmyVT1RgyNnyoPQ7vd6nrDZS2M4TU8/ODaQH/SV8/+rOiNN1s6Ug39VBxMNpxs2k C+kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=juaCeWzo; 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=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a21-20020a63e855000000b0047916fa90e6si3777332pgk.873.2023.01.07.00.08.51; Sat, 07 Jan 2023 00:09:08 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=juaCeWzo; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236595AbjAGHsP (ORCPT + 99 others); Sat, 7 Jan 2023 02:48:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231819AbjAGHsI (ORCPT ); Sat, 7 Jan 2023 02:48:08 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5240848D7; Fri, 6 Jan 2023 23:48:06 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id 1760FB81EBD; Sat, 7 Jan 2023 07:48:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C07CC433A0; Sat, 7 Jan 2023 07:47:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673077683; bh=RTLKdjUECYDxN3vnqCPtfGzhyPkDlqfYSeIu5deVu7c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=juaCeWzoPppUgCgLAK5poNkr4NGkQHZChSrHnc6v0NXJUrh/bjqfPkLLJPfoKrS/S Kx2/niq7Ryk1XIu6Vgc7/0AuEl3+yDECZmIlzNMlN0zeSfbGPQngtfly6fFfUy/nmT hVJymkx4kloc6n/XAgK171QkYSC/K0V7H5JzTeuaf1mchFVqjlN6S2lTmr25uAQmym iShi9MiZPF7mrU0/57SbX/qydgO1NYZNsY2Q5z9NAhTWPhb7OnPewDMX3OIlMwJoVf D14jYp1rTpsU65bAx2rjXncUys3JFYCTVcdBINy4xyS5x6YU0gVS5xOBU8e66lT1kV 4fSPQ/T5rKP0A== From: Masahiro Yamada To: linux-kernel@vger.kernel.org, Kentaro Takeda , Tetsuo Handa Cc: linux-kbuild@vger.kernel.org, Masahiro Yamada , James Morris , Paul Moore , "Serge E. Hallyn" , linux-security-module@vger.kernel.org Subject: [PATCH 3/3] tomoyo: Omit use of bin2c Date: Sat, 7 Jan 2023 16:47:43 +0900 Message-Id: <20230107074743.3352242-3-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230107074743.3352242-1-masahiroy@kernel.org> References: <20230107074743.3352242-1-masahiroy@kernel.org> MIME-Version: 1.0 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754350431226441447?= X-GMAIL-MSGID: =?utf-8?q?1754350431226441447?= bin2c was, as its name implies, introduced to convert a binary file to C code. However, I did not see any good reason ever for using this tool because using the .incbin directive is much faster, and often results in simpler code. Most of the uses of bin2c have been killed, for example: - 13610aa908dc ("kernel/configs: use .incbin directive to embed config_data.gz") - 4c0f032d4963 ("s390/purgatory: Omit use of bin2c") security/tomoyo/Makefile has even less reason for using bin2c because the policy files are text data. So, sed is enough for converting them to C string literals, and what is nicer, generates human-readable builtin-policy.h. This is the last user of bin2c. After this commit lands, bin2c will be removed. Signed-off-by: Masahiro Yamada --- security/tomoyo/Kconfig | 1 - security/tomoyo/Makefile | 15 ++++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/security/tomoyo/Kconfig b/security/tomoyo/Kconfig index b9f867100a9f..772d2ab58fd1 100644 --- a/security/tomoyo/Kconfig +++ b/security/tomoyo/Kconfig @@ -7,7 +7,6 @@ config SECURITY_TOMOYO select SECURITY_PATH select SECURITY_NETWORK select SRCU - select BUILD_BIN2C default n help This selects TOMOYO Linux, pathname-based access control. diff --git a/security/tomoyo/Makefile b/security/tomoyo/Makefile index 1b18a02ccd2e..77358b7655fa 100644 --- a/security/tomoyo/Makefile +++ b/security/tomoyo/Makefile @@ -2,13 +2,14 @@ obj-y = audit.o common.o condition.o domain.o environ.o file.o gc.o group.o load_policy.o memory.o mount.o network.o realpath.o securityfs_if.o tomoyo.o util.o targets += builtin-policy.h -define do_policy -echo "static char tomoyo_builtin_$(1)[] __initdata ="; \ -$(objtree)/scripts/bin2c <$(firstword $(wildcard $(obj)/policy/$(1).conf $(srctree)/$(src)/policy/$(1).conf.default) /dev/null); \ -echo ";" -endef -quiet_cmd_policy = POLICY $@ - cmd_policy = ($(call do_policy,profile); $(call do_policy,exception_policy); $(call do_policy,domain_policy); $(call do_policy,manager); $(call do_policy,stat)) >$@ + +quiet_cmd_policy = POLICY $@ + cmd_policy = { \ + $(foreach x, profile exception_policy domain_policy manager stat, \ + printf 'static char tomoyo_builtin_$x[] __initdata =\n'; \ + sed 's/\(.*\)/\t"\1\\n"/' $(firstword $(filter %/$x.conf %/$x.conf.default, $^) /dev/null); \ + printf '\t"";\n';) \ + } > $@ $(obj)/builtin-policy.h: $(wildcard $(obj)/policy/*.conf $(srctree)/$(src)/policy/*.conf.default) FORCE $(call if_changed,policy)