[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aSn2NjaMqoyrP1k2@derry.ads.avm.de>
Date: Fri, 28 Nov 2025 20:21:26 +0100
From: Nicolas Schier <nsc@...nel.org>
To: Nathan Chancellor <nathan@...nel.org>
Cc: WangYuli <wangyuli@...c.io>, kees@...nel.org,
linux-hardening@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-kbuild@...r.kernel.org, WangYuli <wangyl5933@...naunicom.cn>
Subject: Re: [PATCH] fortify: Ignore intermediate *.tmp files
On Wed, Nov 12, 2025 at 03:36:06PM -0700, Nathan Chancellor wrote:
> On Wed, Nov 12, 2025 at 07:47:25PM +0800, WangYuli wrote:
> > From: WangYuli <wangyl5933@...naunicom.cn>
> >
> > The test_fortify.sh script generates logs of build-time warnings
> > for string and memory functions. To ensure the final log file is
> > updated atomically, the script first writes its output to a temporary
> > file with a .log.tmp extension. Upon successful completion, this
> > temporary file is renamed to the final .log file.
Sounds good, but does not reflect the current implementation:
The output log file may be written in several steps, and the temporary
file is not renamed but simply used to read the buffered output.
> >
> > If the build process is interrupted before this rename operation,
> > these *.log.tmp intermediate files will be left in the directory,
> > creating a risk of them being accidentally added to the git repository.
Instead of adding a directory specific ignore, I'd rather rename the
temporary file to match a global ignore pattern (e.g. '.*.tmp').
>
> Shouldn't the cleanup trap in lib/test_fortify/test_fortify.sh be enough
> to avoid leaving behind .log.tmp? Or does that only work for clean
> exits? Would adding INT to the trap avoid the problem?
Correct, the current 'EXIT' trap is only executed if test_fortify.sh
exits with 'exit' or reaches its EOF. We could add HUP, INT, QUIT, TERM
and PIPE as well, as it is done in scripts/Kbuild.include; this may be a
bit more than usually needed, but then we can expect the cleanup to
happen, too, if the script is killed by typical signals (or due to 'set
-e').
>
> > To prevent this from happening, add *.tmp to the .gitignore file to
> > explicitly ignore these temporary files.
> >
> > Signed-off-by: WangYuli <wangyl5933@...naunicom.cn>
> > Signed-off-by: WangYuli <wangyuli@...c.io>
>
> Regardless, this seems fine in the meantime.
>
> Reviewed-by: Nathan Chancellor <nathan@...nel.org>
I am going to send an alternative approach.
Kind regards,
Nicolas
Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)
Powered by blists - more mailing lists