data/siggen: Switch md5 -> sha256
PATCH 1/1 data/siggen: Switch md5 -> sha256
Similarly to the codeparser change, change to sha256 hashes due to worries over collisions. The main impact of this change is slightly slower parsing time as well as longer sstate file names.
--- lib/bb/data.py | 2 +- lib/bb/data_smart.py | 2 +- lib/bb/siggen.py | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-)
lib/bb/data.py +1 -1
@@ -436,7 +436,7 @@ def generate_dependency_hash(tasklist, gendeps, lookupcache, whitelist, fn): if var is not None: data = data + str(var) k = fn + "." + task - basehash[k] = hashlib.md5(data.encode("utf-8")).hexdigest() + basehash[k] = hashlib.sha256(data.encode("utf-8")).hexdigest() taskdeps[task] = alldeps return taskdeps, basehash
lib/bb/data_smart.py +1 -1
@@ -1074,4 +1074,4 @@ class DataSmart(MutableMapping): data.update({i:value}) data_str = str([(k, data[k]) for k in sorted(data.keys())]) - return hashlib.md5(data_str.encode("utf-8")).hexdigest() + return hashlib.sha256(data_str.encode("utf-8")).hexdigest()
lib/bb/siggen.py +3 -3
@@ -213,7 +213,7 @@ class SignatureGeneratorBasic(SignatureGenerator): self.taints[k] = taint logger.warning("%s is tainted from a forced run" % k) - h = hashlib.md5(data.encode("utf-8")).hexdigest() + h = hashlib.sha256(data.encode("utf-8")).hexdigest() self.taskhash[k] = h #d.setVar("BB_TASKHASH_task-%s" % task, taskhash[task]) return h
@@ -647,7 +647,7 @@ def calc_basehash(sigdata): if val is not None: basedata = basedata + str(val) - return hashlib.md5(basedata.encode("utf-8")).hexdigest() + return hashlib.sha256(basedata.encode("utf-8")).hexdigest() def calc_taskhash(sigdata): data = sigdata['basehash']
@@ -665,7 +665,7 @@ def calc_taskhash(sigdata): else: data = data + sigdata['taint'] - return hashlib.md5(data.encode("utf-8")).hexdigest() + return hashlib.sha256(data.encode("utf-8")).hexdigest() def dump_sigfile(a):
Signature · 1 line
2.19.1
Quoted 5 lines · Richard Purdie
Similarly to the codeparser change, change to sha256 hashes due to worries over collisions. The main impact of this change is slightly slower parsing time as well as longer sstate file names.
Signed-off-by Richard Purdie <[email protected]>
This change has given us several sstate cache filenames that exceed the 255 character limit of ext4. :(
We have a recipe that constructs a source tree from three separate Git repositories, so we end up with a PV that is 93 characters long, which doesn't help.
I've found that using urlsafe_b64encode to shorten the SHA-256 hashes reduces the filename lengths by 21 characters, which is more than the 14 characters we need to save. However, there's a risk of collisions if the cache is stored on a case-insensitive filesystem.
Would you be amenable to a patch to use urlsafe_b64encode?
If not, would you be amenable to a patch that consolidated the algorithm into a single function called from the places you changed so that we can patch it locally more easily? Or perhaps there's another way to make it configurable?
Thanks.
Mike.
Quoted 9 lines · Mike Crowe
Quoted 5 lines · Richard Purdie
Similarly to the codeparser change, change to sha256 hashes due to worries over collisions. The main impact of this change is slightly slower parsing time as well as longer sstate file names.
Signed-off-by Richard Purdie <[email protected]>This change has given us several sstate cache filenames that exceed the 255 character limit of ext4. :(
I wonder if another approach might be easier. Instead use change the filename to be:
sstate:<sstate_version>:<hash>:recipe:version:...:task.<type>
(<type> such as .tgz.signifo)
If the filename becomes too long, simply truncate the middle section) preserving:
sstate:<state_version>:<hash> and <type>
So the same truncation when matching, and it should be safe. The recipe, version ... task bit is nice to have for a human reader, but I don't think it's actually needed by the system itself.
This should avoid any collisions and keep the maximum information that will fit in the filename(s).
--Mark
Quoted 20 lines
We have a recipe that constructs a source tree from three separate Git repositories, so we end up with a PV that is 93 characters long, which doesn't help.
I've found that using
urlsafe_b64encodeto shorten the SHA-256 hashes reduces the filename lengths by 21 characters, which is more than the 14 characters we need to save. However, there's a risk of collisions if the cache is stored on a case-insensitive filesystem.Would you be amenable to a patch to use
urlsafe_b64encode?If not, would you be amenable to a patch that consolidated the algorithm into a single function called from the places you changed so that we can patch it locally more easily? Or perhaps there's another way to make it configurable?
Thanks.
Mike.
Quoted 34 lines · Mark Hatle
Quoted 7 lines · Mike Crowe
Quoted 6 lines · Richard Purdie
Similarly to the codeparser change, change to sha256 hashes due to worries
over collisions. The main impact of this change is slightly slower parsing
time as well as longer sstate file names.Quoted 6 lines
Quoted 2 lines
Signed-off-by Richard Purdie <[email protected]Quoted 1 line
This change has given us several sstate cache filenames that exceed the 255
character limit of ext4. :(I wonder if another approach might be easier. Instead use change the filename
to be:sstate:<sstate_version>:<hash>:recipe:version:...:task.<type>
(<type> such as .tgz.signifo)
If the filename becomes too long, simply truncate the middle section) preserving:
sstate:<state_version>:<hash> and <type>
So the same truncation when matching, and it should be safe. The recipe,
version ... task bit is nice to have for a human reader, but I don't think it's
actually needed by the system itself.
Quoted 3 lines
This should avoid any collisions and keep the maximum information that will fit
in the filename(s).
In some ways regardless of what we do, we need to abstract it so that we have one function generating the filenames.
So yes, think we need a patch which abstracts the filename generation. It needs to be able to truncate elements of the constructed name other than the hash. I do prefer truncating the other elements than changing the hash.
Cheers,
Richard
Quoted 20 lines · Richard Purdie
Quoted 19 lines · Mark Hatle
Quoted 7 lines · Mike Crowe
Quoted 6 lines · Richard Purdie
Similarly to the codeparser change, change to sha256 hashes due to worries
over collisions. The main impact of this change is slightly slower parsing
time as well as longer sstate file names.Quoted 6 lines
Quoted 2 lines
Signed-off-by Richard Purdie <[email protected]Quoted 1 line
This change has given us several sstate cache filenames that exceed the 255
character limit of ext4. :(I wonder if another approach might be easier. Instead use change the filename
to be:
Quoted 8 lines
Quoted 8 lines
sstate:<sstate_version>:<hash>:recipe:version:...:task.<type>
(<type> such as .tgz.signifo)
If the filename becomes too long, simply truncate the middle section) preserving:
sstate:<state_version>:<hash> and <type>
We make use of the recipe name in our sstate cache pruning script, since some recipes have more churn and we expire them more quickly. That shouldn't be a problem as long as the recipe name is kept in preference to the version.
Quoted 10 lines
Quoted 9 lines
So the same truncation when matching, and it should be safe. The recipe,
version ... task bit is nice to have for a human reader, but I don't think it's
actually needed by the system itself.This should avoid any collisions and keep the maximum information that will fit
in the filename(s).
Quoted 7 lines
In some ways regardless of what we do, we need to abstract it so that we have one function generating the filenames.
So yes, think we need a patch which abstracts the filename generation. It needs to be able to truncate elements of the constructed name other than the hash. I do prefer truncating the other elements than changing the hash.
If we're going to keep the 64-character SHA-256 hash and instead elide parts of the sstate filenames, then I think only sstate.bbclass needs to change, so this isn't a Bitbake issue and we should probably move this thread it openembedded-core.
Or perhaps I'm misunderstanding your suggestion.
Thanks.
Mike.
Quoted 28 lines · Mike Crowe
Quoted 27 lines · Richard Purdie
Quoted 26 lines · Mark Hatle
Quoted 7 lines · Mike Crowe
Quoted 6 lines · Richard Purdie
Similarly to the codeparser change, change to sha256 hashes due to worries
over collisions. The main impact of this change is slightly slower parsing
time as well as longer sstate file names.Quoted 6 lines
Quoted 2 lines
Signed-off-by Richard Purdie <[email protected]Quoted 1 line
This change has given us several sstate cache filenames that exceed the 255
character limit of ext4. :(I wonder if another approach might be easier. Instead use change the filename
to be:sstate:<sstate_version>:<hash>:recipe:version:...:task.<type>
(<type> such as .tgz.signifo)
If the filename becomes too long, simply truncate the middle section) preserving:
Quoted 6 lines
Quoted 1 line
Quoted 1 line
sstate:<state_version>:<hash> and <type>
We make use of the recipe name in our sstate cache pruning script, since some recipes have more churn and we expire them more quickly. That shouldn't be a problem as long as the recipe name is kept in preference to the version.
Ya, this is the human readable part. However, you can still dump the contents of the siginfo using the bitbake-dumpsig and get anything that was truncated off. So I would still consider it 'human readable', that happens to be machine readable in most cases.
Quoted 18 lines
Quoted 10 lines
Quoted 9 lines
So the same truncation when matching, and it should be safe. The recipe,
version ... task bit is nice to have for a human reader, but I don't think it's
actually needed by the system itself.This should avoid any collisions and keep the maximum information that will fit
in the filename(s).Quoted 7 lines
In some ways regardless of what we do, we need to abstract it so that we have one function generating the filenames.
So yes, think we need a patch which abstracts the filename generation. It needs to be able to truncate elements of the constructed name other than the hash. I do prefer truncating the other elements than changing the hash.
Quoted 6 lines
If we're going to keep the 64-character SHA-256 hash and instead elide parts of the sstate filenames, then I think only sstate.bbclass needs to change, so this isn't a Bitbake issue and we should probably move this thread it openembedded-core.
Or perhaps I'm misunderstanding your suggestion.
I'm not sure where all of the filenames are handled, if it's in oe-core sstate class, then yes.. I think moving the discussion is the right next move.
It may be a joint change though, if filename generation needs an API or sync with bitbake. (I've not touched this part before, so I really don't know how that part is generated.)
--Mark
Quoted 4 lines
Thanks.
Mike.
Quoted 4 lines · Mike Crowe
We make use of the recipe name in our sstate cache pruning script, since some recipes have more churn and we expire them more quickly. That shouldn't be a problem as long as the recipe name is kept in preference to the version.
Lets get the abstraction, then we can discuss which pieces make most sense and have which priority.
Quoted 23 lines
Quoted 15 lines
Quoted 10 lines
So the same truncation when matching, and it should be safe. The recipe,
version ... task bit is nice to have for a human reader, but I don't
think it's
actually needed by the system itself.This should avoid any collisions and keep the maximum information that will fit
in the filename(s).In some ways regardless of what we do, we need to abstract it so that
we have one function generating the filenames.Quoted 7 lines
So yes, think we need a patch which abstracts the filename generation.
It needs to be able to truncate elements of the constructed name other
than the hash. I do prefer truncating the other elements than changing
the hash.
Quoted 6 lines
If we're going to keep the 64-character SHA-256 hash and instead elide parts of the sstate filenames, then I think only sstate.bbclass needs to change, so this isn't a Bitbake issue and we should probably move this thread it openembedded-core.
Or perhaps I'm misunderstanding your suggestion.
No, this probably becomes an OE-Core issue. Keep in mind that some code does glob on these names though iirc so we'll have to consider those bits too.
Cheers,
Richard