[LG G6 ROMs, Kernels, Recoveries, & Other Developme] lordoftheflows:
Decryption issues

Hi zefie, thanks to you and everybody contributing to the community.

Just starting with my new G6 H870 EUR (coming from G3), the bootloader is already unlocked and I'm working on getting TWRP working right now, and would be thankful for some advice.

The issues I'm seeing seem to be centered around encryption.

For the first attempt, I flashed Melina TWRP 3.2.1r3 after trying out the stock V10t-EUR-XXX ROM for a while. I had a lockscreen pattern and fingerprints enabled. Directly after applying the unlock.bin, I booted into TWRP.

I:Setting up '/data' as data/media emulated storage.
I:Can't probe device /dev/block/sda17
I:Unable to mount '/data'
I:Actual block device: '/dev/block/sda17', current file system: 'ext4'
I:Can't probe device /dev/block/sda17
I:Unable to mount '/data'
I:Actual block device: '/dev/block/sda17', current file system: 'ext4'
get_crypt_ftr_info crypto key location: '/dev/block/platform/soc/624000.ufshc/by-name/encrypt'
Bad magic for real block device /dev/block/platform/soc/624000.ufshc/by-name/encrypt
Could not mount /data and unable to find crypto footer.
I:Setting up '/data' as data/media emulated storage.
I:Can't probe device /dev/block/sda17
I:Unable to mount '/data'
I:Actual block device: '/dev/block/sda17', current file system: 'ext4'
I:Can't probe device /dev/block/sda17
Failed to mount '/data' (Unknown error 150)
I:Actual block device: '/dev/block/sda17', current file system: 'ext4'
Unable to recreate /data/media folder.
I:Can't probe device /dev/block/sda15
Failed to mount '/cache' (Unknown error 150)
I:Actual block device: '/dev/block/sda15', current file system: 'ext4'
I:Backup folder set to '/data/media/TWRP/BACKUPS/LGH870d4b723cc'
I:Settings storage is '/data/media'
I:Can't probe device /dev/block/sda17
I:Unable to mount '/data'
I:Actual block device: '/dev/block/sda17', current file system: 'ext4'
Updating partition details...
I:Can't probe device /dev/block/sda17
Failed to mount '/data' (Unknown error 150)
I:Actual block device: '/dev/block/sda17', current file system: 'ext4'
I:Can't probe device /dev/block/sda15
Failed to mount '/cache' (Unknown error 150)
I:Actual block device: '/dev/block/sda15', current file system: 'ext4'
I:Unable to mount '/usb-otg'
I:Actual block device: '', current file system: 'auto'
I:Unable to mount '/sd-ext'
I:Actual block device: '', current file system: 'ext4'
...done
I:Can't probe device /dev/block/sda17
I:Unable to mount '/data'
I:Actual block device: '/dev/block/sda17', current file system: 'ext4'
Unable to mount storage
I:Unmounting main partitions...

...

/data | /dev/block/sda17 | Size: 0MB Used: 0MB Free: 0MB Backup Size: 0MB
Flags: Can_Be_Mounted Can_Be_Wiped Can_Be_Backed_Up Wipe_During_Factory_Reset Wipe_Available_in_GUI IsPresent Can_Be_Encrypted Has_Data_Media Can_Encrypt_Backup Use_Userdata_Encryption Is_Storage Is_Settings_Storage
Symlink_Path: /data/media
Symlink_Mount_Point: /sdcard
Primary_Block_Device: /dev/block/sda17
Crypto_Key_Location: /dev/block/platform/soc/624000.ufshc/by-name/encrypt
Display_Name: Data
Storage_Name: Internal Storage
Backup_Path: /data
Backup_Name: data
Backup_Display_Name: Data
Storage_Path: /data/media
Current_File_System: ext4
Fstab_File_System: ext4
Backup_Method: files
Mount_Flags: 0, Mount_Options: discard
MTP_Storage_ID: 65537

