linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tomoyo: remove a temporary output file
@ 2023-01-09  9:19 Masahiro Yamada
  2023-01-09 10:01 ` Tetsuo Handa
  0 siblings, 1 reply; 4+ messages in thread
From: Masahiro Yamada @ 2023-01-09  9:19 UTC (permalink / raw)
  To: Kentaro Takeda, Tetsuo Handa
  Cc: linux-kernel, Masahiro Yamada, James Morris, Paul Moore,
	Serge E. Hallyn, linux-security-module

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(-)

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)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] tomoyo: remove a temporary output file
  2023-01-09  9:19 [PATCH] tomoyo: remove a temporary output file Masahiro Yamada
@ 2023-01-09 10:01 ` Tetsuo Handa
  2023-01-09 11:35   ` Masahiro Yamada
  0 siblings, 1 reply; 4+ messages in thread
From: Tetsuo Handa @ 2023-01-09 10:01 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kernel, James Morris, Paul Moore, Serge E. Hallyn,
	linux-security-module, Kentaro Takeda

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?


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tomoyo: remove a temporary output file
  2023-01-09 10:01 ` Tetsuo Handa
@ 2023-01-09 11:35   ` Masahiro Yamada
  2023-01-09 12:59     ` Tetsuo Handa
  0 siblings, 1 reply; 4+ messages in thread
From: Masahiro Yamada @ 2023-01-09 11:35 UTC (permalink / raw)
  To: Tetsuo Handa
  Cc: linux-kernel, James Morris, Paul Moore, Serge E. Hallyn,
	linux-security-module, Kentaro Takeda

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tomoyo: remove a temporary output file
  2023-01-09 11:35   ` Masahiro Yamada
@ 2023-01-09 12:59     ` Tetsuo Handa
  0 siblings, 0 replies; 4+ messages in thread
From: Tetsuo Handa @ 2023-01-09 12:59 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kernel, James Morris, Paul Moore, Serge E. Hallyn,
	linux-security-module, Kentaro Takeda

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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-01-09 13:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-09  9:19 [PATCH] tomoyo: remove a temporary output file Masahiro Yamada
2023-01-09 10:01 ` Tetsuo Handa
2023-01-09 11:35   ` Masahiro Yamada
2023-01-09 12:59     ` Tetsuo Handa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).