Skip to content

Safer accounts.toml updates#7988

Open
link2xt wants to merge 2 commits intomainfrom
link2xt/accounts.toml-sync-all
Open

Safer accounts.toml updates#7988
link2xt wants to merge 2 commits intomainfrom
link2xt/accounts.toml-sync-all

Conversation

@link2xt
Copy link
Collaborator

@link2xt link2xt commented Mar 14, 2026

It is not clear what the problem with Ubuntu Touch was that caused this, but the changes make accounts.toml sync safer in any case. There are other operating systems and possibly incorrect fdatasync() implementations, it is safer to just always use fsync(). This PR also syncs the rename().


There was a report that on Ubuntu Touch with fscrypt-encrypted filesystem, accounts.toml turned into a file with random contents.

Reading on fscrypt, it says each file has its own "nonce" which protects the file:
https://www.kernel.org/doc/html/v6.19/filesystems/fscrypt.html#per-file-encryption-keys
It is not clear if nonce is part of the "metadata" synced with fsync on the file handle. Also this does not explain why filename did not get corrupted, but only the bytes. Filenames in fscrypt are kind of special because they are also part of the directory, so it is still possible that it is fscrypt problem: https://www.kernel.org/doc/html/v6.19/filesystems/fscrypt.html#filenames-encryption

UBPorts documentation for fscrypt is at https://docs.ubports.com/en/latest/porting/configure_test_fix/Fscrypt.html

It could be that contents was corrupted because of use-after-free that is fixed with #7962
Account manager got freed and its memory was reused.

The file though looks entirely random. Does not have zero bytes, one 0xff, one 0x01, three 0x02, two 0x03, ..., two 0xd7, one 0xd8, two 0xd9 etc.

@link2xt link2xt force-pushed the link2xt/accounts.toml-sync-all branch from b96dec5 to 92a8019 Compare March 14, 2026 21:48
@link2xt link2xt marked this pull request as ready for review March 14, 2026 21:48
@link2xt link2xt changed the title fix: call sync_all() and not sync_data() when writing accounts.toml Safer accounts.toml updates Mar 14, 2026
@link2xt link2xt marked this pull request as draft March 14, 2026 21:59
@link2xt link2xt force-pushed the link2xt/accounts.toml-sync-all branch from 92a8019 to a18be15 Compare March 14, 2026 22:01
@link2xt link2xt marked this pull request as ready for review March 14, 2026 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant