Skip to content

Commit 405544d

Browse files
Nicolas Pitregregkh
Nicolas Pitre
authored andcommitted
kbuild: make scripts/adjust_autoksyms.sh robust against timestamp races
[ Upstream commit 825d487583089f9a33d31650c9c41f6474aab7fc ] Some filesystems have timestamps with coarse precision that may allow for a recently built object file to have the same timestamp as the updated time on one of its dependency files. When that happens, the object file doesn't get rebuilt as it should. This is especially the case on filesystems that don't have sub-second time precision, such as ext3 or Ext4 with 128B inodes. Let's prevent that by making sure updated dependency files have a newer timestamp than the first file we created (i.e. autoksyms.h.tmpnew). Reported-by: Thomas Lindroth <[email protected]> Signed-off-by: Nicolas Pitre <[email protected]> Tested-by: Thomas Lindroth <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 0839b0c commit 405544d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Diff for: scripts/adjust_autoksyms.sh

+7
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ while read sympath; do
8484
depfile="include/config/ksym/${sympath}.h"
8585
mkdir -p "$(dirname "$depfile")"
8686
touch "$depfile"
87+
# Filesystems with coarse time precision may create timestamps
88+
# equal to the one from a file that was very recently built and that
89+
# needs to be rebuild. Let's guard against that by making sure our
90+
# dep files are always newer than the first file we created here.
91+
while [ ! "$depfile" -nt "$new_ksyms_file" ]; do
92+
touch "$depfile"
93+
done
8794
echo $((count += 1))
8895
done | tail -1 )
8996
changed=${changed:-0}

0 commit comments

Comments
 (0)