sync from upstream openeuler/iSulad

Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
This commit is contained in:
zhangxiaoyu 2022-06-21 19:15:20 +08:00
parent eea5b6db2c
commit 07838725fd
29 changed files with 2749 additions and 23 deletions

View File

@ -1,7 +1,7 @@
From 9837be14200fecb32db0337652e60532f1adb7be Mon Sep 17 00:00:00 2001
From: WangFengTu <wangfengtu@huawei.com>
Date: Mon, 23 May 2022 17:06:19 +0800
Subject: [PATCH 01/22] do not mkdir of isulad if no controller found
Subject: [PATCH 01/28] do not mkdir of isulad if no controller found
If selinux disable the capibility DAC_OVERRIDE,
mkdir isulad may fail when run container.

View File

@ -1,7 +1,7 @@
From 426a282802b8b81c66e6857857a745583f816c0a Mon Sep 17 00:00:00 2001
From: WangFengTu <wangfengtu@huawei.com>
Date: Tue, 24 May 2022 16:51:02 +0800
Subject: [PATCH 02/22] fix install error when android
Subject: [PATCH 02/28] fix install error when android
Signed-off-by: WangFengTu <wangfengtu@huawei.com>
---

View File

@ -1,7 +1,7 @@
From 9ccb30fa430c7b98ecab4406dabe8498c74db8c3 Mon Sep 17 00:00:00 2001
From: chegJH <hejunjie10@huawei.com>
Date: Thu, 12 May 2022 16:40:41 +0800
Subject: [PATCH 03/22] imp fuzz for pw gr parser
Subject: [PATCH 03/28] imp fuzz for pw gr parser
Signed-off-by: chegJH <hejunjie10@huawei.com>
---

View File

@ -1,7 +1,7 @@
From 31a92265a6bd29dc8f98179947406f1bb56ac5a8 Mon Sep 17 00:00:00 2001
From: haozi007 <liuhao27@huawei.com>
Date: Thu, 26 May 2022 13:53:09 +0100
Subject: [PATCH 04/22] improve fuzz test
Subject: [PATCH 04/28] improve fuzz test
Signed-off-by: haozi007 <liuhao27@huawei.com>
---

View File

@ -1,7 +1,7 @@
From 02167555e702316fe14cc963f9e978e9f66f59ba Mon Sep 17 00:00:00 2001
From: chengzrz <czrzrichard@gmail.com>
Date: Fri, 24 Dec 2021 10:47:31 +0800
Subject: [PATCH 05/22] Seccomp optimization
Subject: [PATCH 05/28] Seccomp optimization
Signed-off-by: chengzrz <czrzrichard@gmail.com>
---

View File

@ -1,7 +1,7 @@
From 1db2941da2eba089f3ed07c59f4925c857860023 Mon Sep 17 00:00:00 2001
From: haozi007 <liuhao27@huawei.com>
Date: Tue, 31 May 2022 03:33:16 +0100
Subject: [PATCH 06/22] fix different type convert
Subject: [PATCH 06/28] fix different type convert
Signed-off-by: haozi007 <liuhao27@huawei.com>
---

View File

@ -1,7 +1,7 @@
From 17b6015d5abe3500a5a89d171af79698e57545f2 Mon Sep 17 00:00:00 2001
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
Date: Tue, 31 May 2022 19:35:35 +0800
Subject: [PATCH 07/22] add pointer parameters NULL check
Subject: [PATCH 07/28] add pointer parameters NULL check
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
Signed-off-by: haozi007 <liuhao27@huawei.com>

View File

@ -1,7 +1,7 @@
From 56c2a6a98d51ea893939079cc31e3a7897fa5aba Mon Sep 17 00:00:00 2001
From: haozi007 <liuhao27@huawei.com>
Date: Tue, 31 May 2022 12:53:10 +0100
Subject: [PATCH 08/22] add check to arguments
Subject: [PATCH 08/28] add check to arguments
Signed-off-by: haozi007 <liuhao27@huawei.com>
---

View File

@ -1,7 +1,7 @@
From 9133e2159e9e69434b41e9649762f8eaed191f37 Mon Sep 17 00:00:00 2001
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
Date: Tue, 31 May 2022 22:39:44 +0800
Subject: [PATCH 09/22] remove static of strlncat
Subject: [PATCH 09/28] remove static of strlncat
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
---

View File

