public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/nautilus] rawhide: Fix CVE-2026-111802
@ 2026-10-30 18:23 Adrian Vovk
0 siblings, 0 replies; only message in thread
From: Adrian Vovk @ 2026-10-30 18:23 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/nautilus
Branch : rawhide
Commit : 29d3320e6dfee04a213b835d63906449c435712c
Author : Adrian Vovk <avovk@redhat.com>
Date : 2026-10-30T14:19:47-04:00
Stats : +404/-0 in 2 file(s)
URL : https://src.fedoraproject.org/rpms/nautilus/c/29d3320e6dfee04a213b835d63906449c435712c?branch=rawhide
Log:
Fix CVE-2026-111802
Assisted-by: Claude
---
diff --git a/CVE-2026-111802.patch b/CVE-2026-111802.patch
new file mode 100644
index 0000000..be13fe6
--- /dev/null
+++ b/CVE-2026-111802.patch
@@ -0,0 +1,402 @@
+[Adapted for Nautilus 51: the includes were different from the main branch
+so the patch wouldn't apply. Fixed the includes, and changed the hunk lines
+so that it can apply without fuzz]
+
+From 20e84b0e3799b8c753441500cac2df8c04a11788 Mon Sep 17 00:00:00 2001
+From: Corey Berla <corey@berla.me>
+Date: Sun, 11 Oct 2026 16:33:46 +0000
+Subject: [PATCH 1/2] file-operations: Ensure trash does not link to other
+ files
+
+When emptying a mount's trash on unmount, any component of the trash
+paths could be a symbolic link, e.g. .Trash-1000/files pointing at
+/home, causing the link target's contents to be deleted.
+
+Checking for symbolic links beforehand is racy, so instead walk the
+trash directories by file descriptor, opened with O_NOFOLLOW and never
+crossing filesystems, and delete their contents with unlinkat().
+
+The "files" and "info" directories themselves are now deleted too,
+which is fine as they are recreated when files are trashed.
+---
+ src/nautilus-file-operations.c | 149 ++++++++++++++++++++++++++++++++-
+ 1 file changed, 147 insertions(+), 2 deletions(-)
+
+diff --git a/src/nautilus-file-operations.c b/src/nautilus-file-operations.c
+index 1cf1b0e..a196d95 100644
+--- a/src/nautilus-file-operations.c
++++ b/src/nautilus-file-operations.c
+@@ -28,6 +28,9 @@
+ #include <stdarg.h>
+ #include <math.h>
+ #include <unistd.h>
++#include <sys/stat.h>
++#include <dirent.h>
++#include <fcntl.h>
+ #include <sys/types.h>
+ #include <stdlib.h>
+
+@@ -44,6 +47,7 @@
+ #include <gtk/gtk.h>
+ #include <gio/gio.h>
+ #include <glib.h>
++#include <glib-unix.h>
+
+ #include "nautilus-dialog-utilities.h"
+ #include "nautilus-error-reporting.h"
+@@ -141,6 +145,7 @@ typedef struct
+ {
+ CommonJob common;
+ GList *trash_dirs;
++ char *mount_root_path;
+ gboolean should_confirm;
+ NautilusOpCallback done_callback;
+ gpointer done_callback_data;
+@@ -2241,6 +2246,129 @@ get_trash_dirs_for_mount (GMount *mount)
+ return list;
+ }
+
++static void
++close_fd (gpointer data)
++{
++ g_clear_fd ((int *) data, NULL);
++}
++
++/* Doesn't follow symbolic links or cross into other filesystems. */
++static int
++open_untrusted_dir_at (int dirfd,
++ const char *name,
++ dev_t dev)
++{
++ g_autofd int fd = openat (dirfd, name,
++ O_RDONLY | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC | O_NOCTTY);
++ struct stat st;
++
++ if (fd < 0 || fstat (fd, &st) != 0 || st.st_dev != dev)
++ {
++ return -1;
++ }
++
++ return g_steal_fd (&fd);
++}
++
++static void
++append_trash_dir_at (GArray *fds,
++ int parent_fd,
++ const char *name,
++ dev_t dev)
++{
++ int fd = open_untrusted_dir_at (parent_fd, name, dev);
++
++ if (fd < 0)
++ {
++ return;
++ }
++
++ g_array_append_val (fds, fd);
++}
++
++/* The contents of a mount are not trusted, so paths below its root could be
++ * swapped for symbolic links at any time. Only use the returned fds. */
++static GArray *
++open_trash_dirs_at_mount_root (const char *root_path)
++{
++ GArray *fds = g_array_new (FALSE, FALSE, sizeof (int));
++ g_autofd int root_fd = -1;
++ g_autofd int shared_fd = -1;
++ g_autofree char *uid_name = g_strdup_printf ("%d", getuid ());
++ g_autofree char *user_trash_name = g_strdup_printf (".Trash-%d", getuid ());
++ struct stat root_st;
++
++ g_array_set_clear_func (fds, close_fd);
++
++ root_fd = open (root_path, O_RDONLY | O_DIRECTORY | O_CLOEXEC | O_NOCTTY);
++ if (root_fd < 0 || fstat (root_fd, &root_st) != 0)
++ {
++ return fds;
++ }
++
++ shared_fd = open_untrusted_dir_at (root_fd, ".Trash", root_st.st_dev);
++ if (shared_fd >= 0)
++ {
++ append_trash_dir_at (fds, shared_fd, uid_name, root_st.st_dev);
++ }
++
++ append_trash_dir_at (fds, root_fd, user_trash_name, root_st.st_dev);
++
++ return fds;
++}
++
++static char *
++get_native_root_path (GMount *mount)
++{
++ g_autoptr (GFile) root = g_mount_get_root (mount);
++
++ if (root == NULL || !g_file_is_native (root))
++ {
++ return NULL;
++ }
++
++ return g_file_get_path (root);
++}
++
++static void
++rm_rf_at (CommonJob *job,
++ int parent_fd,
++ const char *name,
++ dev_t dev)
++{
++ int fd = open_untrusted_dir_at (parent_fd, name, dev);
++ DIR *dir;
++ struct dirent *entry;
++
++ if (fd < 0)
++ {
++ unlinkat (parent_fd, name, 0);
++ return;
++ }
++
++ dir = fdopendir (fd);
++ if (dir == NULL)
++ {
++ close (fd);
++ return;
++ }
++
++ while (!job_aborted (job) && (entry = readdir (dir)) != NULL)
++ {
++ if (!g_str_equal (entry->d_name, ".") && !g_str_equal (entry->d_name, ".."))
++ {
++ rm_rf_at (job, dirfd (dir), entry->d_name, dev);
++ }
++ }
++
++ closedir (dir);
++
++ if (!job_aborted (job))
++ {
++ unlinkat (parent_fd, name, AT_REMOVEDIR);
++ }
++}
++
+ static AdwDialog *
+ create_empty_trash_prompt (UnmountData *data)
+ {
+@@ -2290,7 +2418,7 @@ empty_trash_prompt_cb (AdwDialog *dialog,
+
+ job = op_job_new (EmptyTrashJob, data->parent_window, NULL);
+ job->should_confirm = FALSE;
+- job->trash_dirs = get_trash_dirs_for_mount (data->mount);
++ job->mount_root_path = get_native_root_path (data->mount);
+ job->done_callback = empty_trash_for_unmount_done;
+ job->done_callback_data = data;
+
+@@ -7320,6 +7448,7 @@ empty_trash_task_done (GObject *source_object,
+ job = user_data;
+
+ g_list_free_full (job->trash_dirs, g_object_unref);
++ g_free (job->mount_root_path);
+
+ if (job->done_callback)
+ {
+@@ -7353,7 +7482,23 @@ empty_trash_thread_func (GTask *task,
+ {
+ confirmed = TRUE;
+ }
+- if (confirmed)
++ if (confirmed && job->mount_root_path != NULL)
++ {
++ g_autoptr (GArray) fds = open_trash_dirs_at_mount_root (job->mount_root_path);
++
++ for (guint i = 0; i < fds->len && !job_aborted (common); i++)
++ {
++ int trash_fd = g_array_index (fds, int, i);
++ struct stat st;
++
++ if (fstat (trash_fd, &st) == 0)
++ {
++ rm_rf_at (common, trash_fd, "files", st.st_dev);
++ rm_rf_at (common, trash_fd, "info", st.st_dev);
++ }
++ }
++ }
++ else if (confirmed)
+ {
+ for (l = job->trash_dirs;
+ l != NULL && !job_aborted (common);
+--
+2.56.0
+
+
+From b7835e3496bb46b305670924e4a8bfb68b3956a8 Mon Sep 17 00:00:00 2001
+From: Corey Berla <corey@berla.me>
+Date: Wed, 21 Oct 2026 16:36:34 -0700
+Subject: [PATCH 2/2] file-operations: Simplify emptying trash
+
+Now that emptying mounts' trash no longer uses trash_dirs
+we only use that list for emptying the main trash. Simplify
+the logic to just delete top levels folders (which is all
+that is necessary for the main trash)
+---
+ src/nautilus-file-operations.c | 91 ++++++++++------------------------
+ 1 file changed, 27 insertions(+), 64 deletions(-)
+
+diff --git a/src/nautilus-file-operations.c b/src/nautilus-file-operations.c
+index a196d95..8e56556 100644
+--- a/src/nautilus-file-operations.c
++++ b/src/nautilus-file-operations.c
+@@ -144,7 +144,6 @@ typedef struct
+ typedef struct
+ {
+ CommonJob common;
+- GList *trash_dirs;
+ char *mount_root_path;
+ gboolean should_confirm;
+ NautilusOpCallback done_callback;
+@@ -7381,61 +7380,37 @@ nautilus_file_operations_new_file (GtkWidget *parent_view,
+
+
+ static void
+-delete_trash_file (CommonJob *job,
+- GFile *file,
+- gboolean del_file,
+- gboolean del_children)
++delete_main_trash_contents (CommonJob *job)
+ {
++ g_autoptr (GFile) trash = g_file_new_for_uri (SCHEME_TRASH ":");
++ g_autoptr (GFileEnumerator) enumerator = NULL;
+ GFileInfo *info;
+- GFile *child;
+- GFileEnumerator *enumerator;
+
+- if (job_aborted (job))
++ enumerator = g_file_enumerate_children (trash,
++ G_FILE_ATTRIBUTE_STANDARD_NAME,
++ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
++ job->cancellable,
++ NULL);
++ if (enumerator == NULL)
+ {
+ return;
+ }
+
+- if (del_children)
++ /* The g_file_delete operation works differently for locations provided
++ * by the trash backend as it prevents modifications of trashed items
++ * For that reason, it is enough to call g_file_delete on top-level
++ * items only.
++ */
++ while (!job_aborted (job) &&
++ (info = g_file_enumerator_next_file (enumerator, job->cancellable, NULL)) != NULL)
+ {
+- gboolean should_recurse;
+-
+- /* The g_file_delete operation works differently for locations provided
+- * by the trash backend as it prevents modifications of trashed items
+- * For that reason, it is enough to call g_file_delete on top-level
+- * items only.
+- */
+- should_recurse = !g_file_has_uri_scheme (file, SCHEME_TRASH);
+-
+- enumerator = g_file_enumerate_children (file,
+- G_FILE_ATTRIBUTE_STANDARD_NAME ","
+- G_FILE_ATTRIBUTE_STANDARD_TYPE,
+- G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+- job->cancellable,
+- NULL);
+- if (enumerator)
+- {
+- while (!job_aborted (job) &&
+- (info = g_file_enumerator_next_file (enumerator, job->cancellable, NULL)) != NULL)
+- {
+- gboolean is_dir;
++ g_autoptr (GFile) child = g_file_get_child (trash, g_file_info_get_name (info));
+
+- child = g_file_get_child (file,
+- g_file_info_get_name (info));
+- is_dir = (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY);
+-
+- delete_trash_file (job, child, TRUE, should_recurse && is_dir);
+- g_object_unref (child);
+- g_object_unref (info);
+- }
+- g_file_enumerator_close (enumerator, job->cancellable, NULL);
+- g_object_unref (enumerator);
+- }
++ g_file_delete (child, job->cancellable, NULL);
++ g_object_unref (info);
+ }
+
+- if (!job_aborted (job) && del_file)
+- {
+- g_file_delete (file, job->cancellable, NULL);
+- }
++ g_file_enumerator_close (enumerator, job->cancellable, NULL);
+ }
+
+ static void
+@@ -7447,7 +7422,6 @@ empty_trash_task_done (GObject *source_object,
+
+ job = user_data;
+
+- g_list_free_full (job->trash_dirs, g_object_unref);
+ g_free (job->mount_root_path);
+
+ if (job->done_callback)
+@@ -7467,22 +7441,18 @@ empty_trash_thread_func (GTask *task,
+ {
+ EmptyTrashJob *job = task_data;
+ CommonJob *common;
+- GList *l;
+- gboolean confirmed;
+
+ common = (CommonJob *) job;
+
+ nautilus_progress_info_start (job->common.progress);
+
+- if (job->should_confirm)
++ if (job->should_confirm &&
++ !confirm_empty_trash (common))
+ {
+- confirmed = confirm_empty_trash (common);
+- }
+- else
+- {
+- confirmed = TRUE;
++ return;
+ }
+- if (confirmed && job->mount_root_path != NULL)
++
++ if (job->mount_root_path != NULL)
+ {
+ g_autoptr (GArray) fds = open_trash_dirs_at_mount_root (job->mount_root_path);
+
+@@ -7498,14 +7468,9 @@ empty_trash_thread_func (GTask *task,
+ }
+ }
+ }
+- else if (confirmed)
++ else
+ {
+- for (l = job->trash_dirs;
+- l != NULL && !job_aborted (common);
+- l = l->next)
+- {
+- delete_trash_file (common, l->data, FALSE, TRUE);
+- }
++ delete_main_trash_contents (common);
+ }
+ }
+
+@@ -7525,8 +7490,6 @@ nautilus_file_operations_empty_trash (GtkWidget *parent_vie
+ }
+
+ job = op_job_new (EmptyTrashJob, parent_window, dbus_data);
+- job->trash_dirs = g_list_prepend (job->trash_dirs,
+- g_file_new_for_uri (SCHEME_TRASH ":"));
+ job->should_confirm = ask_confirmation;
+
+ inhibit_power_manager ((CommonJob *) job, _("Emptying Trash"));
+--
+2.56.0
+
diff --git a/nautilus.spec b/nautilus.spec
index 763bd22..c5b820d 100644
--- a/nautilus.spec
+++ b/nautilus.spec
@@ -20,6 +20,8 @@ Source0: https://download.gnome.org/sources/%{name}/%{gnome_major_version
# https://pagure.io/fedora-workstation/issue/442
Patch: default-terminal.patch
+Patch: CVE-2026-111802.patch
+
BuildRequires: desktop-file-utils
BuildRequires: gcc
BuildRequires: gettext
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-30 18:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-30 18:23 [rpms/nautilus] rawhide: Fix CVE-2026-111802 Adrian Vovk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox