[packages/lxc] Rel 3. Fix CVE-2026-100395 and GHSA-4xwm-pr6h-55r8

arekm arekm at pld-linux.org
Mon Nov 16 22:13:02 CET 2026


commit e007ba01514388addaef013ae4811da568e7595a
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Mon Nov 16 22:11:56 2026 +0100

    Rel 3. Fix CVE-2026-100395 and GHSA-4xwm-pr6h-55r8

 lxc-CVE-2026-100395.patch     | 163 ++++++++++++++++++++++++++++++++++++++++++
 lxc-GHSA-4xwm-pr6h-55r8.patch |  65 +++++++++++++++++
 lxc-oci-untrusted-image.patch | 120 +++++++++++++++++++++++++++++++
 lxc.spec                      |   9 ++-
 x32.patch                     |  15 ----
 5 files changed, 354 insertions(+), 18 deletions(-)
---
diff --git a/lxc.spec b/lxc.spec
index f8d740b..19f62cc 100644
--- a/lxc.spec
+++ b/lxc.spec
@@ -16,7 +16,7 @@ Summary:	Linux Containers userspace tools
 Summary(pl.UTF-8):	Narzędzia do kontenerów linuksowych (LXC)
 Name:		lxc
 Version:	7.0.0
-Release:	2
+Release:	3
 License:	LGPL v2.1+
 Group:		Applications/System
 Source0:	https://linuxcontainers.org/downloads/lxc/%{name}-%{version}.tar.gz
@@ -27,7 +27,9 @@ Source2:	%{name}_macvlan.sysconfig
 Source3:	%{name}_macvlan
 Patch0:		%{name}-pld.patch
 Patch1:		%{name}-net.patch
-Patch2:		x32.patch
+Patch2:		%{name}-CVE-2026-100395.patch
+Patch3:		%{name}-GHSA-4xwm-pr6h-55r8.patch
+Patch4:		%{name}-oci-untrusted-image.patch
 URL:		https://www.linuxcontainers.org/
 BuildRequires:	dbus-devel
 BuildRequires:	docbook-dtd45-xml
@@ -50,7 +52,6 @@ BuildRequires:	pkgconfig
 BuildRequires:	rpm-build >= 4.6
 BuildRequires:	rpmbuild(macros) >= 2.042
 BuildRequires:	sed >= 4.0
-Requires(post):	/sbin/ldconfig
 Requires(post,preun):	/sbin/chkconfig
 Requires:	%{name}-libs = %{version}-%{release}
 # lxc_macvlan script
@@ -181,6 +182,8 @@ bashowe uzupełnianie nazw dla LXC.
 %patch -P0 -p1
 %patch -P1 -p1
 %patch -P2 -p1
+%patch -P3 -p1
+%patch -P4 -p1
 
 cp -p %{SOURCE1} templates/lxc-pld.in
 