@ -1,7 +1,7 @@
From 60715b192de2cb1b4e8fe9ce48ddf081a6d2be53 Mon Sep 17 00:00:00 2001
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
Date: Wed, 1 Jun 2022 09:50:03 +0800
Subject: [PATCH 10/22] remove check parameter label_opts in init_label
Subject: [PATCH 10/28] remove check parameter label_opts in init_label
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
---

View File

@ -1,7 +1,7 @@
From 55a4f57232c42a9c2d36a41de5d743ee9ebbe88e Mon Sep 17 00:00:00 2001
From: vegbir <yangjiaqi16@huawei.com>
Date: Wed, 1 Jun 2022 13:44:37 +0800
Subject: [PATCH 11/22] update seccomp to Linux 5.10 syscall list
Subject: [PATCH 11/28] update seccomp to Linux 5.10 syscall list
Signed-off-by: yangjiaqi <yangjiaqi16@huawei.com>
---

View File

@ -1,7 +1,7 @@
From 8dcad172ea0241f35cdd464029523253ada7e99f Mon Sep 17 00:00:00 2001
From: haozi007 <liuhao27@huawei.com>
Date: Wed, 1 Jun 2022 12:53:56 +0100
Subject: [PATCH 12/22] fix invalid convert and format
Subject: [PATCH 12/28] fix invalid convert and format
1. invalid convert;
2. error print format;

View File

@ -1,7 +1,7 @@
From a96ad33008671e61bddebb744a7ac0aa3798313b Mon Sep 17 00:00:00 2001
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
Date: Thu, 2 Jun 2022 10:33:07 +0800
Subject: [PATCH 13/22] fix get_network_namespace_path check
Subject: [PATCH 13/28] fix get_network_namespace_path check
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
---

View File

@ -1,7 +1,7 @@
From 7934311c1b1003021449b92900f3102ff77395e2 Mon Sep 17 00:00:00 2001
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
Date: Tue, 7 Jun 2022 15:19:20 +0800
Subject: [PATCH 14/22] bugfix for double free and use after free
Subject: [PATCH 14/28] bugfix for double free and use after free
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
---

View File

@ -1,7 +1,7 @@
From 18db58c919bb9767bbe2f11c7447cfed27312c63 Mon Sep 17 00:00:00 2001
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
Date: Thu, 9 Jun 2022 21:16:26 +0800
Subject: [PATCH 15/22] fix isulad-shim coredump when remove ioc fd node
Subject: [PATCH 15/28] fix isulad-shim coredump when remove ioc fd node
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
---

View File

@ -1,7 +1,7 @@
From ae49fce8e19f7544c463cfbff58794f35f44c493 Mon Sep 17 00:00:00 2001
From: WangFengTu <wangfengtu@huawei.com>
Date: Thu, 9 Jun 2022 16:17:52 +0800
Subject: [PATCH 16/22] do not fail if pw is not NULL
Subject: [PATCH 16/28] do not fail if pw is not NULL
Signed-off-by: WangFengTu <wangfengtu@huawei.com>
---

View File

@ -1,7 +1,7 @@
From b4596641a08891bfec9384f87815c8e671d594d4 Mon Sep 17 00:00:00 2001
From: WangFengTu <wangfengtu@huawei.com>
Date: Thu, 9 Jun 2022 17:07:40 +0800
Subject: [PATCH 17/22] do not fail if gr is NULL
Subject: [PATCH 17/28] do not fail if gr is NULL
Signed-off-by: WangFengTu <wangfengtu@huawei.com>
---

View File

@ -1,7 +1,7 @@
From eb168d32053f9204336c37af98210810957cedd2 Mon Sep 17 00:00:00 2001
From: haozi007 <liuhao27@huawei.com>
Date: Fri, 10 Jun 2022 04:10:39 +0100
Subject: [PATCH 18/22] fix memory leak of remove layer
Subject: [PATCH 18/28] fix memory leak of remove layer
Signed-off-by: haozi007 <liuhao27@huawei.com>
---

View File

@ -1,7 +1,7 @@
From 12bbd939c1c2c55d0906b5a53a0b9b26b616c56b Mon Sep 17 00:00:00 2001
From: haozi007 <liuhao27@huawei.com>
Date: Fri, 10 Jun 2022 04:16:48 +0100
Subject: [PATCH 19/22] add null terminal at end of gr mem list
Subject: [PATCH 19/28] add null terminal at end of gr mem list
Signed-off-by: haozi007 <liuhao27@huawei.com>
---

View File

