Open marcin-github opened 1 month ago
The same happens if password file is empty (I have fs with empty password).
For a full reproduction against current master
:
head --bytes=1G < /dev/zero > loop
yes | bcachefs mkfs --encrypted loop
bcachefs unlock -f /dev/null loop
The error originates in https://github.com/koverstreet/bcachefs-tools/blob/master/c_src/tools-util.c#L127
if (!strlen(buf)) {
free(buf);
buf = NULL;
}
After reading the passphrase from file, we return NULL
if the passphrase was empty. Then later crypto_pwhash_scryptsalsa208sha256_ll
dies when it's been fed a null pointer for its passwd
argument.
Commit 7c39a1cf1bc499ff5c8776b455bb94dea4b8ca59 by Kent introduced the check for an empty passphrase, but I don't know why.
We have two ways forward:
Either: forbid empty passphrases, and fail with a proper error message. That would also entail teaching mkfs
to reject empty passphrases.
Or: handle empty passphrases in unlock
properly. Perhaps that's as easy as just deleting the four offending lines, but perhaps there are other consequences.
bcachefs unlock /dev/xxxx -f /dev/null
throws core:gdb: