From e9207e35f728a7f4c369e4e8034ebbb38e80f87b Mon Sep 17 00:00:00 2001 From: wujing Date: Tue, 21 Jul 2020 17:37:41 +0800 Subject: [PATCH] solve coredump bug caused by fstype being NULL during mount Signed-off-by: wujing --- 0001-huawei-adapt-to-huawei-4.0.3.patch | 2 +- 0002-add-mount-label-for-rootfs.patch | 2 +- 0003-format-code-and-verify-mount-mode.patch | 2 +- ...nition-of-the-thread-attributes-obje.patch | 2 +- ...ug-caused-by-fstype-being-NULL-durin.patch | 65 +++++++++++++++++++ lxc.spec | 1 + series.conf | 1 + 7 files changed, 71 insertions(+), 4 deletions(-) create mode 100644 0005-solve-coredump-bug-caused-by-fstype-being-NULL-durin.patch diff --git a/0001-huawei-adapt-to-huawei-4.0.3.patch b/0001-huawei-adapt-to-huawei-4.0.3.patch index 1025af2..1e3f687 100644 --- a/0001-huawei-adapt-to-huawei-4.0.3.patch +++ b/0001-huawei-adapt-to-huawei-4.0.3.patch @@ -1,7 +1,7 @@ From 8a62b519510080bb361cdd058d0e7a5edd955a95 Mon Sep 17 00:00:00 2001 From: lifeng68 Date: Wed, 15 Jul 2020 09:32:32 +0800 -Subject: [PATCH 1/4] huawei: adapt to huawei 4.0.3 +Subject: [PATCH 1/5] huawei: adapt to huawei 4.0.3 Signed-off-by: lifeng68 --- diff --git a/0002-add-mount-label-for-rootfs.patch b/0002-add-mount-label-for-rootfs.patch index 5753b78..f856f52 100644 --- a/0002-add-mount-label-for-rootfs.patch +++ b/0002-add-mount-label-for-rootfs.patch @@ -1,7 +1,7 @@ From 0b8bc902c0c7acb54efb1fd4be5121dbf9a08598 Mon Sep 17 00:00:00 2001 From: wujing Date: Wed, 15 Jul 2020 16:09:35 +0800 -Subject: [PATCH 2/4] add mount label for rootfs +Subject: [PATCH 2/5] add mount label for rootfs Signed-off-by: wujing --- diff --git a/0003-format-code-and-verify-mount-mode.patch b/0003-format-code-and-verify-mount-mode.patch index e79931a..8a3198a 100644 --- a/0003-format-code-and-verify-mount-mode.patch +++ b/0003-format-code-and-verify-mount-mode.patch @@ -1,7 +1,7 @@ From c0f37e083c49cfcb9441743a409fdee44d32d7c5 Mon Sep 17 00:00:00 2001 From: wujing Date: Thu, 16 Jul 2020 16:39:35 +0800 -Subject: [PATCH 3/4] format code and verify mount mode +Subject: [PATCH 3/5] format code and verify mount mode Signed-off-by: wujing --- diff --git a/0004-Removes-the-definition-of-the-thread-attributes-obje.patch b/0004-Removes-the-definition-of-the-thread-attributes-obje.patch index f3466da..f154ab3 100644 --- a/0004-Removes-the-definition-of-the-thread-attributes-obje.patch +++ b/0004-Removes-the-definition-of-the-thread-attributes-obje.patch @@ -1,7 +1,7 @@ From b1ef723b4f437aad3c0c0497174bc7d3444426cd Mon Sep 17 00:00:00 2001 From: wujing Date: Mon, 20 Jul 2020 15:30:42 +0800 -Subject: [PATCH 4/4] Removes the definition of the thread attributes object +Subject: [PATCH 4/5] Removes the definition of the thread attributes object Signed-off-by: wujing --- diff --git a/0005-solve-coredump-bug-caused-by-fstype-being-NULL-durin.patch b/0005-solve-coredump-bug-caused-by-fstype-being-NULL-durin.patch new file mode 100644 index 0000000..1d2ca8d --- /dev/null +++ b/0005-solve-coredump-bug-caused-by-fstype-being-NULL-durin.patch @@ -0,0 +1,65 @@ +From 405b048dc82a8695b8a400524787243f3898cbd6 Mon Sep 17 00:00:00 2001 +From: wujing +Date: Tue, 21 Jul 2020 17:30:17 +0800 +Subject: [PATCH 5/5] solve coredump bug caused by fstype being NULL during + mount + +Signed-off-by: wujing +--- + src/lxc/lsm/selinux.c | 3 +-- + src/lxc/utils.c | 7 ++++--- + 2 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/src/lxc/lsm/selinux.c b/src/lxc/lsm/selinux.c +index ceac0889..837a3da3 100644 +--- a/src/lxc/lsm/selinux.c ++++ b/src/lxc/lsm/selinux.c +@@ -68,7 +68,6 @@ static int selinux_process_label_set(const char *inlabel, struct lxc_conf *conf, + + label = inlabel ? inlabel : conf->lsm_se_context; + if (!label) { +- + label = DEFAULT_LABEL; + } + +@@ -273,7 +272,7 @@ static int selinux_relabel(const char *path, const char *label, bool shared) + { + __do_free char *tmp_file_label = NULL; + +- if (label == NULL) { ++ if (path == NULL || label == NULL) { + return 0; + } + +diff --git a/src/lxc/utils.c b/src/lxc/utils.c +index 5ec6117f..95c00cfe 100644 +--- a/src/lxc/utils.c ++++ b/src/lxc/utils.c +@@ -1230,7 +1230,7 @@ int safe_mount(const char *src, const char *dest, const char *fstype, + + ret = mount(mntsrc, destbuf, fstype, flags, mnt_opts); + saved_errno = errno; +- if (ret < 0 && strcmp(fstype, "mqueue") == 0) { ++ if (ret < 0 && fstype != NULL && strcmp(fstype, "mqueue") == 0) { + INFO("older kernels don't support labeling of /dev/mqueue, retry without selinux context"); + ret = mount(mntsrc, destbuf, fstype, flags, data); + saved_errno = errno; +@@ -1250,12 +1250,13 @@ int safe_mount(const char *src, const char *dest, const char *fstype, + } + + #ifdef HAVE_ISULAD +- if (strcmp(fstype, "mqueue") == 0 && lsm_file_label_set(dest, mount_label) != 0) { ++ if (fstype != NULL && strcmp(fstype, "mqueue") == 0 && lsm_file_label_set(dest, mount_label) != 0) { + ERROR("Failed to set file label on %s", dest); + return -EINVAL; + } + +- if (strcmp(fstype, "bind") == 0 && relabel_bind_mount_source(src, fstype, (const char *)data, mount_label) != 0) { ++ if (fstype != NULL && strcmp(fstype, "bind") == 0 && ++ relabel_bind_mount_source(src, fstype, (const char *)data, mount_label) != 0) { + ERROR("Failed to reabel %s with %s", src, mount_label); + return -EINVAL; + } +-- +2.25.1 + diff --git a/lxc.spec b/lxc.spec index ba1f75d..201a6a1 100644 --- a/lxc.spec +++ b/lxc.spec @@ -12,6 +12,7 @@ Patch9001: 0001-huawei-adapt-to-huawei-4.0.3.patch Patch9002: 0002-add-mount-label-for-rootfs.patch Patch9003: 0003-format-code-and-verify-mount-mode.patch Patch9004: 0004-Removes-the-definition-of-the-thread-attributes-obje.patch +Patch9005: 0005-solve-coredump-bug-caused-by-fstype-being-NULL-durin.patch BuildRequires: systemd-units git libtool graphviz docbook2X doxygen chrpath BuildRequires: pkgconfig(libseccomp) diff --git a/series.conf b/series.conf index f7a1e97..ecf77e2 100644 --- a/series.conf +++ b/series.conf @@ -2,3 +2,4 @@ 0002-add-mount-label-for-rootfs.patch 0003-format-code-and-verify-mount-mode.patch 0004-Removes-the-definition-of-the-thread-attributes-obje.patch +0005-solve-coredump-bug-caused-by-fstype-being-NULL-durin.patch -- Gitee