From 72922783bb0057c3929bdad9caa73f2638d6937c Mon Sep 17 00:00:00 2001 From: Eduardo Ferreira Date: Fri, 22 Nov 2024 10:26:28 -0300 Subject: [PATCH 1/2] ostree: removing unnecessary composefs patches These composefs patches were in this recipe when composefs was a submodule of ostree. Now that we build it separately, and the changes were merged upstream, we can safely remove those. Signed-off-by: Eduardo Ferreira --- ...ding-when-macro-MOUNT_ATTR_IDMAP-is-.patch | 64 ------------------- ...ding-when-macro-LOOP_CONFIGURE-is-no.patch | 47 -------------- recipes-extended/ostree/ostree_%.bbappend | 2 - 3 files changed, 113 deletions(-) delete mode 100644 recipes-extended/ostree/files/0001-mount-Allow-building-when-macro-MOUNT_ATTR_IDMAP-is-.patch delete mode 100644 recipes-extended/ostree/files/0002-mount-Allow-building-when-macro-LOOP_CONFIGURE-is-no.patch diff --git a/recipes-extended/ostree/files/0001-mount-Allow-building-when-macro-MOUNT_ATTR_IDMAP-is-.patch b/recipes-extended/ostree/files/0001-mount-Allow-building-when-macro-MOUNT_ATTR_IDMAP-is-.patch deleted file mode 100644 index c1e3b5a9..00000000 --- a/recipes-extended/ostree/files/0001-mount-Allow-building-when-macro-MOUNT_ATTR_IDMAP-is-.patch +++ /dev/null @@ -1,64 +0,0 @@ -From c5241e94030f774df5f410e07c4de894d41e64e2 Mon Sep 17 00:00:00 2001 -From: Rogerio Guerra Borin -Date: Tue, 6 Feb 2024 23:14:20 -0300 -Subject: [PATCH 1/2] mount: Allow building when macro MOUNT_ATTR_IDMAP is not - available - -This is to allow building the software on machines not having the -MOUNT_ATTR_IDMAP macro in header "linux/mount.h". When that macro is not -available, the dependency on struct mount_attr is also eliminated (which -is good since both the macro and the struct were added to the kernel -uapi virtually at the same time). - -With the changes in this commit, errors would be thrown at runtime when -mounting the erofs image, but only if the idmap feature is used; this -resembles the behavior when the "new mount API" is not detected. - -Upstream-Status: Accepted [https://github.com/containers/composefs/pull/253] - -Signed-off-by: Rogerio Guerra Borin ---- - libcomposefs/lcfs-mount.c | 6 ++++++ - 2 files changed, 17 insertions(+) - -diff --git a/composefs/libcomposefs/lcfs-mount.c b/composefs/libcomposefs/lcfs-mount.c -index 0a4b08f..5285833 100644 ---- a/composefs/libcomposefs/lcfs-mount.c -+++ b/composefs/libcomposefs/lcfs-mount.c -@@ -108,6 +108,7 @@ static int syscall_move_mount(int from_dfd, const char *from_pathname, int to_df - #endif - } - -+#ifdef HAVE_MOUNT_ATTR_IDMAP - static int syscall_mount_setattr(int dfd, const char *path, unsigned int flags, - struct mount_attr *attr, size_t usize) - { -@@ -122,6 +123,7 @@ static int syscall_mount_setattr(int dfd, const char *path, unsigned int flags, - return -1; - #endif - } -+#endif - - #define MAX_DIGEST_SIZE 64 - -@@ -381,6 +383,7 @@ static int lcfs_mount_erofs(const char *source, const char *target, - return -errno; - - if (use_idmap) { -+#ifdef HAVE_MOUNT_ATTR_IDMAP - struct mount_attr attr = { - .attr_set = MOUNT_ATTR_IDMAP, - .userns_fd = state->options->idmap_fd, -@@ -390,6 +393,9 @@ static int lcfs_mount_erofs(const char *source, const char *target, - sizeof(struct mount_attr)); - if (res < 0) - return -errno; -+#else -+ return -ENOTSUP; -+#endif - } - - res = syscall_move_mount(fd_mnt, "", AT_FDCWD, target, --- -2.25.1 - diff --git a/recipes-extended/ostree/files/0002-mount-Allow-building-when-macro-LOOP_CONFIGURE-is-no.patch b/recipes-extended/ostree/files/0002-mount-Allow-building-when-macro-LOOP_CONFIGURE-is-no.patch deleted file mode 100644 index 62a6483f..00000000 --- a/recipes-extended/ostree/files/0002-mount-Allow-building-when-macro-LOOP_CONFIGURE-is-no.patch +++ /dev/null @@ -1,47 +0,0 @@ -From ebb4e195b94074cb66d031d1f449d55cba86a182 Mon Sep 17 00:00:00 2001 -From: Rogerio Guerra Borin -Date: Tue, 6 Feb 2024 23:36:15 -0300 -Subject: [PATCH 2/2] mount: Allow building when macro LOOP_CONFIGURE is not - available - -This is to allow building the software on machines not having the macro -LOOP_CONFIGURE or the struct loop_config in header "linux/loop.h" (both -of which added to the kernel uapi at the same time); the code snippet -providing them was taken from package util-linux, source file -"include/loopdev.h". - -Upstream-Status: Accepted [https://github.com/containers/composefs/pull/253] - -Signed-off-by: Rogerio Guerra Borin ---- - libcomposefs/lcfs-mount.c | 14 ++++++++++++++ - 1 file changed, 14 insertions(+) - -diff --git a/composefs/libcomposefs/lcfs-mount.c b/composefs/libcomposefs/lcfs-mount.c -index 5285833..8acc7b9 100644 ---- a/composefs/libcomposefs/lcfs-mount.c -+++ b/composefs/libcomposefs/lcfs-mount.c -@@ -49,6 +49,20 @@ - #include "lcfs-utils.h" - #include "lcfs-internal.h" - -+#ifndef LOOP_CONFIGURE -+/* Snippet from util-linux/include/loopdev.h */ -+/* -+ * Since Linux v5.8-rc1 (commit 3448914e8cc550ba792d4ccc74471d1ca4293aae) -+ */ -+#define LOOP_CONFIGURE 0x4C0A -+struct loop_config { -+ uint32_t fd; -+ uint32_t block_size; -+ struct loop_info64 info; -+ uint64_t __reserved[8]; -+}; -+#endif -+ - static int syscall_fsopen(const char *fs_name, unsigned int flags) - { - #if defined __NR_fsopen --- -2.25.1 - diff --git a/recipes-extended/ostree/ostree_%.bbappend b/recipes-extended/ostree/ostree_%.bbappend index 56771321..909f5b3c 100644 --- a/recipes-extended/ostree/ostree_%.bbappend +++ b/recipes-extended/ostree/ostree_%.bbappend @@ -6,8 +6,6 @@ SRC_URI:append = " \ file://0001-update-default-grub-cfg-header.patch \ file://0002-Add-support-for-the-fdtfile-variable-in-uEnv.txt.patch \ file://0003-ostree-fetcher-curl-set-max-parallel-connections.patch \ - file://0001-mount-Allow-building-when-macro-MOUNT_ATTR_IDMAP-is-.patch \ - file://0002-mount-Allow-building-when-macro-LOOP_CONFIGURE-is-no.patch \ file://ostree-pending-reboot.service \ file://ostree-pending-reboot.path \ " From 8e61a33529615f6b74e34dea1bc482ced919560c Mon Sep 17 00:00:00 2001 From: Eduardo Ferreira Date: Thu, 21 Nov 2024 13:16:06 -0300 Subject: [PATCH 2/2] ostree: backport Curl patch An issue was found during some automated tests, and it was related to OSTree. Looking upstream, there was already an issue opened about this [2], and a fix was recently published [1]. Since this is only available on v2024.9 and were some version behind, we backported this patch. Related-to: TOR-3649 [1] https://github.com/ostreedev/ostree/pull/3307/commits/4d755a85225ea0a02d4580d088bb8a97138cb040 [2] https://github.com/ostreedev/ostree/issues/3299 Signed-off-by: Eduardo Ferreira --- ...t-callback-during-cleanup-into-no-op.patch | 62 +++++++++++++++++++ recipes-extended/ostree/ostree_%.bbappend | 1 + 2 files changed, 63 insertions(+) create mode 100644 recipes-extended/ostree/files/0004-curl-Make-socket-callback-during-cleanup-into-no-op.patch diff --git a/recipes-extended/ostree/files/0004-curl-Make-socket-callback-during-cleanup-into-no-op.patch b/recipes-extended/ostree/files/0004-curl-Make-socket-callback-during-cleanup-into-no-op.patch new file mode 100644 index 00000000..e1073bd0 --- /dev/null +++ b/recipes-extended/ostree/files/0004-curl-Make-socket-callback-during-cleanup-into-no-op.patch @@ -0,0 +1,62 @@ +From 4d755a85225ea0a02d4580d088bb8a97138cb040 Mon Sep 17 00:00:00 2001 +From: Colin Walters +Date: Wed, 18 Sep 2024 13:41:59 -0400 +Subject: [PATCH] curl: Make socket callback during cleanup into no-op + +Because curl_multi_cleanup may invoke callbacks, we effectively have +some circular references going on here. See discussion in + +https://github.com/curl/curl/issues/14860 + +Basically what we do is the socket callback libcurl may invoke into a no-op when +we detect we're finalizing. The data structures are owned by this object and +not by the callbacks, and will be destroyed below. Note that +e.g. g_hash_table_unref() may itself invoke callbacks, which is where +some data is cleaned up. + +Upstream-Status: Backport [https://github.com/ostreedev/ostree/pull/3307/commits/4d755a85225ea0a02d4580d088bb8a97138cb040] + +Signed-off-by: Colin Walters +--- + src/libostree/ostree-fetcher-curl.c | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +diff --git a/src/libostree/ostree-fetcher-curl.c b/src/libostree/ostree-fetcher-curl.c +index d6902893ff..8054812f57 100644 +--- a/src/libostree/ostree-fetcher-curl.c ++++ b/src/libostree/ostree-fetcher-curl.c +@@ -78,6 +78,7 @@ struct OstreeFetcher + struct curl_slist *extra_headers; + int tmpdir_dfd; + bool force_anonymous; ++ bool finalizing; // Set if we're in the process of teardown + char *custom_user_agent; + guint32 opt_low_speed_limit; + guint32 opt_low_speed_time; +@@ -180,6 +181,15 @@ _ostree_fetcher_finalize (GObject *object) + { + OstreeFetcher *self = OSTREE_FETCHER (object); + ++ // Because curl_multi_cleanup may invoke callbacks, we effectively have ++ // some circular references going on here. See discussion in ++ // https://github.com/curl/curl/issues/14860 ++ // Basically what we do is make most callbacks libcurl may invoke into no-ops when ++ // we detect we're finalizing. The data structures are owned by this object and ++ // not by the callbacks, and will be destroyed below. Note that ++ // e.g. g_hash_table_unref() may itself invoke callbacks, which is where ++ // some data is cleaned up. ++ self->finalizing = true; + curl_multi_cleanup (self->multi); + g_free (self->remote_name); + g_free (self->tls_ca_db_path); +@@ -528,6 +538,10 @@ sock_cb (CURL *easy, curl_socket_t s, int what, void *cbp, void *sockp) + OstreeFetcher *fetcher = cbp; + SockInfo *fdp = (SockInfo *)sockp; + ++ // We do nothing if we're in the process of teardown; see below. ++ if (fetcher->finalizing) ++ return 0; ++ + if (what == CURL_POLL_REMOVE) + { + if (!g_hash_table_remove (fetcher->sockets, fdp)) diff --git a/recipes-extended/ostree/ostree_%.bbappend b/recipes-extended/ostree/ostree_%.bbappend index 909f5b3c..0c6bc6ea 100644 --- a/recipes-extended/ostree/ostree_%.bbappend +++ b/recipes-extended/ostree/ostree_%.bbappend @@ -6,6 +6,7 @@ SRC_URI:append = " \ file://0001-update-default-grub-cfg-header.patch \ file://0002-Add-support-for-the-fdtfile-variable-in-uEnv.txt.patch \ file://0003-ostree-fetcher-curl-set-max-parallel-connections.patch \ + file://0004-curl-Make-socket-callback-during-cleanup-into-no-op.patch \ file://ostree-pending-reboot.service \ file://ostree-pending-reboot.path \ "