@ -1,7 +1,7 @@
From b289a6b384ac5ba474dd477b2a92b89244b27c24 Mon Sep 17 00:00:00 2001
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
Date: Mon, 13 Jun 2022 14:35:46 +0800
Subject: [PATCH 20/22] fix shm size set invalid when reboot
Subject: [PATCH 20/28] fix shm size set invalid when reboot
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
---

View File

@ -1,7 +1,7 @@
From 8878630c20163dc9b716e2fdc35cae23b8aec6d1 Mon Sep 17 00:00:00 2001
From: wujing <wujing50@huawei.com>
Date: Tue, 14 Jun 2022 15:30:49 +0800
Subject: [PATCH 21/22] set the name of each container and image operation
Subject: [PATCH 21/28] set the name of each container and image operation
thread
Signed-off-by: wujing <wujing50@huawei.com>

View File

@ -1,7 +1,7 @@
From 7d13b23a09d397f743acdcaf606804fea5989cff Mon Sep 17 00:00:00 2001
From: wujing <wujing50@huawei.com>
Date: Tue, 14 Jun 2022 18:54:02 +0800
Subject: [PATCH 22/22] set the name of each container and image operation
Subject: [PATCH 22/28] set the name of each container and image operation
thread for restful version
Signed-off-by: wujing <wujing50@huawei.com>

View File