diff --git a/lxc-CVE-2026-100395.patch b/lxc-CVE-2026-100395.patch
new file mode 100644
index 0000000..c319b57
--- /dev/null
+++ b/lxc-CVE-2026-100395.patch
@@ -0,0 +1,163 @@
+CVE-2026-100395: lxc-copy/clone() followed a symlinked etc/hostname out of the new rootfs
+https://github.com/lxc/lxc/security/advisories/GHSA-r23j-58gg-pjjc
+upstream 6424a91a55efc54edc25ca46e9165bd9f35b50b7 + fa12709a79c2b63b3918297d7505108fcc840eb6
+
+From 6424a91a55efc54edc25ca46e9165bd9f35b50b7 Mon Sep 17 00:00:00 2001
+From: Serge Hallyn <serge at hallyn.com>
+Date: Tue, 14 Jul 2026 11:50:39 -0500
+Subject: [PATCH] lxc-copy: open hostname in a safer way
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+lxc-copy without -K updates the hostname in the container.  It does
+this by opening /etc/hostname in the container and writing the new
+hostname to it.  If /etc/hostname is a symbolic link, we can end up
+ovewriting a host path.
+
+lxc-copy is not setuid-root, so unprivileged users can't exploit this
+without help.  More likely would be unprivileged users shooting
+themselves in the foot and accidentally changing the hostname of the
+original container.
+
+Fix it by using openat2(RESOLVE_IN_ROOT) to make sure that if
+/etc or /etc/hostname is a symlink, it is resolved inside the
+container's fs.
+
+Signed-off-by: Serge Hallyn <serge at hallyn.com>
+Reported-by: 怀硕 <shuohuai at mail.nankai.edu.cn>
+---
+ src/lxc/lxccontainer.c | 76 ++++++++++++++++++++++++++----------------
+ 1 file changed, 47 insertions(+), 29 deletions(-)
+
+diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
+index ba3d988b5b..736df037ac 100644
+--- a/src/lxc/lxccontainer.c
++++ b/src/lxc/lxccontainer.c
+@@ -3584,6 +3584,52 @@ struct clone_update_data {
+ 	char **hookargs;
+ };
+ 
++static int do_update_hostname(struct lxc_container *c, int flags)
++{
++	char *path;
++	__do_close int dir = -EBADF;
++	__do_close int hfd = -EBADF;
++	__do_fclose FILE *fout = NULL;
++	struct open_how how = {
++		.flags = O_RDWR,
++		.resolve = RESOLVE_IN_ROOT
++	};
++
++	path = c->lxc_conf->rootfs.storage->dest;
++	if (!file_exists(path))
++		return 0;
++
++	dir = open(path, O_RDONLY | O_DIRECTORY | O_PATH | O_CLOEXEC);
++	if (dir < 0)
++		return 0;
++
++	hfd = openat2(dir, "/etc/hostname", &how, sizeof(how));
++	if (hfd < 0)
++		return 0;
++
++	fout = fdopen(hfd, "w");
++	if (!fout)
++		return 0;
++	hfd = -EBADF; // fclose(fout) will close hfd
++
++	if (fprintf(fout, "%s", c->name) < 0)
++		return -1;
++
++	return 0;
++}
++
++static int maybe_update_hostname(struct lxc_container *c, int flags)
++{
++	int ret = 0;
++	struct lxc_conf *conf = c->lxc_conf;
++
++	if (!(flags & LXC_CLONE_KEEPNAME))
++		ret = do_update_hostname(c, flags);
++
++	lxc_storage_put(conf);
++	return ret;
++}
++
+ static int clone_update_rootfs(struct clone_update_data *data)
+ {
+ 	struct lxc_container *c0 = data->c0;
+@@ -3591,9 +3637,7 @@ static int clone_update_rootfs(struct clone_update_data *data)
+ 	int flags = data->flags;
+ 	char **hookargs = data->hookargs;
+ 	int ret = -1;
+-	char path[PATH_MAX];
+ 	struct lxc_storage *bdev;
+-	FILE *fout;
+ 	struct lxc_conf *conf = c->lxc_conf;
+ 
+ 	/* update hostname in rootfs */
+@@ -3662,33 +3706,7 @@ static int clone_update_rootfs(struct clone_update_data *data)
+ 		}
+ 	}
+ 
+-	if (!(flags & LXC_CLONE_KEEPNAME)) {
+-		ret = strnprintf(path, sizeof(path), "%s/etc/hostname", bdev->dest);
+-		lxc_storage_put(conf);
+-
+-		if (ret < 0)
+-			return -1;
+-
+-		if (!file_exists(path))
+-			return 0;
+-
+-		if (!(fout = fopen(path, "we"))) {
+-			SYSERROR("unable to open %s: ignoring", path);
+-			return 0;
+-		}
+-
+-		if (fprintf(fout, "%s", c->name) < 0) {
+-			fclose(fout);
+-			return -1;
+-		}
+-
+-		if (fclose(fout) < 0)
+-			return -1;
+-	} else {
+-		lxc_storage_put(conf);
+-	}
+-
+-	return 0;
++	return maybe_update_hostname(c, flags);
+ }
+ 
+ static int clone_update_rootfs_wrapper(void *data)
+From fa12709a79c2b63b3918297d7505108fcc840eb6 Mon Sep 17 00:00:00 2001
+From: Shuo Huai <shuohuai at mail.nankai.edu.cn>
+Date: Tue, 28 Jul 2026 17:22:28 +0800
+Subject: [PATCH] lxc-copy: fix hostname truncation during clone
+
+The hostname update code switched from fopen() to openat2()
+and fdopen(), but fdopen() does not truncate an existing file.
+
+Add O_TRUNC to preserve the previous fopen() behavior and avoid
+leaving stale bytes after updating the hostname.
+
+Signed-off-by: Shuo Huai <shuohuai at mail.nankai.edu.cn>
+---
+ src/lxc/lxccontainer.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
+index 736df037ac..c820f59090 100644
+--- a/src/lxc/lxccontainer.c
++++ b/src/lxc/lxccontainer.c
+@@ -3591,7 +3591,7 @@ static int do_update_hostname(struct lxc_container *c, int flags)
+ 	__do_close int hfd = -EBADF;
+ 	__do_fclose FILE *fout = NULL;
+ 	struct open_how how = {
+-		.flags = O_RDWR,
++		.flags = O_RDWR | O_TRUNC,
+ 		.resolve = RESOLVE_IN_ROOT
+ 	};
+ 
diff --git a/lxc-GHSA-4xwm-pr6h-55r8.patch b/lxc-GHSA-4xwm-pr6h-55r8.patch
new file mode 100644
index 0000000..2d48428
--- /dev/null
+++ b/lxc-GHSA-4xwm-pr6h-55r8.patch
@@ -0,0 +1,65 @@
+GHSA-4xwm-pr6h-55r8: command socket handlers dereferenced a client-supplied pointer
+https://github.com/lxc/lxc/security/advisories/GHSA-4xwm-pr6h-55r8
+upstream 06f626091cb9f1d717cb9d63b7bc2ffdbf0c3cdf + 19ad80ed8e6288904caaee5b7bd3c485d51a2291
+
+From 06f626091cb9f1d717cb9d63b7bc2ffdbf0c3cdf Mon Sep 17 00:00:00 2001
+From: Kartik Kenchi <netliomax25 at gmail.com>
+Date: Tue, 9 Jun 2026 12:14:46 +0530
+Subject: [PATCH] commands: validate string in lxc_cmd_get_config_item_callback
+
+Signed-off-by: Kartik Kenchi <netliomax25 at gmail.com>
+---
+ src/lxc/commands.c | 11 +++++++++++
+ 1 file changed, 11 insertions(+)
+
+diff --git a/src/lxc/commands.c b/src/lxc/commands.c
+index 8c6460cdcc..1454d0ebaa 100644
+--- a/src/lxc/commands.c
++++ b/src/lxc/commands.c
+@@ -1028,8 +1028,19 @@ static int lxc_cmd_get_config_item_callback(int fd, struct lxc_cmd_req *req,
+ 	int cilen;
+ 	struct lxc_config_t *item;
+ 	struct lxc_cmd_rsp rsp;
++	ssize_t ret;
+ 
+ 	memset(&rsp, 0, sizeof(rsp));
++
++	if (req->datalen <= 0) {
++		rsp.ret = -EINVAL;
++		return lxc_cmd_rsp_send_reap(fd, &rsp);
++	}
++
++	ret = validate_string_request(fd, req);
++	if (ret != 0)
++		return ret;
++
+ 	item = lxc_get_config(req->data);
+ 	cilen = item->get(req->data, NULL, 0, handler->conf, NULL);
+ 	if (cilen <= 0)
+From 19ad80ed8e6288904caaee5b7bd3c485d51a2291 Mon Sep 17 00:00:00 2001
+From: Kartik Kenchi <netliomax25 at gmail.com>
+Date: Thu, 20 Aug 2026 13:03:50 +0530
+Subject: [PATCH] commands: validate datalen in lxc_cmd_console_log_callback
+
+Signed-off-by: Kartik Kenchi <netliomax25 at gmail.com>
+---
+ src/lxc/commands.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/src/lxc/commands.c b/src/lxc/commands.c
+index 8c6460cdcc..3a8353bf2a 100644
+--- a/src/lxc/commands.c
++++ b/src/lxc/commands.c
+@@ -1554,6 +1554,12 @@ static int lxc_cmd_console_log_callback(int fd, struct lxc_cmd_req *req,
+ 	rsp.ret = -EFAULT;
+ 	rsp.datalen = 0;
+ 	rsp.data = NULL;
++
++	if (req->datalen != sizeof(struct lxc_cmd_console_log) || !req->data) {
++		rsp.ret = -EINVAL;
++		goto out;
++	}
++
+ 	if (buffer_size <= 0)
+ 		goto out;
+ 
diff --git a/lxc-oci-untrusted-image.patch b/lxc-oci-untrusted-image.patch
new file mode 100644
index 0000000..c7b5d5a
--- /dev/null
+++ b/lxc-oci-untrusted-image.patch
@@ -0,0 +1,120 @@
+lxc-oci: image config could inject LXC config lines (newlines) and symlinked /etc
+made the template overwrite host files
+upstream 56f03b1a3f6e5fbc9e27f958d78942e481113e88 + e637761f198319feadb780673fe07772ccadb254 (PR #4748)
+
+From 56f03b1a3f6e5fbc9e27f958d78942e481113e88 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at stgraber.org>
+Date: Thu, 5 Nov 2026 12:59:38 -0500
+Subject: [PATCH] oci: reject newlines in values written to config
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Signed-off-by: Stéphane Graber <stgraber at stgraber.org>
+Reported-by: FengZi <95153092+FengZi1221 at users.noreply.github.com>
+---
+ templates/lxc-oci.in | 16 ++++++++++++++++
+ 1 file changed, 16 insertions(+)
+
+diff --git a/templates/lxc-oci.in b/templates/lxc-oci.in
+index 4f41b7feed..2754466f30 100755
+--- a/templates/lxc-oci.in
++++ b/templates/lxc-oci.in
+@@ -156,6 +156,16 @@ getenv() {
+   return
+ }
+ 
++# reject image values that would start a new line in the LXC config.
++checkconfigvalue() {
++  case "$2" in
++    *$'\n'*|*$'\r'*)
++      echo "ERROR: Invalid $1 in OCI image" 1>&2
++      exit 1
++      ;;
++  esac
++}
++
+ # check var is decimal.
+ isdecimal() {
+   var="$1"
+@@ -458,6 +468,7 @@ esac
+ environment=$(getenv "${OCI_CONF_FILE}")
+ # shellcheck disable=SC2039
+ while read -r line; do
++  checkconfigvalue "environment" "${line}"
+   echo "lxc.environment = ${line}" >> "${LXC_CONF_FILE}"
+ done <<< "${environment}"
+ 
+@@ -498,11 +509,16 @@ EOF
+ # shellcheck disable=SC2039
+ uidgid=($(getuidgid "${OCI_CONF_FILE}" "${LXC_ROOTFS}" ))
+ # shellcheck disable=SC2039
++checkconfigvalue "user" "${uidgid[0]}"
++# shellcheck disable=SC2039
++checkconfigvalue "group" "${uidgid[1]}"
++# shellcheck disable=SC2039
+ echo "lxc.init.uid = ${uidgid[0]}" >> "${LXC_CONF_FILE}"
+ # shellcheck disable=SC2039
+ echo "lxc.init.gid = ${uidgid[1]}" >> "${LXC_CONF_FILE}"
+ 
+ cwd=$(getcwd "${OCI_CONF_FILE}")
++checkconfigvalue "working directory" "${cwd}"
+ echo "lxc.init.cwd = ${cwd}" >> "${LXC_CONF_FILE}"
+ 
+ if [ -n "$LXC_MAPPED_UID" ] && [ "$LXC_MAPPED_UID" != "-1" ]; then
+From e637761f198319feadb780673fe07772ccadb254 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at stgraber.org>
+Date: Thu, 5 Nov 2026 13:02:28 -0500
+Subject: [PATCH] oci: don't follow image links when writing to /etc
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Signed-off-by: Stéphane Graber <stgraber at stgraber.org>
+---
+ templates/lxc-oci.in | 21 +++++++++++++++++++--
+ 1 file changed, 19 insertions(+), 2 deletions(-)
+
+diff --git a/templates/lxc-oci.in b/templates/lxc-oci.in
+index 2754466f30..97f9e0b9d8 100755
+--- a/templates/lxc-oci.in
++++ b/templates/lxc-oci.in
+@@ -166,6 +166,23 @@ checkconfigvalue() {
+   esac
+ }
+ 
++# write stdin to a file in the rootfs' /etc, replacing whatever the image put there.
++writeetcfile() {
++  local etc root
++  etc=$(realpath -e "${LXC_ROOTFS}/etc")
++  root=$(realpath -e "${LXC_ROOTFS}")
++  case "${etc}/" in
++    "${root}"/*) ;;
++    *)
++      echo "ERROR: /etc in OCI image points outside of the rootfs" 1>&2
++      exit 1
++      ;;
++  esac
++
++  rm -f "${etc}/$1"
++  cat > "${etc}/$1"
++}
++
+ # check var is decimal.
+ isdecimal() {
+   var="$1"
+@@ -491,12 +508,12 @@ fi
+ 
+ echo "lxc.uts.name = ${LXC_NAME}" >> "${LXC_CONF_FILE}"
+ # set the hostname
+-cat <<EOF > "${LXC_ROOTFS}/etc/hostname"
++writeetcfile hostname <<EOF
+ ${LXC_NAME}
+ EOF
+ 
+ # set minimal hosts
+-cat <<EOF > "${LXC_ROOTFS}/etc/hosts"
++writeetcfile hosts <<EOF
+ 127.0.0.1   localhost
+ 127.0.1.1   ${LXC_NAME}
+ ::1     localhost ip6-localhost ip6-loopback
diff --git a/x32.patch b/x32.patch
deleted file mode 100644
index 9113480..0000000
--- a/x32.patch
+++ /dev/null
@@ -1,15 +0,0 @@
-diff -ruNp lxc-4.0.7.orig/src/lxc/log.c lxc-4.0.7/src/lxc/log.c
---- lxc-4.0.7.orig/src/lxc/log.c	2021-04-29 22:57:15.000000000 +0200
-+++ lxc-4.0.7/src/lxc/log.c	2021-04-30 17:29:22.505346892 +0200
-@@ -280,7 +280,11 @@ static int lxc_unix_epoch_to_utc(char *b
- 	seconds = (time->tv_sec - d_in_s - h_in_s - (minutes * 60));
- 
- 	/* Make string from nanoseconds. */
-+        #ifdef __ILP32__
-+        ret = snprintf(nanosec, sizeof(nanosec), "%lld", (int64_t)time->tv_nsec);
-+        #else
- 	ret = strnprintf(nanosec, sizeof(nanosec), "%"PRId64, (int64_t)time->tv_nsec);
-+	#endif
- 	if (ret < 0)
- 		return ret_errno(EIO);
- 
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/lxc.git/commitdiff/e007ba01514388addaef013ae4811da568e7595a



More information about the pld-cvs-commit mailing list