After that, I figured I might have to boot up the ROM again after the wipe induced from the unlock.bin, so I did that. This time, I did not setup any kind of screen lock.

The behaviour of Melina TWRP is now different; it seems to recognize the encryption and asks for a password. Since I did not set up any password, I just tried 'default_password', which did not work. After pressing cancel, I get to the TWRP main screen alright.

I:Done processing fstab files
I:Setting up '/data' as data/media emulated storage.
I:Can't probe device /dev/block/sda17
I:Unable to mount '/data'
I:Actual block device: '/dev/block/sda17', current file system: 'ext4'
I:Can't probe device /dev/block/sda17
I:Unable to mount '/data'
I:Actual block device: '/dev/block/sda17', current file system: 'ext4'
get_crypt_ftr_info crypto key location: '/dev/block/platform/soc/624000.ufshc/by-name/encrypt'
I:Backup folder set to '/data/media/TWRP/BACKUPS/LGH870d4b72xxx'
I:Settings storage is '/data/media'
I:Device is encrypted with the default password, attempting to decrypt.
crypt_ftr->fs_size = 48037888
Using pbkdf2 for cryptfs KDF
Invalid hex string
kdf failed
failure decrypting master key
Failed to decrypt master key
crypt_ftr->fs_size = 48037888
Using pbkdf2 for cryptfs KDF
Enabling support for allow_discards in dmcrypt.
load_crypto_mapping_table: target_type = crypt
load_crypto_mapping_table: real_blk_name = /dev/block/sda17, extra_params = 1 allow_discards
22
22
22
22
22
22
22
22
22
22
Cannot load dm-crypt mapping table.
Error creating decrypted block device
TW_CRYPTO_USE_SYSTEM_VOLD := true
Checking existence of vendor and firmware partitions...
I:Is_Mounted: Unable to find partition for path '/vendor'
I:Is_Mounted: Unable to find partition for path '/firmware'
Attempting to use system's vold for decryption...
List of additional services for vold_decrypt:
qseecomd: Enabled as sys_qseecomd -> /system/bin/qseecomd (temporarily replacing TWRP's sbinqseecomd service)
Setting up folders and permissions...
Symlinking vendor folder...
Symlinking firmware folder...
Symlinking firmware files...
0 file(s) symlinked.
Starting services...
Start service sys_qseecomd: running.
Start service sys_vold: running.
About to run vdc...
Retrying connection to vold (Reason: Error connecting to cryptd: Connection refused)
Retrying connection to vold (Reason: 406 463 Error)
Retrying connection to vold (Reason: 406 464 Error)
Retrying connection to vold (Reason: 406 465 Error)
Retrying connection to vold (Reason: 406 466 Error)
Retrying connection to vold (Reason: 406 467 Error)
Retrying connection to vold (Reason: 406 468 Error)
Retrying connection to vold (Reason: 406 469 Error)
Retrying connection to vold (Reason: 406 470 Error)
Retrying connection to vold (Reason: 406 471 Error)
Retrying connection to vold (Reason: 406 472 Error)
Retrying connection to vold (Reason: 406 473 Error)
Retrying connection to vold (Reason: 406 474 Error)
Retrying connection to vold (Reason: 406 476 Error)
Retrying connection to vold (Reason: 406 481 Error)
Retrying connection to vold (Reason: 406 482 Error)
Retrying connection to vold (Reason: 406 483 Error)
Retrying connection to vold (Reason: 406 484 Error)
Retrying connection to vold (Reason: 406 485 Error)
Retrying connection to vold (Reason: 406 486 Error)
Decryption failed
Stopping services...
Stop service sys_vold: stopped.
Stop service sys_qseecomd: stopped.
Finished.
Failed to decrypt data.
Unable to decrypt with default password.
Updating partition details...
I:Unable to mount '/usb-otg'
I:Actual block device: '', current file system: 'auto'
I:Unable to mount '/sd-ext'
I:Actual block device: '', current file system: 'ext4'
...done
Unable to mount storage
I:Unmounting main partitions...

Looks like in this state, I could perform the intended TWRP operations if I formatted data (?).

I also noticed that the device partitions did not show up over USB on the PC (I think that did work on the previous attempt). The device is shown as 'offline'.

PS D:\Android\G6\platform-tools> .\adb.exe devices
List of devices attached
LGH870d4b72xxx offline

So after that, I wanted to give the official TWRP 3.2.1 a try. It seems the encryption can be handled fine there, but there's another problem: looks like it can't mount /system RW!

I:Done processing fstab files
I:Setting up '/data' as data/media emulated storage.
I:Can't probe device /dev/block/sda17
I:Unable to mount '/data'
I:Actual block device: '/dev/block/sda17', current file system: 'ext4'
I:Can't probe device /dev/block/sda17
I:Unable to mount '/data'
I:Actual block device: '/dev/block/sda17', current file system: 'ext4'
get_crypt_ftr_info crypto key location: '/dev/block/bootdevice/by-name/encrypt'
I:Backup folder set to '/data/media/TWRP/BACKUPS/LGH870d4b72xxx'
I:Settings storage is '/data/media'
I:Device is encrypted with the default password, attempting to decrypt.
crypt_ftr->fs_size = 48037888
Using pbkdf2 for cryptfs KDF
Invalid hex string
kdf failed
failure decrypting master key
Failed to decrypt master key
crypt_ftr->fs_size = 48037888
Using pbkdf2 for cryptfs KDF
Enabling support for allow_discards in dmcrypt.
load_crypto_mapping_table: target_type = crypt
load_crypto_mapping_table: real_blk_name = /dev/block/sda17, extra_params = 1 allow_discards
22
22
22
22
22
22
22
22
22
22
Cannot load dm-crypt mapping table.
Error creating decrypted block device
TW_CRYPTO_USE_SYSTEM_VOLD := true
Checking existence of vendor and firmware partitions...
I:Is_Mounted: Unable to find partition for path '/vendor'
I:Is_Mounted: Unable to find partition for path '/firmware'
Attempting to use system's vold for decryption...
List of additional services for vold_decrypt:
qseecomd: Enabled as sys_qseecomd -> /system/bin/qseecomd (temporarily replacing TWRP's sbinqseecomd service)
Setting up folders and permissions...
Symlinking vendor folder...
Symlinking firmware folder...
Symlinking firmware files...
0 file(s) symlinked.
Starting services...
Start service sys_qseecomd: running.
Start service sys_vold: running.
About to run vdc...
Connected to vold (213 479 defaultret=0)
vdc cryptfs result (passwd): 200 481 0 (ret=0)
Stopping services...
Stop service sys_vold: stopped.
Stop service sys_qseecomd: stopped.
Failed to unmount '/system' (Device or resource busy)
WARNING: system could not be unmounted normally!
Finished.
Data successfully decrypted, new block device: '/dev/block/dm-0'
I:mount -o bind '/data/media' '/sdcard' process ended with RC=0
I:Backup folder set to '/data/media/0/TWRP/BACKUPS/LGH870d4b72xxx'
Updating partition details...
I:mount -o bind '/data/media/0' '/sdcard' process ended with RC=0
I:Data backup size is 225MB, free: 22675MB.
I:cmd: /sbin/exfat-fuse -o big_writes,max_read=131072,max_write=131072 /dev/block/mmcblk0p1 /external_sd
I:Unable to mount '/usb-otg'
I:Actual block device: '', current file system: 'vfat'
...done
I:mount -o bind '/data/media/0' '/sdcard' process ended with RC=0
/data | /dev/block/dm-0 | Size: 22959MB Used: 225MB Free: 22675MB Backup Size: 225MB
Flags: Can_Be_Mounted Can_Be_Wiped Can_Be_Backed_Up Wipe_During_Factory_Reset Wipe_Available_in_GUI IsPresent Can_Be_Encrypted Is_Encrypted Is_Decrypted Has_Data_Media Can_Encrypt_Backup Use_Userdata_Encryption Is_Storage Is_Settings_Storage
Symlink_Path: /data/media/0
Symlink_Mount_Point: /sdcard
Primary_Block_Device: /dev/block/sda17
Decrypted_Block_Device: /dev/block/dm-0
Crypto_Key_Location: /dev/block/bootdevice/by-name/encrypt
Display_Name: data
Storage_Name: Internal Storage
Backup_Path: /data
Backup_Name: data
Backup_Display_Name: Data
Storage_Path: /data/media/0
Current_File_System: ext4
Fstab_File_System: ext4
Backup_Method: files
MTP_Storage_ID: 65537

I:Unmounting main partitions...
Successfully decrypted with default password.
I:Decrypt adopted storage starting
I:PageManager::LoadFileToBuffer loading filename: '/data/system/storage.xml' directly
I:successfully loaded storage.xml
Updating partition details...
I:Data backup size is 225MB, free: 22675MB.
I:cmd: /sbin/exfat-fuse -o big_writes,max_read=131072,max_write=131072 /dev/block/mmcblk0p1 /external_sd
I:Unable to mount '/usb-otg'
I:Actual block device: '', current file system: 'vfat'
...done
I:Unmounting main partitions...

/system | /dev/block/sda14 | Size: 5333MB Used: 5021MB Free: 312MB Backup Size: 5021MB
Flags: Can_Be_Mounted Can_Be_Wiped Can_Be_Backed_Up Wipe_Available_in_GUI IsPresent Mount_Read_Only
Primary_Block_Device: /dev/block/sda14
Display_Name: System
Storage_Name: System
Backup_Path: /system
Backup_Name: system
Backup_Display_Name: System
Storage_Path: /system
Current_File_System: ext4
Fstab_File_System: ext4
Backup_Method: files

/data | /dev/block/dm-0 | Size: 22959MB Used: 225MB Free: 22675MB Backup Size: 225MB
Flags: Can_Be_Mounted Can_Be_Wiped Can_Be_Backed_Up Wipe_During_Factory_Reset Wipe_Available_in_GUI IsPresent Can_Be_Encrypted Is_Encrypted Is_Decrypted Has_Data_Media Can_Encrypt_Backup Use_Userdata_Encryption Is_Storage Is_Settings_Storage
Symlink_Path: /data/media/0
Symlink_Mount_Point: /sdcard
Primary_Block_Device: /dev/block/sda17
Decrypted_Block_Device: /dev/block/dm-0
Crypto_Key_Location: /dev/block/bootdevice/by-name/encrypt
Display_Name: data
Storage_Name: Internal Storage
Backup_Path: /data
Backup_Name: data
Backup_Display_Name: Data
Storage_Path: /data/media/0
Current_File_System: ext4
Fstab_File_System: ext4
Backup_Method: files
MTP_Storage_ID: 65537

At least from there, I was able to do a full backup of all partitions (after mounting system RO -- that worked). This is recommended in the '11G ROM' thread, which is the ROM I want to install.

In order to proceed with that however, I'd like to make sure to have a reliable recovery with the following things:

System mounted RW (I guess, otherwise you cannot flash ROMs)

Data partition available no matter the encryption state

Seems that for the moment, I can get 1) with Melina, and 2) with official TWRP. Having both would be perfect :D

I can provide more logs, if it helps. A bit unsure on how to proceed here, as I'm afraid to break stuff due to missing knowledge.... should I just 'stop worrying and love the bomb', i.e. use Melina and format /data?

As I understand, this will remove the encryption. But if I wanted to use encryption later, would it be supported?