Skip to content

ui: Disable core dumps for the UI process - #263

Merged
iinuwa merged 1 commit into
linux-credentials:mainfrom
kpanuragh:ui-core-dumps
Nov 13, 2026
Merged

iinuwa merged 1 commit into
linux-credentials:mainfrom
kpanuragh:ui-core-dumps

Conversation

@kpanuragh

Copy link
Copy Markdown
Contributor

Split out of #261 as requested. Part of #209.

credentialsd-ui handles PINs typed by the user. This PR sets RLIMIT_CORE to 0, both soft and hard, at startup, so that no core dump is written. systemd-coredump honours the limit: it logs "Resource limits disable core dumping" and stores nothing.

prctl(PR_SET_DUMPABLE, 0) would also block ptrace from other processes running as the same user. However, it makes /proc/<pid>/root unreadable to xdg-desktop-portal, which then rejects every portal call from the UI with "Portal operation not allowed: Unable to open /proc//root". That includes Settings.ReadOne, which GTK uses for the colour scheme (tested with xdg-desktop-portal 1.22.1). Until xdg-desktop-portal identifies callers another way, ptrace protection is left to Yama.

Testing

  • cargo test -p credentialsd-ui: a new test checks that the soft and hard core limits are both 0.
  • Ran credentialsd-ui: /proc/<pid>/limits shows Max core file size 0 0.
  • Ran a process with a core limit of 0 and sent it SIGSEGV: coredumpctl lists it with COREFILE none.

@iinuwa iinuwa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this: besides fixing the merge conflict, we should also add a Meson option to disable this hardening It should be on by default, in both release and debug profiles, but if a developer wants to investigate a crash, then they should be able to enable the option easily with meson setup reconfigure -Denable_core_dumps=true build, for example.

The UI handles PINs typed by the user, so set RLIMIT_CORE to zero (soft
and hard) at startup. systemd-coredump honours this and stores no core.

prctl(PR_SET_DUMPABLE, 0) was considered, but it makes /proc/<pid>/root
unreadable to xdg-desktop-portal, which then rejects every portal call
from the process, including the Settings portal GTK uses.

Part of linux-credentials#209.
@kpanuragh

Copy link
Copy Markdown
Contributor Author

Rebased on main (the conflict was CHANGELOG.md after #262) and added the option:

meson configure -Denable_core_dumps=true build

It defaults to false in both profiles, and it's passed to the UI as config::ENABLE_CORE_DUMPS. When it's true, the UI logs that core dumps are enabled and leaves RLIMIT_CORE alone. I checked /proc/<pid>/limits on a meson build: 0 0 by default and unlimited with the option. I also documented it in BUILDING.md (development section and the options table) and the changelog entry.

@iinuwa iinuwa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, thank you!

@iinuwa
iinuwa merged commit 2924a2f into linux-credentials:main Nov 13, 2026
1 check passed
@kpanuragh

Copy link
Copy Markdown
Contributor Author

Thanks for merging, @iinuwa! I have some time to contribute more. If there's an issue you'd like help with, or one that's a priority for you, feel free to assign it to me and I'll pick it up.

@iinuwa

iinuwa commented Nov 13, 2026

Copy link
Copy Markdown
Member

@kpanuragh thanks for your efforts! I think that the next biggest thing we need help with is Debian packaging. I created an issue 268 (not linking so that it doesn't show as related) with some information. Feel free to discuss on that issue or our matrix channel, #credentials-for-linux:matrix.org, if you are interested!

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.

2 participants