Skip to contentSkip to conversation

Error while unlocking encrypted BCacheFS: Required key not available

DISCUSSION Martin Steigerwald 3 participants 8 messages Jan 7, 2024 – Jan 11, 2024

lore
Share & tools
lore
#0 lore raw

Hi!

Kernel 6.7.0-rc8 with BCacheFS new year fixes. Compliled with Debian gcc 13.2.0-9.

BCacheFS tools 1.3.3 – according to bcachefs version – from Debian package bcachefs-tools 24+really1.3.4-2.

Linux kernel keyutils from Debian package keyutils 1.6.3-2+b2. (Not sure whether really required.)

Created BCacheFS on external 4 TB SSD:

% mkfs.bcachefs -L […] --data_checksum xxhash --metadata_checksum xxhash --compression=lz4 --encrypted /dev/sda1

(also tried without xxhash, no difference)

Unlock attempt with incorrect passphrase:

% bcachefs unlock /dev/sda1
Enter passphrase:
incorrect passphrase

Unlock attempt with correct passphrase does not yield error message "incorrect passphrase". Key seems to be available:

% grep bcachefs /proc/keys
1b9e7153 I--Q--- 1 perm 3f010000 0 0 user bcachefs:[… UUID …]: 32

UUID matches filesystem.

Still I get:

% LANG=en mount /dev/sda1 /mnt/zeit
mount: /mnt/zeit: mount(2) system call failed: Required key not available.
dmesg(1) may have more information after failed mount system call.

% dmesg | tail -1

[105441.695035] bcachefs ([…]): error requesting encryption key: ENOKEY

Why? And how to fix it?

I found

error requesting encryption key #93

https://github.com/koverstreet/bcachefs/issues/93

But I am not sure whether it applies to my situation.

I use Devuan with elogind. Do I need that pam related configuration change from comment

https://github.com/koverstreet/bcachefs/issues/93#issuecomment-609430340

?

I do not like to do it in case it is not required.

Best,

Signature · 1 line
Martin
#1 lore raw

Martin Steigerwald - 07.01.24, 12:22:53 CET:

Quoted 25 lines

Hi!

Kernel 6.7.0-rc8 with BCacheFS new year fixes. Compliled with Debian gcc 13.2.0-9.

BCacheFS tools 1.3.3 – according to bcachefs version – from Debian package bcachefs-tools 24+really1.3.4-2.

Linux kernel keyutils from Debian package keyutils 1.6.3-2+b2. (Not sure whether really required.)

Created BCacheFS on external 4 TB SSD:

% mkfs.bcachefs -L […] --data_checksum xxhash --metadata_checksum xxhash --compression=lz4 --encrypted /dev/sda1

(also tried without xxhash, no difference)

Unlock attempt with incorrect passphrase:

% bcachefs unlock /dev/sda1
Enter passphrase:
incorrect passphrase

Quoted 5 lines

Unlock attempt with correct passphrase does not yield error message "incorrect passphrase". Key seems to be available:

% grep bcachefs /proc/keys
1b9e7153 I--Q--- 1 perm 3f010000 0 0 user bcachefs:[… UUID …]: 32

Also keyctl sees the key in root user keyring:

% keyctl list @u
1 key in keyring:
463368531: --alswrv 0 0 user: bcachefs:[… UUID …]

In case this is an issue with Debian packaging of bcachefs-tools I can report there.

Quoted 34 lines

UUID matches filesystem.

Still I get:

% LANG=en mount /dev/sda1 /mnt/zeit
mount: /mnt/zeit: mount(2) system call failed: Required key not available. dmesg(1) may have more information after failed mount system call.

% dmesg | tail -1

[105441.695035] bcachefs ([…]): error requesting encryption key: ENOKEY

Why? And how to fix it?

I found

error requesting encryption key #93

https://github.com/koverstreet/bcachefs/issues/93

But I am not sure whether it applies to my situation.

I use Devuan with elogind. Do I need that pam related configuration change from comment

https://github.com/koverstreet/bcachefs/issues/93#issuecomment-609430340

?

I do not like to do it in case it is not required.

Best,

Signature · 1 line
Martin
#2 lore raw
Quoted 2 lines · Martin Steigerwald

In case this is an issue with Debian packaging of bcachefs-tools I can report there.

What version of bcachefs-tools are you using? The default one in bookworm is v0.24 and is >1 year old and that may be the issue.

I'm starting to switch from btrfs to bcachefs and I backported v1.3.4 from sid.

AP

#3 lore raw

AP - 10.01.24, 03:13:01 CET:

Quoted 6 lines · Martin Steigerwald
Quoted 2 lines

In case this is an issue with Debian packaging of bcachefs-tools I can report there.

What version of bcachefs-tools are you using? The default one in bookworm is v0.24 and is >1 year old and that may be the issue.

As I wrote:

"BCacheFS tools 1.3.3 – according to bcachefs version – from Debian package bcachefs-tools 24+really1.3.4-2.".

Quoted 2 lines

I'm starting to switch from btrfs to bcachefs and I backported v1.3.4 from sid.

