summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--recipes-extended/hyperstart/hyperstart/0001-container.c-Fix-compiler-errors-that-gcc-8.1.0-repor.patch230
-rw-r--r--recipes-extended/hyperstart/hyperstart_git.bb26
2 files changed, 0 insertions, 256 deletions
diff --git a/recipes-extended/hyperstart/hyperstart/0001-container.c-Fix-compiler-errors-that-gcc-8.1.0-repor.patch b/recipes-extended/hyperstart/hyperstart/0001-container.c-Fix-compiler-errors-that-gcc-8.1.0-repor.patch
deleted file mode 100644
index d48e2647..00000000
--- a/recipes-extended/hyperstart/hyperstart/0001-container.c-Fix-compiler-errors-that-gcc-8.1.0-repor.patch
+++ /dev/null
@@ -1,230 +0,0 @@
1From 085dd65bba063e391350487f2a5e4a7bf69ee6c8 Mon Sep 17 00:00:00 2001
2From: Jason Wessel <jason.wessel@windriver.com>
3Date: Fri, 15 Jun 2018 08:04:35 -0700
4Subject: [PATCH] container.c: Fix compiler errors that gcc 8.1.0 reports
5
6gcc 8.1.0 reports the following compiler errors/warnings. They can be
7fixed by using snprintf and checking the result for truncation. This
8patch also uses a named constant instead of inserting the value 512 in
9many locations.
10
11container.c: In function 'hyper_setup_container_rootfs':
12container.c:630:24: error: '/' directive writing 1 byte into a region of size between 0 and 511 [-Werror=format-overflow=]
13 sprintf(rootfs, "%s/%s/", root, container->rootfs);
14 ^
15container.c:630:2: note: 'sprintf' output 3 or more bytes (assuming 514) into a destination of size 512
16 sprintf(rootfs, "%s/%s/", root, container->rootfs);
17 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18container.c:262:18: error: '%s' directive writing up to 511 bytes into a region of size 510 [-Werror=format-overflow=]
19 sprintf(dst, "./%s", src);
20 ^~ ~~~
21container.c:262:2: note: 'sprintf' output between 3 and 514 bytes into a destination of size 512
22 sprintf(dst, "./%s", src);
23 ^~~~~~~~~~~~~~~~~~~~~~~~~
24container.c:218:24: error: '/_data' directive writing 6 bytes into a region of size between 1 and 512 [-Werror=format-overflow=]
25 sprintf(volume, "%s/_data", path);
26 ^~~~~~
27container.c:218:5: note: 'sprintf' output between 7 and 518 bytes into a destination of size 512
28 sprintf(volume, "%s/_data", path);
29 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
30container.c:149:24: error: '/_data' directive writing 6 bytes into a region of size between 0 and 511 [-Werror=format-overflow=]
31 sprintf(volume, "/%s/_data", path);
32 ^~~~~~
33container.c:149:4: note: 'sprintf' output between 8 and 519 bytes into a destination of size 512
34 sprintf(volume, "/%s/_data", path);
35 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
36container.c:131:24: error: '/' directive writing 1 byte into a region of size between 0 and 511 [-Werror=format-overflow=]
37 sprintf(volume, "/%s/", path);
38 ^
39container.c:131:4: note: 'sprintf' output between 3 and 514 bytes into a destination of size 512
40 sprintf(volume, "/%s/", path);
41 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
42container.c:176:24: error: '/_data/' directive writing 7 bytes into a region of size between 0 and 511 [-Werror=format-overflow=]
43 sprintf(volume, "/%s/_data/%s", path, filevolume);
44 ^~~~~~~
45container.c:176:4: note: 'sprintf' output 9 or more bytes (assuming 520) into a destination of size 512
46 sprintf(volume, "/%s/_data/%s", path, filevolume);
47 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
48
49Upstream-Status: Inappropriate [embedded specific]
50
51Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
52
53---
54 src/container.c | 47 ++++++++++++++++++++++++++++-------------------
55 1 file changed, 28 insertions(+), 19 deletions(-)
56
57diff --git a/src/container.c b/src/container.c
58index fee67ff..94d49d8 100644
59--- a/src/container.c
60+++ b/src/container.c
61@@ -22,6 +22,8 @@
62 #include "syscall.h"
63 #include "netlink.h"
64
65+#define MAX_PBUF 512
66+
67 static int container_populate_volume(char *src, char *dest)
68 {
69 struct stat st;
70@@ -116,12 +118,12 @@ static int container_setup_volume(struct hyper_pod *pod,
71 struct hyper_container *container)
72 {
73 int i;
74- char dev[512], path[512];
75+ char dev[MAX_PBUF], path[MAX_PBUF];
76 struct volume *vol;
77
78 for (i = 0; i < container->vols_num; i++) {
79- char volume[512];
80- char mountpoint[512];
81+ char volume[MAX_PBUF];
82+ char mountpoint[MAX_PBUF];
83 char *options = NULL;
84 const char *filevolume = NULL;
85 bool newvolume = false;
86@@ -146,7 +148,8 @@ static int container_setup_volume(struct hyper_pod *pod,
87 if (hyper_mount_nfs(vol->device, path) < 0)
88 return -1;
89 /* nfs export has implicitly included _data part of the volume */
90- sprintf(volume, "/%s/", path);
91+ if (snprintf(volume, MAX_PBUF, "/%s/", path) >= MAX_PBUF)
92+ return -1;
93 } else {
94 fprintf(stdout, "mount %s to %s, tmp path %s\n",
95 dev, vol->mountpoint, path);
96@@ -155,7 +158,7 @@ static int container_setup_volume(struct hyper_pod *pod,
97 options = "nouuid";
98
99 if (access(dev, R_OK) < 0) {
100- char device[512];
101+ char device[MAX_PBUF];
102 sprintf(device, "/block/%s", vol->device);
103 hyper_netlink_wait_dev(pod->ueventfd, device);
104 }
105@@ -164,7 +167,8 @@ static int container_setup_volume(struct hyper_pod *pod,
106 perror("mount volume device failed");
107 return -1;
108 }
109- sprintf(volume, "/%s/_data", path);
110+ if (snprintf(volume, MAX_PBUF, "/%s/_data", path) >= MAX_PBUF)
111+ return -1;
112 }
113
114 if (container_check_volume(volume, &filevolume, &newvolume) < 0)
115@@ -193,7 +197,8 @@ static int container_setup_volume(struct hyper_pod *pod,
116 perror("create volume file failed");
117 return -1;
118 }
119- sprintf(volume, "/%s/_data/%s", path, filevolume);
120+ if (snprintf(volume, MAX_PBUF, "/%s/_data/%s", path, filevolume) >= MAX_PBUF)
121+ return -1;
122 /* 0777 so that any user can read/write the new file volume */
123 if (chmod(volume, 0777) < 0) {
124 fprintf(stderr, "fail to chmod directory %s\n", volume);
125@@ -217,9 +222,9 @@ static int container_setup_volume(struct hyper_pod *pod,
126
127 for (i = 0; i < container->maps_num; i++) {
128 struct stat st;
129- char *src, path[512], volume[512];
130+ char *src, path[MAX_PBUF], volume[MAX_PBUF];
131 struct fsmap *map = &container->maps[i];
132- char mountpoint[512];
133+ char mountpoint[MAX_PBUF];
134
135 sprintf(path, "%s/%s", SHARED_DIR, map->source);
136 sprintf(mountpoint, "./%s", map->path);
137@@ -235,7 +240,8 @@ static int container_setup_volume(struct hyper_pod *pod,
138 }
139 if (map->docker) {
140 /* converted from volume */
141- sprintf(volume, "%s/_data", path);
142+ if (snprintf(volume, MAX_PBUF, "%s/_data", path) >= MAX_PBUF)
143+ return -1;
144 src = volume;
145 if (container->initialize &&
146 (container_populate_volume(mountpoint, volume) < 0)) {
147@@ -271,7 +277,7 @@ static int container_setup_modules(struct hyper_container *container)
148 {
149 struct stat st;
150 struct utsname uts;
151- char src[512], dst[512];
152+ char src[MAX_PBUF], dst[MAX_PBUF];
153
154 if (uname(&uts) < 0) {
155 perror("fail to call uname");
156@@ -279,7 +285,8 @@ static int container_setup_modules(struct hyper_container *container)
157 }
158
159 sprintf(src, "/lib/modules/%s", uts.release);
160- sprintf(dst, "./%s", src);
161+ if (snprintf(dst, MAX_PBUF, "./%s", src) >= MAX_PBUF)
162+ return -1;
163
164 if (stat(dst, &st) == 0) {
165 struct dirent **list;
166@@ -318,7 +325,7 @@ static int container_setup_modules(struct hyper_container *container)
167
168 static int container_setup_mount(struct hyper_container *container)
169 {
170- char src[512];
171+ char src[MAX_PBUF];
172
173 // current dir is container rootfs, the operations on "./PATH" are the operations on container's "/PATH"
174 if (!container->readonly) {
175@@ -576,7 +583,7 @@ static int hyper_setup_container_rootfs(void *data)
176 {
177 struct hyper_container_arg *arg = data;
178 struct hyper_container *container = arg->c;
179- char root[512], rootfs[512];
180+ char root[MAX_PBUF], rootfs[MAX_PBUF];
181 int setup_dns;
182
183 /* wait for ns-opened ready message */
184@@ -639,7 +646,7 @@ static int hyper_setup_container_rootfs(void *data)
185 goto fail;
186 }
187 } else {
188- char path[512];
189+ char path[MAX_PBUF];
190
191 sprintf(path, "%s/%s/", SHARED_DIR, container->image);
192 fprintf(stdout, "src directory %s\n", path);
193@@ -657,7 +664,9 @@ static int hyper_setup_container_rootfs(void *data)
194 fprintf(stdout, "root directory for container is %s/%s, init task %s\n",
195 root, container->rootfs, container->exec.argv[0]);
196
197- sprintf(rootfs, "%s/%s/", root, container->rootfs);
198+ if (snprintf(rootfs, MAX_PBUF, "%s/%s/", root, container->rootfs) >= MAX_PBUF)
199+ goto fail;
200+
201 if (mount(rootfs, rootfs, NULL, MS_BIND|MS_REC, NULL) < 0) {
202 perror("failed to bind rootfs");
203 goto fail;
204@@ -740,7 +749,7 @@ fail:
205
206 static int hyper_setup_pty(struct hyper_container *c)
207 {
208- char root[512];
209+ char root[MAX_PBUF];
210
211 sprintf(root, "/tmp/hyper/%s/devpts/", c->id);
212
213@@ -760,7 +769,7 @@ static int hyper_setup_pty(struct hyper_container *c)
214
215 static void hyper_cleanup_pty(struct hyper_container *c)
216 {
217- char path[512];
218+ char path[MAX_PBUF];
219
220 sprintf(path, "/tmp/hyper/%s/devpts/", c->id);
221 if (umount(path) < 0)
222@@ -769,7 +778,7 @@ static void hyper_cleanup_pty(struct hyper_container *c)
223
224 int container_prepare_rootfs_dev(struct hyper_container *container, struct hyper_pod *pod)
225 {
226- char dev[512];
227+ char dev[MAX_PBUF];
228
229 if (container->fstype == NULL)
230 return 0;
diff --git a/recipes-extended/hyperstart/hyperstart_git.bb b/recipes-extended/hyperstart/hyperstart_git.bb
deleted file mode 100644
index e156cdae..00000000
--- a/recipes-extended/hyperstart/hyperstart_git.bb
+++ /dev/null
@@ -1,26 +0,0 @@
1SUMMARY = "The tiny Init service for HyperContainer"
2DESCRIPTION = "The init Task for HyperContainer"
3
4LICENSE = "Apache-2.0"
5LIC_FILES_CHKSUM = "file://LICENSE;md5=fa818a259cbed7ce8bc2a22d35a464fc"
6
7inherit autotools-brokensep
8
9SRC_URI = "git://github.com/hyperhq/hyperstart.git;branch=master;protocol=https"
10SRC_URI += "file://0001-container.c-Fix-compiler-errors-that-gcc-8.1.0-repor.patch"
11
12SRCREV = "c0c07d218b482dd07f9068b52a6e7468ae4172ac"
13PV = "v0.2+git"
14
15S = "${WORKDIR}/git"
16
17CACHED_CONFIGUREVARS = "ac_cv_file__usr_include_linux_vm_sockets_h=true"
18
19do_install() {
20 install -d ${D}/var/lib/hyper/
21
22 install -m644 ${S}/build/hyper-initrd.img ${D}/var/lib/hyper/
23 install -m644 ${S}/build/arch/x86_64/kernel ${D}/var/lib/hyper/
24}
25
26FILES:${PN} += "/var/lib/hyper"