Commit Graph
8230 Commits
Author SHA1 Message Date
bbhtt b9ec9cab24 tests: Add test for NoRuntime extra-data app
(cherry picked from commit 79cb10e880)
2026-04-10 12:36:10 -04:00
Sebastian Wick 2bf787c496 tests: Add test-extra-data.sh to test extra-data installation
[smcv: Remove OCI test because #3790 was only solved in 1.17.x,
only keep libostree test]

(cherry picked from commit e9e713fa0d)
2026-04-10 12:36:10 -04:00
Simon McVittie a140dd1629 dir: In apply_extra_data(), don't assume there is always a runtime
org.freedesktop.Platform.openh264 is one example of an extension that
runs a statically-linked extra-data helper, with no runtime. Only open
the runtime if there is one.

Fixes: ac62ebe3 "run: Use O_PATH fds for the runtime and app deploy directories"
Resolves: https://github.com/flatpak/flatpak/issues/6583
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit c14ad37229)
2026-04-10 12:36:10 -04:00
Simon McVittie b942152bde run: Cope with an empty runtime
When FlatpakDir runs extra-data helpers in apply_extra_data(),
if the helper is statically linked, it might not need a runtime at all.
For example the helper for openh264 falls into this category.

Fixes: ac62ebe3 "run: Use O_PATH fds for the runtime and app deploy directories"
Helps: https://github.com/flatpak/flatpak/issues/6583
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit aa1a54c9da)
2026-04-10 12:36:10 -04:00
Sebastian Wick b020ba65ee Post-release version bump 2026-04-09 01:37:21 +02:00
Sebastian Wick 4b48ee8669 Update translation files for 1.16.5 1.16.5 2026-04-09 01:26:37 +02:00
Sebastian Wick 1e9a1df163 Update NEWS for 1.16.5 2026-04-09 01:26:09 +02:00
Sebastian Wick 8ebffc2ad3 tests/test-run-custom: Test --bind-fd and --ro-bind-fd 2026-04-08 19:07:46 -04:00
Sebastian Wick ab8ca4d6a0 tests/test-run-custom: Test --usr-path, --usr-fd, --app-path, --app-fd 2026-04-08 19:07:46 -04:00
Sebastian Wick ac540672bb run: Fix backport mistake
Not even sure how this happened. Whoops. It's time to get some sleep.

Fixes: c89a0c50 ("run: Use the same FD validation for all FD options")
2026-04-08 19:07:46 -04:00
Alberto Garcia 8e71548ab5 portal: use g_array_index() to read from expose_fds / expose_fds_ro
The data field of a GArray is a gchar* but we're storing integers
here, so use the proper method to ensure that we're getting the
element at the right offset and with the correct type.
2026-04-08 18:42:38 -04:00
Sebastian Wick 6118b415e4 run: Add bind-fd and ro-bind-fd binds after all other binds
This is only moving it a bit down because
flatpak_run_add_environment_args still adds a whole bunch of binds which
then can over-mount the user requested binds (bind-fd, ro-bind-fd).
2026-04-08 17:30:43 -04:00
Sebastian Wick c89a0c509a run: Use the same FD validation for all FD options 2026-04-08 17:30:43 -04:00
Sebastian Wick e654ebade0 run: Do not close --bind/--ro-bind 2026-04-08 17:30:43 -04:00
Sebastian Wick e2ef538e8d utils: Improve error message when passing an FD numer which is not a FD 2026-04-08 17:30:43 -04:00
Sebastian Wick bd41305b98 run: Fix fd tracking in flatpak_run_add_app_info_args
Calls to flatpak_bwrap_add_args_data_fd take ownership over the fd they
take. Closing them while they are still in the bwrap struct will abort
later when the bwrap struct gets freed and it tries to close the already
closed fd.

Fix this by using glnx_autofd and g_steal_fd.
2026-04-08 17:30:43 -04:00
Alberto Garcia 2e2f4a430b portal: update max_fd after creating the instance ID pipe
fd_map_remap_fd() is called several times after this, and without this
change it can allocate a target fd that collides with instance_id_fd.

Only the write end of the pipe needs to be considered because that's
the one passed to the child.

Closes: https://github.com/flatpak/flatpak/issues/6570
2026-04-08 16:07:17 -04:00
Simon McVittie ccd9c8a7fa run: Mount original app on /run/parent/app when using --app-path=""
Before addressing CVE-2026-34078, we would always mount the original app
*somewhere*, either /app (in the normal case) or /run/parent/app (when
using a custom or empty /app for the subsandbox). The empty-app case
regressed during the fix for CVE-2026-34078; bring back previous behaviour.

