summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/siggen.py
diff options
context:
space:
mode:
authorJoshua Watt <JPEWhacker@gmail.com>2022-08-03 09:04:41 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-08-09 16:28:03 +0100
commitfdc9d9e4fc386e178800b15ea22a368749e90965 (patch)
tree134ba923e8aa1935c6a2056f031e18d0169ce826 /bitbake/lib/bb/siggen.py
parentc58fca98e4959684c5d3f3ac93570ff06898df58 (diff)
downloadpoky-fdc9d9e4fc386e178800b15ea22a368749e90965.tar.gz
bitbake: siggen: Fix insufficent entropy in sigtask file names
Signature generation uses mkstemp() to get a file descriptor to a unique file and then write the signature into it. However, the unique file name generation in glibc is based on the system timestamp, which means that with highly parallel builds it is more likely than one might expect expected that a conflict will occur between two different builder nodes. When operating over NFS (such as a shared sstate cache), this can cause race conditions and rare failures (particularly with NFS servers that may not correctly implement O_EXCL). The signature generation code is particularly susceptible to races since a single "sigtask." prefix used for all signatures from all tasks, which makes collision even more likely. To work around this, add an internal implementation of mkstemp() that adds additional truly random entropy to the file name to eliminate conflicts. (Bitbake rev: 97955f3c1c738aa4b4478a6ec10a08094ffc689d) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/siggen.py')
-rw-r--r--bitbake/lib/bb/siggen.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/bitbake/lib/bb/siggen.py b/bitbake/lib/bb/siggen.py
index 3f3d6df54d..bb80343a97 100644
--- a/bitbake/lib/bb/siggen.py
+++ b/bitbake/lib/bb/siggen.py
@@ -425,7 +425,7 @@ class SignatureGeneratorBasic(SignatureGenerator):
425 bb.error("Taskhash mismatch %s versus %s for %s" % (computed_taskhash, self.taskhash[tid], tid)) 425 bb.error("Taskhash mismatch %s versus %s for %s" % (computed_taskhash, self.taskhash[tid], tid))
426 sigfile = sigfile.replace(self.taskhash[tid], computed_taskhash) 426 sigfile = sigfile.replace(self.taskhash[tid], computed_taskhash)
427 427
428 fd, tmpfile = tempfile.mkstemp(dir=os.path.dirname(sigfile), prefix="sigtask.") 428 fd, tmpfile = bb.utils.mkstemp(dir=os.path.dirname(sigfile), prefix="sigtask.")
429 try: 429 try:
430 with bb.compress.zstd.open(fd, "wt", encoding="utf-8", num_threads=1) as f: 430 with bb.compress.zstd.open(fd, "wt", encoding="utf-8", num_threads=1) as f:
431 json.dump(data, f, sort_keys=True, separators=(",", ":"), cls=SetEncoder) 431 json.dump(data, f, sort_keys=True, separators=(",", ":"), cls=SetEncoder)