Can't create CryFS encrypted volume due to high memory usage #23

Open
opened 2023-09-28 09:14:40 +02:00 by nasakoto · 11 comments

I can't create CryFS encrypted volume, neither ordinary or hidden. I tried all possible locations (DroidFS internal, phone, SD card). The error I got is "The volume creation has failed".
GocryptFS works fine.

DroidFS versions tried: 2.1.0 and 2.1.2 (both installed via F-droid)
Android version: 8.1.0

I can't create CryFS encrypted volume, neither ordinary or hidden. I tried all possible locations (DroidFS internal, phone, SD card). The error I got is "The volume creation has failed". GocryptFS works fine. DroidFS versions tried: 2.1.0 and 2.1.2 (both installed via F-droid) Android version: 8.1.0

Unfortunatly I cannot reproduce. It would be very helpful if you could show the logcat.

How long the message "Creating volume..." is displayed before showing the error?
Can you reproduce the issue with the APKs provided here?

Unfortunatly I cannot reproduce. It would be very helpful if you could show the logcat. How long the message "Creating volume..." is displayed before showing the error? Can you reproduce the issue with the APKs provided here?
Author

I tried the "universal" APK - still the same result. Unfortunately, I'm not a programmer, and I can't provide the logcat.

_ How long the message "Creating volume..." is displayed before showing the error?_

In the majority of cases this time is a fraction of a second, with one or two exceptions (for instance: the first time I tried to use aes-256, the "Creating volume..." message was displayed for about two seconds, followed by error, and on the second try (immediately after the first one), this time was considerably shorter.

Here are some screenshots:

https://i.postimg.cc/tC3vb2cf/Screenshot-20230928-080847.png

https://i.postimg.cc/RCnbsMLv/Screenshot-20230928-080851.png

https://i.postimg.cc/CLTr9Wck/Screenshot-20230928-080911.png

https://i.postimg.cc/XYx2GX4k/Screenshot-20230928-094857.png

I'm standing by for further assistance.

I tried the "universal" APK - still the same result. Unfortunately, I'm not a programmer, and I can't provide the logcat. > _ How long the message "Creating volume..." is displayed before showing the error?_ In the majority of cases this time is a fraction of a second, with one or two exceptions (for instance: the first time I tried to use aes-256, the "Creating volume..." message was displayed for about two seconds, followed by error, and on the second try (immediately after the first one), this time was considerably shorter. Here are some screenshots: https://i.postimg.cc/tC3vb2cf/Screenshot-20230928-080847.png https://i.postimg.cc/RCnbsMLv/Screenshot-20230928-080851.png https://i.postimg.cc/CLTr9Wck/Screenshot-20230928-080911.png https://i.postimg.cc/XYx2GX4k/Screenshot-20230928-094857.png I'm standing by for further assistance.

OK, that's hard to tell what's the problem without seeing the logcat. Can't you use adb or LogFox?

Do you have the same issue with different ciphers and different passwords (including empty)?

OK, that's hard to tell what's the problem without seeing the logcat. Can't you use `adb` or [LogFox](https://f-droid.org/en/packages/com.f0x1d.logfox)? Do you have the same issue with different ciphers and different passwords (including empty)?
Author

Sorry for the slow response, in the attached file is what I got.

The package is DroidFS-v2.1.2-universal.apk, directly downloaded from here.

(Just tried DroidFS-v2.1.3-universal.apk - same behaviour.)

Do you have the same issue with different ciphers and different passwords (including empty)?

Yes, all the ciphers and password lenghts (empty password, 1,3,8, 10 character) I tried failed.

Sorry for the slow response, in the attached file is what I got. The package is DroidFS-v2.1.2-universal.apk, directly downloaded from here. (Just tried DroidFS-v2.1.3-universal.apk - same behaviour.) > Do you have the same issue with different ciphers and different passwords (including empty)? Yes, all the ciphers and password lenghts (empty password, 1,3,8, 10 character) I tried failed.

Thank you very much. The only relevant line I spot in the provided logs is the following:

[libcryfs] [error] Crashed: std::bad_alloc

I think cryfs is failing to allocate enough memory for the scrypt derivation of the password.

How much memory does your device have? Are you using memory-hungry applications at the same time as DroidFS?

Are you using any special memory features from your ROM or other applications (such as memory usage constraints)?

Thank you very much. The only relevant line I spot in the provided logs is the following: ``` [libcryfs] [error] Crashed: std::bad_alloc ``` I think cryfs is failing to allocate enough memory for the scrypt derivation of the password. How much memory does your device have? Are you using memory-hungry applications at the same time as DroidFS? Are you using any special memory features from your ROM or other applications (such as memory usage constraints)?
Author

At the moment of writing: 3 Gb total memory, 1.7 Gb used.

Are you using any special memory features from your ROM or other applications (such as memory usage constraints)?

What did you say? ;-)
Smartphone related: I'm an ordinary, dumb user and I don't do anything unusual. Usually there are browser (Vivaldi), messenger (Threema), non-root firewall and e-mail client napping in the background.

At the moment of writing: 3 Gb total memory, 1.7 Gb used. > Are you using any special memory features from your ROM or other applications (such as memory usage constraints)? What did you say? ;-) Smartphone related: I'm an ordinary, dumb user and I don't do anything unusual. Usually there are browser (Vivaldi), messenger (Threema), non-root firewall and e-mail client napping in the background.