@ -0,0 +1,32 @@
From 59557dbd1b4d0bde973941d383a30a7b9e0d63d4 Mon Sep 17 00:00:00 2001
From: WangFengTu <wangfengtu@huawei.com>
Date: Thu, 16 Jun 2022 09:16:47 +0800
Subject: [PATCH 23/28] fix inspect -f error when bionic
Signed-off-by: WangFengTu <wangfengtu@huawei.com>
---
src/cmd/isula/information/inspect.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/cmd/isula/information/inspect.c b/src/cmd/isula/information/inspect.c
index 5058fb95..55366551 100644
--- a/src/cmd/isula/information/inspect.c
+++ b/src/cmd/isula/information/inspect.c
@@ -667,12 +667,12 @@ static int inspect_check(const char *json_str, const char *regex)
static int inspect_check_format_f(const char *json_str, bool *json_format)
{
#ifdef __ANDROID__
-#define JSON_FORMAT_FIRST "^[ \t\r\n\v\f]*\\{[ \t\r\n\v\f]*\\{[ \t\r\n\v\f]*(json[ \t\r\n\v\f]+)?(\\.\\w+)+[ \t\r\n\v\f]*\\}[ \t\r\n\v\f]*\\}[ \t\r\n\v\f]*$"
+#define JSON_FORMAT_FIRST "^[ \t\r\n\v\f]*\\{[ \t\r\n\v\f]*\\{[ \t\r\n\v\f]*(json[ \t\r\n\v\f]+)?(\\.[a-zA-Z0-9_]+)+[ \t\r\n\v\f]*\\}[ \t\r\n\v\f]*\\}[ \t\r\n\v\f]*$"
#else
#define JSON_FORMAT_FIRST "^\\s*\\{\\s*\\{\\s*(json\\s+)?(\\.\\w+)+\\s*\\}\\s*\\}\\s*$"
#endif
#ifdef __ANDROID__
-#define JSON_FORMAT_SECOND "^[ \t\r\n\v\f]*\\{[ \t\r\n\v\f]*\\{[ \t\r\n\v\f]*json[ \t\r\n\v\f]+(\\.\\w+)+[ \t\r\n\v\f]*\\}[ \t\r\n\v\f]*\\}[ \t\r\n\v\f]*$"
+#define JSON_FORMAT_SECOND "^[ \t\r\n\v\f]*\\{[ \t\r\n\v\f]*\\{[ \t\r\n\v\f]*json[ \t\r\n\v\f]+(\\.[a-zA-Z0-9_]+)+[ \t\r\n\v\f]*\\}[ \t\r\n\v\f]*\\}[ \t\r\n\v\f]*$"
#else
#define JSON_FORMAT_SECOND "^\\s*\\{\\s*\\{\\s*json\\s+(\\.\\w+)+\\s*\\}\\s*\\}\\s*$"
#endif
--
2.25.1

View File

@ -0,0 +1,289 @@
From 4c945810da8c645eb048e5fbb3a195da855bdcf7 Mon Sep 17 00:00:00 2001
From: wujing <wujing50@huawei.com>
Date: Sat, 14 May 2022 17:13:26 +0800
Subject: [PATCH 24/28] refactor devmapper_parse_options function
Signed-off-by: wujing <wujing50@huawei.com>
---
.../graphdriver/devmapper/deviceset.c | 242 ++++++++++++------
1 file changed, 157 insertions(+), 85 deletions(-)
diff --git a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/deviceset.c b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/deviceset.c
index d90dde50..868e3086 100644
--- a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/deviceset.c
+++ b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/deviceset.c
@@ -65,9 +65,147 @@ static char *util_trim_prefice_string(char *str, const char *prefix)
return str;
}
+typedef int (*devmapper_option_handle)(char *val, struct device_set *devset);
+
+struct devmapper_option_handler {
+ char *name;
+ devmapper_option_handle handle;
+};
+
+static int handle_dm_fs(char *val, struct device_set *devset)
+{
+ if (strcmp(val, "ext4") == 0) {
+ free(devset->filesystem);
+ devset->filesystem = util_strdup_s(val);
+ } else {
+ ERROR("Invalid filesystem: '%s': not supported", val);
+ isulad_set_error_message("Invalid filesystem: '%s': not supported", val);
+ return -1;
+ }
+
+ return 0;
+}
+
+static int handle_dm_thinpooldev(char *val, struct device_set *devset)
+{
+ char *tmp_val = NULL;
+
+ if (!util_valid_str(val)) {
+ ERROR("Invalid thinpool device, it must not be empty");
+ isulad_set_error_message("Invalid thinpool device, it must not be empty");
+ return -1;
+ }
+ tmp_val = util_trim_prefice_string(val, "/dev/mapper/");
+ devset->thin_pool_device = util_strdup_s(tmp_val);
+
+ return 0;
+}
+
+static int handle_dm_min_free_space(char *val, struct device_set *devset)
+{
+ long converted = 0;
+ int ret = util_parse_percent_string(val, &converted);
+
+ if (ret != 0 || converted >= 100) {
+ ERROR("Invalid min free space: '%s': %s", val, strerror(-ret));
+ isulad_set_error_message("Invalid min free space: '%s': %s", val, strerror(-ret));
+ return -1;
+ }
+ devset->min_free_space_percent = (uint32_t)converted;
+
+ return 0;
+}
+
+static int handle_dm_basesize(char *val, struct device_set *devset)
+{
+ int64_t converted = 0;
+ int ret = util_parse_byte_size_string(val, &converted);
+
+ if (ret != 0) {
+ ERROR("Invalid size: '%s': %s", val, strerror(-ret));
+ isulad_set_error_message("Invalid size: '%s': %s", val, strerror(-ret));
+ return -1;
+ }
+ if (converted <= 0) {
+ ERROR("dm.basesize is lower than zero");
+ isulad_set_error_message("dm.basesize is lower than zero");
+ return -1;
+ }
+ devset->user_base_size = true;
+ devset->base_fs_size = (uint64_t)converted;
+
+ return 0;
+}
+
+static int handle_dm_mkfsarg(char *val, struct device_set *devset)
+{
+ if (!util_valid_str(val)) {
+ ERROR("Invalid dm.mkfsarg value");
+ isulad_set_error_message("Invalid dm.mkfsarg value");
+ return -1;
+ }
+ if (util_array_append(&devset->mkfs_args, val) != 0) {
+ ERROR("Out of memory");
+ return -1;
+ }
+ devset->mkfs_args_len++;
+
+ return 0;
+}
+
+static int handle_dm_mountopt(char *val, struct device_set *devset)
+{
+ if (!util_valid_str(val)) {
+ ERROR("Invalid dm.mountopt or devicemapper.mountopt value");
+ isulad_set_error_message("Invalid dm.mountopt or devicemapper.mountopt value");
+ return -1;
+ }
+ devset->mount_options = util_strdup_s(val);
+
+ return 0;
+}
+
+static int devmapper_option_exact(const char *name, char *val, struct device_set *devset)
+{
+ size_t i = 0;
+ bool found = false;
+
+ struct devmapper_option_handler handler_jump_table[] = {
+ { "dm.fs", handle_dm_fs },
+ { "dm.thinpooldev", handle_dm_thinpooldev },
+ { "dm.min_free_space", handle_dm_min_free_space },
+ { "dm.basesize", handle_dm_basesize },
+ { "dm.mkfsarg", handle_dm_mkfsarg },
+ { "dm.mountopt", handle_dm_mountopt },
+ { "devicemapper.mountopt", handle_dm_mountopt },
+ };
+
+ for (i = 0; i < sizeof(handler_jump_table)/sizeof(handler_jump_table[0]); i++) {
+ if (strcmp(handler_jump_table[i].name, name) != 0) {
+ continue;
+ }
+ found = true;
+ if (handler_jump_table[i].handle(val, devset) != 0) {
+ ERROR("Failed to handle %s option with %s", name, val);
+ return -1;
+ }
+ break;
+ }
+
+ if (!found) {
+ ERROR("devicemapper: unknown option: '%s'", name);
+ isulad_set_error_message("devicemapper: unknown option: '%s'", name);
+ return -1;
+ }
+
+ return 0;
+}
+
static int devmapper_parse_options(struct device_set *devset, const char **options, size_t options_len)
{
+ int ret = 0;
size_t i = 0;
+ char *dup_option = NULL;
if (devset == NULL) {
ERROR("Invalid input params");
@@ -75,104 +213,38 @@ static int devmapper_parse_options(struct device_set *devset, const char **optio
}
for (i = 0; options != NULL && i < options_len; i++) {
- char *dup = NULL;
char *val = NULL;
- char *tmp_val = NULL;
- int ret = 0;
- int nret = 0;
- dup = util_strdup_s(options[i]);
- if (dup == NULL) {
+ dup_option = util_strdup_s(options[i]);
+ if (dup_option == NULL) {
ERROR("Out of memory");
return -1;
}
- val = strchr(dup, '=');
+ val = strchr(dup_option, '=');
if (val == NULL) {
- ERROR("Unable to parse key/value option: '%s'", dup);
- isulad_set_error_message("Unable to parse key/value option: '%s'", dup);
- free(dup);
- return -1;
+ ERROR("Unable to parse key/value option: '%s'", dup_option);
+ isulad_set_error_message("Unable to parse key/value option: '%s'", dup_option);
+ ret = -1;
+ goto out;
}
+
*val = '\0';
val++;
- if (strcasecmp(dup, "dm.fs") == 0) {
- if (strcmp(val, "ext4") == 0) {
- free(devset->filesystem);
- devset->filesystem = util_strdup_s(val);
- } else {
- ERROR("Invalid filesystem: '%s': not supported", val);
- isulad_set_error_message("Invalid filesystem: '%s': not supported", val);
- ret = -1;
- }
- } else if (strcasecmp(dup, "dm.thinpooldev") == 0) {
- if (!util_valid_str(val)) {
- ERROR("Invalid thinpool device, it must not be empty");
- isulad_set_error_message("Invalid thinpool device, it must not be empty");
- ret = -1;
- goto out;
- }
- tmp_val = util_trim_prefice_string(val, "/dev/mapper/");
- devset->thin_pool_device = util_strdup_s(tmp_val);
- } else if (strcasecmp(dup, "dm.min_free_space") == 0) {
- long converted = 0;
- ret = util_parse_percent_string(val, &converted);
- if (ret != 0 || converted >= 100) {
- ERROR("Invalid min free space: '%s': %s", val, strerror(-ret));
- isulad_set_error_message("Invalid min free space: '%s': %s", val, strerror(-ret));
- ret = -1;
- goto out;
- }
- devset->min_free_space_percent = (uint32_t)converted;
- } else if (strcasecmp(dup, "dm.basesize") == 0) {
- int64_t converted = 0;
- ret = util_parse_byte_size_string(val, &converted);
- if (ret != 0) {
- ERROR("Invalid size: '%s': %s", val, strerror(-ret));
- isulad_set_error_message("Invalid size: '%s': %s", val, strerror(-ret));
- ret = -1;
- goto out;
- }
- if (converted <= 0) {
- ERROR("dm.basesize is lower than zero");
- isulad_set_error_message("dm.basesize is lower than zero");
- ret = -1;
- goto out;
- }
- devset->user_base_size = true;
- devset->base_fs_size = (uint64_t)converted;
- } else if (strcasecmp(dup, "dm.mkfsarg") == 0) {
- if (!util_valid_str(val)) {
- ERROR("Invalid dm.mkfsarg value");
- isulad_set_error_message("Invalid dm.mkfsarg value");
- ret = -1;
- goto out;
- }
- nret = util_array_append(&devset->mkfs_args, val);
- if (nret != 0) {
- ERROR("Out of memory");
- ret = -1;
- goto out;
- }
- devset->mkfs_args_len++;
- } else if (strcasecmp(dup, "dm.mountopt") == 0 || strcasecmp(dup, "devicemapper.mountopt") == 0) {
- if (!util_valid_str(val)) {
- ERROR("Invalid dm.mountopt or devicemapper.mountopt value");
- isulad_set_error_message("Invalid dm.mountopt or devicemapper.mountopt value");
- ret = -1;
- goto out;
- }
- devset->mount_options = util_strdup_s(val);
- } else {
- ERROR("devicemapper: unknown option: '%s'", dup);
- isulad_set_error_message("devicemapper: unknown option: '%s'", dup);
+
+ if (devmapper_option_exact(dup_option, val, devset) != 0) {
+ ERROR("Failed to exact devmapper option: %s", dup_option);
ret = -1;
+ goto out;
}
+
+ free(dup_option);
+ }
+
out:
- free(dup);
- if (ret != 0) {
- return ret;
- }
+ free(dup_option);
+ if (ret != 0) {
+ return ret;
}
return 0;
--
2.25.1

View File

@ -0,0 +1,153 @@
From 4df32783e4a665bd639f8b3ccd1b8860614eefb3 Mon Sep 17 00:00:00 2001
From: wujing <wujing50@huawei.com>
Date: Sat, 14 May 2022 15:33:33 +0800
Subject: [PATCH 25/28] refactor parse_volume function
Signed-off-by: wujing <wujing50@huawei.com>
---
src/daemon/modules/spec/parse_volume.c | 91 ++++++++++++++------------
1 file changed, 50 insertions(+), 41 deletions(-)
diff --git a/src/daemon/modules/spec/parse_volume.c b/src/daemon/modules/spec/parse_volume.c
index ef2d58e4..3afa0962 100644
--- a/src/daemon/modules/spec/parse_volume.c
+++ b/src/daemon/modules/spec/parse_volume.c
@@ -341,22 +341,60 @@ static int check_volume_element(const char *volume)
return ret;
}
+static int set_volume_element_options(defs_mount *mount_element, const char **modes)
+{
+ const size_t max_options_len = 4;
+ size_t options_len = 0;
+ size_t i = 0;
+ bool with_rw = false;
+ bool with_pro = false;
+ bool with_label = false;
+
+ mount_element->options = util_common_calloc_s(max_options_len * sizeof(char *));
+ if (mount_element->options == NULL) {
+ ERROR("Out of memory");
+ return -1;
+ }
+
+ options_len = util_array_len((const char **)modes);
+ if (options_len > max_options_len) {
+ ERROR("Invalid volume element options");
+ return -1;
+ }
+
+ for (i = 0; i < options_len; i++) {
+ if (util_valid_rw_mode(modes[i])) {
+ with_rw = true;
+ mount_element->options[mount_element->options_len++] = util_strdup_s(modes[i]);
+ } else if (util_valid_propagation_mode(modes[i])) {
+ with_pro = true;
+ mount_element->options[mount_element->options_len++] = util_strdup_s(modes[i]);
+ } else if (util_valid_label_mode(modes[i])) {
+ with_label = true;
+ mount_element->options[mount_element->options_len++] = util_strdup_s(modes[i]);
+ } else if (util_valid_copy_mode(modes[i])) {
+ mount_element->options[mount_element->options_len++] = util_strdup_s(modes[i]);
+ }
+ }
+
+ if (append_default_mount_options(mount_element, with_rw, with_pro, with_label) != 0) {
+ ERROR("Failed to append default mount options");
+ return -1;
+ }
+
+ return 0;
+}
+
defs_mount *parse_volume(const char *volume)
{
int ret = 0;
- size_t i = 0;
- size_t mlen = 0;
defs_mount *mount_element = NULL;
char **modes = NULL;
char path[PATH_MAX] = { 0x00 };
- char *rw = NULL;
- char *pro = NULL;
- char *label = NULL;
- size_t max_options_len = 4;
- char *nocopy = NULL;
ret = check_volume_element(volume);
if (ret != 0) {
+ ERROR("Invalid volume element");
goto free_out;
}
@@ -368,22 +406,10 @@ defs_mount *parse_volume(const char *volume)
ret = get_src_dst_mode_by_volume(volume, mount_element, &modes);
if (ret != 0) {
+ ERROR("Failed to parse volume");
goto free_out;
}
- mlen = util_array_len((const char **)modes);
- for (i = 0; i < mlen; i++) {
- if (util_valid_rw_mode(modes[i])) {
- rw = modes[i];
- } else if (util_valid_propagation_mode(modes[i])) {
- pro = modes[i];
- } else if (util_valid_label_mode(modes[i])) {
- label = modes[i];
- } else if (util_valid_copy_mode(modes[i])) {
- nocopy = modes[i];
- }
- }
-
if (!util_clean_path(mount_element->destination, path, sizeof(path))) {
ERROR("Failed to get clean path");
ret = -1;
@@ -402,25 +428,6 @@ defs_mount *parse_volume(const char *volume)
mount_element->source = util_strdup_s(path);
}
- mount_element->options = util_common_calloc_s(max_options_len * sizeof(char *));
- if (mount_element->options == NULL) {
- ERROR("Out of memory");
- mount_element->options_len = 0;
- ret = -1;
- goto free_out;
- }
- if (rw != NULL) {
- mount_element->options[mount_element->options_len++] = util_strdup_s(rw);
- }
- if (pro != NULL) {
- mount_element->options[mount_element->options_len++] = util_strdup_s(pro);
- }
- if (label != NULL) {
- mount_element->options[mount_element->options_len++] = util_strdup_s(label);
- }
- if (nocopy != NULL) {
- mount_element->options[mount_element->options_len++] = util_strdup_s(nocopy);
- }
if (mount_element->source != NULL && mount_element->source[0] == '/') {
mount_element->type = util_strdup_s(MOUNT_TYPE_BIND);
} else {
@@ -430,13 +437,15 @@ defs_mount *parse_volume(const char *volume)
}
}
- ret = check_mount_element(volume, mount_element);
+ ret = set_volume_element_options(mount_element, (const char **)modes);
if (ret != 0) {
+ ERROR("Failed to set volume element options");
goto free_out;
}
- ret = append_default_mount_options(mount_element, rw != NULL, pro != NULL, label != NULL);
+ ret = check_mount_element(volume, mount_element);
if (ret != 0) {
+ ERROR("Invalid mount element");
goto free_out;
}
--
2.25.1

View File

@ -0,0 +1,93 @@
From fdb731d7a272eb1574ef31b058beffbefffa1eb2 Mon Sep 17 00:00:00 2001
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
Date: Wed, 18 May 2022 10:30:35 +0800
Subject: [PATCH 26/28] fix parse volume failed
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
---
src/daemon/modules/spec/parse_volume.c | 28 ++++++++++++++------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/src/daemon/modules/spec/parse_volume.c b/src/daemon/modules/spec/parse_volume.c
index 3afa0962..7b02f6ca 100644
--- a/src/daemon/modules/spec/parse_volume.c
+++ b/src/daemon/modules/spec/parse_volume.c
@@ -341,14 +341,12 @@ static int check_volume_element(const char *volume)
return ret;
}
-static int set_volume_element_options(defs_mount *mount_element, const char **modes)
+static int set_volume_element_options(defs_mount *mount_element, const char **modes, bool *with_rw,
+ bool *with_pro, bool *with_label)
{
const size_t max_options_len = 4;
size_t options_len = 0;
size_t i = 0;
- bool with_rw = false;
- bool with_pro = false;
- bool with_label = false;
mount_element->options = util_common_calloc_s(max_options_len * sizeof(char *));
if (mount_element->options == NULL) {
@@ -364,30 +362,28 @@ static int set_volume_element_options(defs_mount *mount_element, const char **mo
for (i = 0; i < options_len; i++) {
if (util_valid_rw_mode(modes[i])) {
- with_rw = true;
+ *with_rw = true;
mount_element->options[mount_element->options_len++] = util_strdup_s(modes[i]);
} else if (util_valid_propagation_mode(modes[i])) {
- with_pro = true;
+ *with_pro = true;
mount_element->options[mount_element->options_len++] = util_strdup_s(modes[i]);
} else if (util_valid_label_mode(modes[i])) {
- with_label = true;
+ *with_label = true;
mount_element->options[mount_element->options_len++] = util_strdup_s(modes[i]);
} else if (util_valid_copy_mode(modes[i])) {
mount_element->options[mount_element->options_len++] = util_strdup_s(modes[i]);
}
}
- if (append_default_mount_options(mount_element, with_rw, with_pro, with_label) != 0) {
- ERROR("Failed to append default mount options");
- return -1;
- }
-
return 0;
}
defs_mount *parse_volume(const char *volume)
{
int ret = 0;
+ bool with_rw = false;
+ bool with_pro = false;
+ bool with_label = false;
defs_mount *mount_element = NULL;
char **modes = NULL;
char path[PATH_MAX] = { 0x00 };
@@ -437,7 +433,7 @@ defs_mount *parse_volume(const char *volume)
}
}
- ret = set_volume_element_options(mount_element, (const char **)modes);
+ ret = set_volume_element_options(mount_element, (const char **)modes, &with_rw, &with_pro, &with_label);
if (ret != 0) {
ERROR("Failed to set volume element options");
goto free_out;
@@ -449,6 +445,12 @@ defs_mount *parse_volume(const char *volume)
goto free_out;
}
+ ret = append_default_mount_options(mount_element, with_rw, with_pro, with_label);
+ if (ret != 0) {
+ ERROR("Failed to append default mount options");
+ goto free_out;
+ }
+
free_out:
util_free_array(modes);
if (ret != 0) {
--
2.25.1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,41 @@
From 2ca552a7faee850c6cfdccc4625b4459add56074 Mon Sep 17 00:00:00 2001
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
Date: Tue, 21 Jun 2022 17:34:23 +0800
Subject: [PATCH 28/28] increase websocket lws_lookup size
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
---
src/daemon/entry/cri/websocket/service/ws_server.cc | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/daemon/entry/cri/websocket/service/ws_server.cc b/src/daemon/entry/cri/websocket/service/ws_server.cc
index 0e462737..98c0fee0 100644
--- a/src/daemon/entry/cri/websocket/service/ws_server.cc
+++ b/src/daemon/entry/cri/websocket/service/ws_server.cc
@@ -187,7 +187,13 @@ void WebsocketServer::EmitLog(int level, const char *line)
int WebsocketServer::CreateContext()
{
- const size_t WS_ULIMIT_FDS { 1024 };
+ /*
+ context->lws_lookup is allocated ( sizeof(struct lws *) * max_fds ) spaces,
+ In general, max_fds should be the process maximum number of open file descriptor.
+ If WS_ULIMIT_FDS set too large, context->lws_lookup will cost too much memory.
+ If WS_ULIMIT_FDS set too small, maybe fd > max_fds and context->lws_lookup[fd] will overflow.
+ */
+ const size_t WS_ULIMIT_FDS { 10240 };
m_url.SetScheme("ws");
m_url.SetHost("localhost:" + std::to_string(m_listenPort));
@@ -208,7 +214,7 @@ int WebsocketServer::CreateContext()
/* daemon set RLIMIT_NOFILE to a large value at main.c,
* belowing lws_create_context limit the fds of websocket to RLIMIT_NOFILE,
- * and malloced memory according to it. To reduce memory, we recover it to 1024 before create m_context.
+ * and malloced memory according to it. To reduce memory, we recover it to WS_ULIMIT_FDS before create m_context.
*/
rlimit oldLimit, newLimit;
newLimit.rlim_cur = WS_ULIMIT_FDS;
--
2.25.1

View File

@ -1,5 +1,5 @@
%global _version 2.0.14
%global _release 8
%global _release 9
%global is_systemd 1
%global enable_shimv2 1
%global is_embedded 1
@ -35,6 +35,12 @@ Patch0019: 0019-add-null-terminal-at-end-of-gr-mem-list.patch
Patch0020: 0020-fix-shm-size-set-invalid-when-reboot.patch
Patch0021: 0021-set-the-name-of-each-container-and-image-operation-t.patch
Patch0022: 0022-set-the-name-of-each-container-and-image-operation-t.patch
Patch0023: 0023-fix-inspect-f-error-when-bionic.patch
Patch0024: 0024-refactor-devmapper_parse_options-function.patch
Patch0025: 0025-refactor-parse_volume-function.patch
Patch0026: 0026-fix-parse-volume-failed.patch
Patch0027: 0027-use-util_smart_calloc_t-to-prevent-overflow.patch
Patch0028: 0028-increase-websocket-lws_lookup-size.patch
%ifarch x86_64 aarch64
Provides: libhttpclient.so()(64bit)
@ -262,6 +268,12 @@ fi
%endif
%changelog
* Tue Jun 21 2022 zhangxiaoyu <zhangxiaoyu58@huawei.com> - 2.0.14-9
- Type: enhancement
- ID: NA
- SUG: NA
- DESC: sync from upstream openeuler/iSulad
* Wed Jun 15 2022 chengzeruizhi <chengzeruizhi@huawei.com> - 2.0.14-8
- Type: enhancement
- ID: NA