Fixes: ac62ebe3 "run: Use O_PATH fds for the runtime and app deploy directories"
Resolves: https://github.com/flatpak/flatpak/issues/6568
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit fde4716f67)
2026-04-08 13:40:44 +01:00
Xiangzhe d19f444080 run: Fix checking wrong variable in runtime fd selection
In flatpak_run_app(), the else-if branch that handles
FLATPAK_RUN_APP_DEPLOY_USR_ORIGINAL was checking custom_app_fd instead
of custom_runtime_fd. When custom_app_fd is APP_EMPTY (-3) and
custom_runtime_fd is USR_ORIGINAL (-2), the condition would not match
and fall through to g_assert_not_reached(), aborting the process.

This broke sub-sandbox spawning with --app-path="" (empty app), which
is used by steam-runtime-check-requirements to verify that Flatpak's
sub-sandbox mechanism works.

Fixes: ac62ebe3 "run: Use O_PATH fds for the runtime and app deploy directories"
Helps: https://github.com/flatpak/flatpak/issues/6568
(cherry picked from commit 066babba75)
2026-04-08 13:40:44 +01:00
Sebastian Wick 89e5c14edb Post-release version bump 2026-04-07 23:21:44 +02:00
Sebastian Wick 2cc39deb23 Update translation files for 1.16.4 1.16.4 2026-04-07 22:57:41 +02:00
Sebastian Wick 15dc23b1be Update NEWS for 1.16.4 2026-04-07 22:56:56 +02:00
Sebastian Wick a27ec46e8c system-helper: Only remove an ongoing pull if users match
The code would always remove a pull from the hashtable, and then check if the
users match and abort if they don't. Either way, the pull gets dropped.

Fix this by only removing the pull if the dir and the user match.
2026-04-07 16:30:26 -04:00
Sebastian Wick 4a678f463b utils: Do not follow symlinks in local_open_file
We use local_open_file in the context of the system helper to open
files written by a user. This means that we want to prevent DOS and
exposing files which only the system helper has access to.

To prevent DOS and avoid side-effects, the file is opened with
O_NONBLOCK and O_NOCTTY.

To prevent leaking files, the file is supposed to not open symlinks.
This part, we failed at. We check if the opened file is a regular file,
but what we actually checked is, if the file a symlink might point at is
a regular file.

Fix this by also specifying O_NOFOLLOW in openat.

(cherry picked from commit FIXME)
2026-04-07 16:24:25 -04:00
Sebastian Wick c97905c818 utils: Only remove cached files in the cache directory
The function flatpak_switch_symlink_and_remove is used to implement a
cache for ld.so (regenerate_ld_cache). If the active symlink changes to
a new cache file, the old cache file is supposed to get removed.

The symlink still points to the old cache file, so we would remove the
file that it points to and then point at the new file.

Because the symlink is under the app's control, the symlink can point
anywhere, and the removal happens in the host context, which allows an
app to remove arbitrary files on the host.

The filename of the cache files are checksums, which means that we can
ensure that the link is a file in the same directory of the link by
checking that it only contains the chars a-zA-Z0-9.

(cherry picked from commit FIXME)
2026-04-07 16:21:15 -04:00
Sebastian Wick c82a3d7716 portal: Use --bind-fd, --app-fd and --usr-fd options to avoid races
Now that flatpak_run_app accepts fds for app and runtime deploy, as well
as bind and ro-bind fds, and flatpak-run exposes the functionality, we
can finally hook this all up to the flatpak portal!
2026-04-07 16:17:51 -04:00
Sebastian Wick a971671f95 run: Add --(ro-)bind-fd options
Exposes the functionality added to flatpak_run_app in the previous
commit with two new options.
2026-04-07 16:17:51 -04:00
Sebastian Wick 4f1e7f8d17 run: Add (ro-)bind fds to flatpak_run_app
The flatpak portal allows apps to expose files and folders from within
the sandbox to a side-sandbox using flatpak-spawn. So far it has used
the --filesystem option to mount those files and folders, but it takes a
path. Paths are inherently racy and they allow the app to swap out any
component of the path with a symlink after handing it off. If they win
the race, flatpak will mount a completely different directory.

This adds a new way to mount files and directories based on O_PATH
file descriptor that needs to provided when execing the flatpak binary.
2026-04-07 16:17:51 -04:00
Sebastian Wick 494c5ea687 run: Add --usr-fd and --app-fd options
Exposes options to pass in a fd for the runtime and app deploy. The
flatpak portal will make use of this in a following commit.
2026-04-07 16:17:51 -04:00
Sebastian Wick 873ed8b371 run: Use O_PATH fds for the runtime and app deploy directories
This also allows us to use glnx_chaseat, and other at-functions to
traverse the filesystem tree in a safe way.

This is important because the app and runtime deploy directories can be
under an attackers control. The flatpak portal for example allows
sandboxed apps to provide them.

In particular, attacks where the deploy dirs get replaced by a symlink
pointing into the host system will be stopped by this.

Note that this change alone is not enough to avoid the attack, and the
portal has to be changed as well.
2026-04-07 16:17:51 -04:00
Sebastian Wick 5a7e677294 flatpak-bwrap: Use glnx_close_fd as clear func
We already have a function which clears a fd that a pointer points to,
so let's use it instead of duplicating the code.