How many processor cores does your device have?

Can you try to close all running applications (force close if necessary), then try again to create a cryfs volume?

On my 8-core device, DroidFS memory usage increases to around 600 MB during CryFS password derivation. You can run top in a terminal on your device (or over adb) to see how much memory DroidFS is using (check the RES column).

How many processor cores does your device have? Can you try to close all running applications (force close if necessary), then try again to create a cryfs volume? On my 8-core device, DroidFS memory usage increases to around 600 MB during CryFS password derivation. You can run `top` in a terminal on your device (or over `adb`) to see how much memory DroidFS is using (check the `RES` column).
Author

I managed to free about 100 Mb of RAM killing whatever I saw - nothing changed. Memory used by the droidFS process never exceeds 130 Mb, as long as I can see it in top. I'm attaching a screenshot. My device has 4 processor cores.

I managed to free about 100 Mb of RAM killing whatever I saw - nothing changed. Memory used by the droidFS process never exceeds 130 Mb, as long as I can see it in `top`. I'm attaching a [screenshot](https://i.postimg.cc/6QNX8qR1/droidfs-top-2-c1.png). My device has 4 processor cores.

Does this also happen when opening an existing cryfs volume? (For example, creating a volume with the original cryfs program on the desktop, then trying to open it with DroidFS).

Can you try to reproduce the bug with gocryptfs, by editing the scrypt parameters in the gocryptfs.conf file? The default parameters used by cryfs are:

"scryptobject": {
	"n": 1048576,
	"r": 4,
	"p": 8,
}

However, gocryptfs doesn't allow r to be less than 8. Maybe you could try with:

"scryptobject": {
	"n": 1048576,
	"r": 8,
	"p": 8,
}
Does this also happen when opening an existing cryfs volume? (For example, creating a volume with the original cryfs program on the desktop, then trying to open it with DroidFS). Can you try to reproduce the bug with gocryptfs, by editing the scrypt parameters in the `gocryptfs.conf` file? The default parameters used by cryfs are: ```json "scryptobject": { "n": 1048576, "r": 4, "p": 8, } ``` However, gocryptfs doesn't allow `r` to be less than 8. Maybe you could try with: ```json "scryptobject": { "n": 1048576, "r": 8, "p": 8, } ```
Author

Please excuse my extreme delay!

Does this also happen when opening an existing cryfs volume? (For example, creating a volume with the original cryfs program on the desktop, then trying to open it with DroidFS).

Yes, but the error is different: "Open failed. Unknown error code: 0"
This particular volume was created on fairly modern phone, 8 cores/8 gigs RAM, using the DroidFS itself. I'm attaching the log captured (01-11_20-12-55.log)

Can you try to reproduce the bug with gocryptfs.....

I tried using the second set of parameters (those with "r": 8), and I got a DroidFS crash - all the three log files I obtained are attached too. I hope they can provide some information.

I'm standing by for any further assistance.

Please excuse my extreme delay! > Does this also happen when opening an existing cryfs volume? (For example, creating a volume with the original cryfs program on the desktop, then trying to open it with DroidFS). Yes, but the error is different: "Open failed. Unknown error code: 0" This particular volume was created on fairly modern phone, 8 cores/8 gigs RAM, using the DroidFS itself. I'm attaching the log captured (01-11_20-12-55.log) > Can you try to reproduce the bug with gocryptfs..... I tried using the second set of parameters (those with "r": 8), and I got a DroidFS crash - all the three log files I obtained are attached too. I hope they can provide some information. I'm standing by for any further assistance.

Interesting. The logcat when opening a volume shows the same error:

1698862389.068 10166  4786  4801 E spdlog  : [2023-11-01 20:13:09.067] [libcryfs] [error] Crashed: std::bad_alloc

If it crashed with gocryptfs then it's definitely a scrypt issue. Unfortunately, CryFS has not be designed to run on mobile devices and there are no ways to change the scrypt parameters at the moment. However, this is a TODO feature in DroidFS. When implemented, you will be able to reduce CryFS scrypt parameters and so create CryFS volumes.

Corresponding CryFS issue: https://github.com/cryfs/cryfs/issues/349

Interesting. The logcat when opening a volume shows the same error: ``` 1698862389.068 10166 4786 4801 E spdlog : [2023-11-01 20:13:09.067] [libcryfs] [error] Crashed: std::bad_alloc ``` If it crashed with gocryptfs then it's definitely a scrypt issue. Unfortunately, CryFS has not be designed to run on mobile devices and there are no ways to change the scrypt parameters at the moment. However, this is a TODO feature in DroidFS. When implemented, you will be able to reduce CryFS scrypt parameters and so create CryFS volumes. Corresponding CryFS issue: https://github.com/cryfs/cryfs/issues/349
hardcoresushi changed title from Can't create CryFS encrypted volume to Can't create CryFS encrypted volume due to high memory usage 2023-11-02 12:30:56 +01:00
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: hardcoresushi/DroidFS#23
No description provided.