Message ID | 20230109091919.3160916-1-masahiroy@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2057624wrt; Mon, 9 Jan 2023 01:29:20 -0800 (PST) X-Google-Smtp-Source: AMrXdXsR0lh/CI5KaWB7ajpFn0BV/1+jOGvekb4tzCZ+vks2ChIbBv1rj2ULTvRwS8bz0ZBUM5qa X-Received: by 2002:a05:6a20:c125:b0:b0:5144:2c1f with SMTP id bh37-20020a056a20c12500b000b051442c1fmr71307253pzb.52.1673256560186; Mon, 09 Jan 2023 01:29:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673256560; cv=none; d=google.com; s=arc-20160816; b=RFsD+mrzV7F8xTR0mGGqXy69vTXSOUEph7Vn5hRYxn1GvYmDLB/PMfPGbFtwFPPRyj Jd++VzB+Ramj8CK8iTBm354YGy8ighliYLJeOff5xYfLvbmKe3iXfQLrhVSqaQ+6eRl1 iBf82TagqVESvGUOLTl2lSNB5YuKQobioZBLx0iIa4XtnlWJGcMcxFBuZhGr8w8lot1u p5fpEM216YJS8O0ZgzWVHql3w4W9PrmTI3EkxQgh7kH2js/FlbfJGOfS5vAZmti0Ehjr azYdLytuVrwpabAZ/ouvg3h0WFzaB7m/DLAs7PHMVrUByhs46BbXug93XieOFGZevOrC 3wiA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=8q0y54WOtGMD4XDNbFIQLausxOCcPhUpP+H7fE1L6Ck=; b=yFP6nOAvZ3+C77DGp9YKtPBs+NHZVDEEot75iH2luNwMRXpEhrZDY8oErUUoBMt74m u0MYy4/xZwQ/zk9ZAewU+LlcptqdRL83+noQ1mrBnsC5mjIIxPqtETMFwDlYe5DJilc/ nnL6Y1EyZ6xjk7XpIiQqqY3D8UINc5UVbnscNmWptnGz4L0kCxbdfk0mkwUzHPvWh+n/ /IOf80YQuBq2/Up8mht+6sGRm53pbnL78NAGnvIALzU1NW5y7fqHwjWqML9BYWdF90Uz s3aXou2i4oQUcvicVzdEd6P/l+bEB8y3mJJMH8ZKdXGcSKcc69njQ5Kt7stLAC2Bj/vB HF0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cu0bjgAi; 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 h192-20020a636cc9000000b004784654214fsi8778844pgc.442.2023.01.09.01.29.07; Mon, 09 Jan 2023 01:29:20 -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=cu0bjgAi; 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 S236849AbjAIJV5 (ORCPT <rfc822;zhanglyra.2023@gmail.com> + 99 others); Mon, 9 Jan 2023 04:21:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236719AbjAIJV0 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 9 Jan 2023 04:21:26 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3410E9B; Mon, 9 Jan 2023 01:19:33 -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 sin.source.kernel.org (Postfix) with ESMTPS id 7CF04CE0B56; Mon, 9 Jan 2023 09:19:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BEE62C433D2; Mon, 9 Jan 2023 09:19:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673255969; bh=uKoGDZevx+gVbLfmMYY5TwRvq3hzb+5W3E7t3luGh1A=; h=From:To:Cc:Subject:Date:From; b=cu0bjgAitfPvflSUJnHrp6QmYi0GE/Ivp/cLcHFBiYYCZKJzzmqa30YoiR8gOknta jrmVw1Ts/hSx96TAliBUqVSE1XnU5rYiYhfXDeUlK56Qt/0utykZPeB/gXztTW1fPt 6Z/NzC6gGjKYvl0WnZ3M8sK/PcENnLcYRmHhz2nI4+Ta/xxybuob9quCnkbi+05I45 br3CJQkTOPj7oVTTD2c3vdS8EaLKA04i3X+SQdJyNd9HizbYP+lFR5j6S/GFxNgkzv RRY2rJXNc3TgNWGPjrjbEelogtX5u/XFGOBvIFLrWibkYgZe46j23F6kP51feUQfg6 w22Gm8VsjsuKQ== From: Masahiro Yamada <masahiroy@kernel.org> To: Kentaro Takeda <takedakn@nttdata.co.jp>, Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Cc: linux-kernel@vger.kernel.org, Masahiro Yamada <masahiroy@kernel.org>, James Morris <jmorris@namei.org>, Paul Moore <paul@paul-moore.com>, "Serge E. Hallyn" <serge@hallyn.com>, linux-security-module@vger.kernel.org Subject: [PATCH] tomoyo: remove a temporary output file Date: Mon, 9 Jan 2023 18:19:18 +0900 Message-Id: <20230109091919.3160916-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 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 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754536671055767016?= X-GMAIL-MSGID: =?utf-8?q?1754536671055767016?= |
Series |
tomoyo: remove a temporary output file
|
|
Commit Message
Masahiro Yamada
Jan. 9, 2023, 9:19 a.m. UTC
Commit 8ab5bc40aad4 ("tomoyo: Omit use of bin2c") was locally modified
on top of the patch I submitted.
I recommend writing to the target directly.
If the recipe command fails, Kbuild will automatically delete the target
because scripts/Kbuild.include defines .DELETE_ON_ERROR.
If the recipe command is interrupted, GNU Make will automatically
delete the target if it has been partially updated. There was a corner
case where the target was not cleaned up, but it was fixed by Commit
a7f3257da8a8 ("kbuild: remove the target in signal traps when
interrupted").
Since this is a general problem, you can leave it to Kbuild instead
of introducing unneeded complexity.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
If it is not too late, please squash this.
security/tomoyo/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 2023/01/09 18:19, Masahiro Yamada wrote: > Since this is a general problem, you can leave it to Kbuild instead > of introducing unneeded complexity. > If it is not too late, please squash this. It is not too late to apply. But how do you handle a case where the process who is responsible for deleting incomplete file was killed by e.g. OOM-killer?
On Mon, Jan 9, 2023 at 7:01 PM Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> wrote: > > On 2023/01/09 18:19, Masahiro Yamada wrote: > > Since this is a general problem, you can leave it to Kbuild instead > > of introducing unneeded complexity. > > > If it is not too late, please squash this. > > It is not too late to apply. But how do you handle a case where > the process who is responsible for deleting incomplete file was > killed by e.g. OOM-killer? > Good point. That is a rare case that Kbuild cannot handle. One idea is to make if_changed to write the command to *.cmd.tmp and rename it to *.cmd after everything succeeds. So, it is a similar approach, but the difference is that it is done in the Kbuild core scripts instead of every command. I will consider it. -- Best Regards Masahiro Yamada
On 2023/01/09 20:35, Masahiro Yamada wrote: > One idea is to make if_changed to write the command to *.cmd.tmp > and rename it to *.cmd after everything succeeds. > So, it is a similar approach, but the difference is that > it is done in the Kbuild core scripts instead of every command. > I will consider it. I see. Applied as https://osdn.net/projects/tomoyo/scm/git/tomoyo-test1/commits/80f8be7af03ffe90dc4df998b16bfa212afbdde9 . Thank you.
diff --git a/security/tomoyo/Makefile b/security/tomoyo/Makefile index 458cf5e2fa25..884ff155edc3 100644 --- a/security/tomoyo/Makefile +++ b/security/tomoyo/Makefile @@ -9,7 +9,7 @@ quiet_cmd_policy = POLICY $@ printf 'static char tomoyo_builtin_$x[] __initdata =\n'; \ sed -e 's/\\/\\\\/g' -e 's/\"/\\"/g' -e 's/\(.*\)/\t"\1\\n"/' -- $(firstword $(filter %/$x.conf %/$x.conf.default, $^) /dev/null); \ printf '\t"";\n';) \ - } > $@.tmp && mv $@.tmp $@ + } > $@ $(obj)/builtin-policy.h: $(wildcard $(obj)/policy/*.conf $(srctree)/$(src)/policy/*.conf.default) FORCE $(call if_changed,policy)