That is where above package is from.

Best,

Signature · 1 line
Martin
#4 lore raw
Quoted 10 lines · Martin Steigerwald

AP - 10.01.24, 03:13:01 CET:

Quoted 6 lines · Martin Steigerwald
Quoted 2 lines

In case this is an issue with Debian packaging of bcachefs-tools I can report there.

What version of bcachefs-tools are you using? The default one in bookworm is v0.24 and is >1 year old and that may be the issue.

As I wrote:

Quoted 7 lines

"BCacheFS tools 1.3.3 – according to bcachefs version – from Debian package bcachefs-tools 24+really1.3.4-2.".

Quoted 2 lines

I'm starting to switch from btrfs to bcachefs and I backported v1.3.4 from sid.

That is where above package is from.

The keyring stuff has been a perpetual utter headache.

I've been debating rewriting that stuff to just pass a memfd handle as a mount option and rip out keyring usage...

alternately - now that we're pretty much always mounting via the mount helper, perhaps it would be a little bit less fragile if the mount helper was adding the key to the keyring - that might be worth checking.

#5 lore raw

Hi!

Kent Overstreet - 10.01.24, 20:13:59 CET:

Quoted 21 lines · Martin Steigerwald
Quoted 11 lines

AP - 10.01.24, 03:13:01 CET:

Quoted 7 lines · Martin Steigerwald
Quoted 3 lines

In case this is an issue with Debian packaging of bcachefs-tools I can
report there.

What version of bcachefs-tools are you using? The default one in bookworm is v0.24 and is >1 year old and that may be the issue.

As I wrote:

Quoted 8 lines

"BCacheFS tools 1.3.3 – according to bcachefs version – from Debian package bcachefs-tools 24+really1.3.4-2.".

Quoted 3 lines

I'm starting to switch from btrfs to bcachefs and I backported v1.3.4
from sid.

That is where above package is from.

Quoted 8 lines

The keyring stuff has been a perpetual utter headache.

I've been debating rewriting that stuff to just pass a memfd handle as a mount option and rip out keyring usage...

alternately - now that we're pretty much always mounting via the mount helper, perhaps it would be a little bit less fragile if the mount helper was adding the key to the keyring - that might be worth checking.

So no suggestion what to try to make it work except for putting BCacheFS unto LUKS? I wanted to get rid of LUKS for removable media. Often enough I have "cryptsetup luksClose" complaining about still in use while I the filesystem on top of it clearly got unmounted already. In these case BTRFS still.

Ciao,

Signature · 1 line
Martin
#6 lore raw
Quoted 33 lines · Martin Steigerwald

Hi!

Kent Overstreet - 10.01.24, 20:13:59 CET:

Quoted 21 lines · Martin Steigerwald
Quoted 11 lines

AP - 10.01.24, 03:13:01 CET:

Quoted 7 lines · Martin Steigerwald
Quoted 3 lines

In case this is an issue with Debian packaging of bcachefs-tools I can
report there.

What version of bcachefs-tools are you using? The default one in bookworm is v0.24 and is >1 year old and that may be the issue.

As I wrote:

Quoted 8 lines

"BCacheFS tools 1.3.3 – according to bcachefs version – from Debian package bcachefs-tools 24+really1.3.4-2.".

Quoted 3 lines

I'm starting to switch from btrfs to bcachefs and I backported v1.3.4
from sid.

That is where above package is from.

Quoted 8 lines

The keyring stuff has been a perpetual utter headache.

I've been debating rewriting that stuff to just pass a memfd handle as a mount option and rip out keyring usage...

alternately - now that we're pretty much always mounting via the mount helper, perhaps it would be a little bit less fragile if the mount helper was adding the key to the keyring - that might be worth checking.

Quoted 5 lines

So no suggestion what to try to make it work except for putting BCacheFS unto LUKS? I wanted to get rid of LUKS for removable media. Often enough I have "cryptsetup luksClose" complaining about still in use while I the filesystem on top of it clearly got unmounted already. In these case BTRFS still.

I just made a couple suggestions. I'm sorry if they weren't exactly what you were looking for?

If you or someone else wants to help out by writing some code, I just laid out what needs to happen next - but I'm not your free helpdesk here, and you're expecting an imediate fix that's not how this works :)

#7 lore raw

Kent Overstreet - 11.01.24, 17:35:10 CET:

Quoted 6 lines

I just made a couple suggestions. I'm sorry if they weren't exactly what you were looking for?

If you or someone else wants to help out by writing some code, I just laid out what needs to happen next - but I'm not your free helpdesk here, and you're expecting an imediate fix that's not how this works :)

That is a misunderstanding. I am not expecting an immediate fix or a fix at all. I did not write I do either. So please do not read something into what I wrote that simply is not there.

My programming experience in C is more than 20 years old, certainly not kernel related and not even on the Linux platform and I thought there might be something I as an user might try to at least pin-point the cause of this issue a bit more. Apparently there is not and that is okay with me.

Nothing of what I do with BCacheFS has immediate urgency at the moment.

Signature · 1 line
Martin