Will become useful in a later commit as well.
2026-04-07 16:17:51 -04:00
Sebastian Wick fbe5a2faa7 utils: Add flatpak_parse_fd
This is meant to parse file descriptor strings passed via the command
line. It is not a security mechanism and will happily accept fds 0-3 as
well.
2026-04-07 16:17:51 -04:00
Sebastian Wick 36bd977772 flatpak-bwrap: Add dup-ing variant flatpak_bwrap_add_args_data_fd_dup 2026-04-07 16:17:51 -04:00
Simon McVittie af44a2c9ff Update subtree: libglnx 2026-04-07
* fdio: Avoid relying on VLAs or gcc-specific constant-folding
* errors: Fix URL to an old libgsystem commit
* lockfile: Assert non-null path in make_lock_file for analyzers
* backports: Add g_clear_fd
* glnx-errors.h: add glnx_fd_throw[_*] variants
* fdio: Add glnx_fd_reopen
* local-alloc: Remove duplicate definition of glnx_unref_object
* fdio: Add glnx_statx
* chase: Add glnx_chaseat which functions similar to openat2
* chase: Add glnx_chase_and_statxat

Signed-off-by: Simon McVittie <smcv@collabora.com>
2026-04-07 20:46:35 +01:00
Simon McVittie ccea836b79 Merge branch 'wip/smcv/autotools' into 'master'
build: Include glnx-chase in the Autotools build system, too

See merge request GNOME/libglnx!71
2026-04-07 14:54:55 +00:00
Simon McVittie e3006ead94 build: Include glnx-chase in the Autotools build system, too
Fixes: a973baad "chase: Add glnx_chaseat which functions similar to openat2"
Signed-off-by: Simon McVittie <smcv@collabora.com>
2026-04-06 21:29:01 +01:00
Simon McVittie aae4505722 Merge branch 'wip/smcv/chase' into 'master'
chase: Fix a memory leak and some undefined behaviour

See merge request GNOME/libglnx!69
2026-03-24 20:45:24 +00:00
Simon McVittie 6dbe18bcda chase: Factor out a function to append to the queue
Signed-off-by: Simon McVittie <smcv@collabora.com>
2026-03-24 20:43:47 +00:00
Simon McVittie 46205a62d2 chase: Don't leak struct glnx_statx when we go up a level
Signed-off-by: Simon McVittie <smcv@collabora.com>
2026-03-24 20:43:47 +00:00
Simon McVittie 916b70619c chase: Don't left-shift signed integer 1 by 31 places
This overflows, which is undefined behaviour (in practice it will usually
wrap around into unsigned space, but this can't be guaranteed).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2026-03-24 20:43:45 +00:00
Sebastian Wick 7c1e8bd756 Merge branch 'wip/chaseat' into 'master'
chase: Safely traversing the filesystem

See merge request GNOME/libglnx!64
2026-03-24 11:21:17 +00:00
Sebastian WickandClaude 4bacb4332a tests: Add comprehensive tests for glnx_chase_and_statxat
Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-17 18:40:38 +01:00
Sebastian Wick b4b9951901 chase: Add glnx_chase_and_statxat
This combines glnx_chaseat with a call to glnx_statx for convenience.
2026-03-17 18:40:38 +01:00
Sebastian Wick 5f92fc4a93 tests: Add comprehensive tests for glnx_chaseat 2026-03-17 18:40:38 +01:00
Sebastian Wick a973baad08 chase: Add glnx_chaseat which functions similar to openat2
The selling features are:

* Support for RESOLVE_BENEATH, RESOLVE_IN_ROOT and RESOLVE_NO_SYMLINKS
* Fallback from openat2 to open_tree to openat for compatibility
* Triggering of automounts
2026-03-17 18:40:38 +01:00
Sebastian Wick 2a75ac86e9 missing: Add syscall number for openat2() and open_tree()
They are taken from an older revision of systemd with minimal changes.
2026-03-12 00:41:48 +01:00
Sebastian Wick 01508367b4 fdio: Add glnx_statx 2026-03-12 00:41:48 +01:00
Sebastian Wick 14578d856e missing: Add syscall and structs for statx()
They are taken from an older revision of systemd with minimal changes.
2026-03-12 00:41:48 +01:00
Simon McVittie 8eb974e539 Merge branch 'wip/smcv/dup-unref-object' into 'master'
[trivial] local-alloc: Remove duplicate definition of glnx_unref_object

See merge request GNOME/libglnx!67
2026-03-10 17:32:50 +00:00
Colin Walters 287353e5ae Merge branch 'wip/smcv/wpointer-sign' into 'master'
[trivial] tests: Avoid a -Wpointer-sign warning

See merge request GNOME/libglnx!66
2026-03-10 17:11:27 +00:00