summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXiangyu Chen <xiangyu.chen@windriver.com>2023-01-18 09:37:05 +0800
committerBruce Ashfield <bruce.ashfield@gmail.com>2023-01-19 15:15:04 -0500
commitd1cbc4c9fc44f0c5994a1276e38cdbb7bdb5bbd3 (patch)
tree4f142c60d961b746f97687aa29f45efbf189a0df
parent83f8742b0e17b7cce7ec748b7922ee0a7ec41afc (diff)
downloadmeta-virtualization-langdale.tar.gz
lxc: backport patch to fix CVE-2022-47952langdale
Signed-off-by: Xiangyu Chen <xiangyu.chen@windriver.com> Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
-rw-r--r--recipes-containers/lxc/files/0001-Patching-an-incoming-CVE-CVE-2022-47952.patch76
-rw-r--r--recipes-containers/lxc/lxc_git.bb1
2 files changed, 77 insertions, 0 deletions
diff --git a/recipes-containers/lxc/files/0001-Patching-an-incoming-CVE-CVE-2022-47952.patch b/recipes-containers/lxc/files/0001-Patching-an-incoming-CVE-CVE-2022-47952.patch
new file mode 100644
index 00000000..d5a02f40
--- /dev/null
+++ b/recipes-containers/lxc/files/0001-Patching-an-incoming-CVE-CVE-2022-47952.patch
@@ -0,0 +1,76 @@
1From 1b0469530d7a38b8f8990e114b52530d1bf7f3b8 Mon Sep 17 00:00:00 2001
2From: Maher Azzouzi <maherazz04@gmail.com>
3Date: Sun, 25 Dec 2022 13:50:25 +0100
4Subject: [PATCH] Patching an incoming CVE (CVE-2022-47952)
5
6lxc-user-nic in lxc through 5.0.1 is installed setuid root, and may
7allow local users to infer whether any file exists, even within a
8protected directory tree, because "Failed to open" often indicates
9that a file does not exist, whereas "does not refer to a network
10namespace path" often indicates that a file exists. NOTE: this is
11different from CVE-2018-6556 because the CVE-2018-6556 fix design was
12based on the premise that "we will report back to the user that the
13open() failed but the user has no way of knowing why it failed";
14however, in many realistic cases, there are no plausible reasons for
15failing except that the file does not exist.
16
17PoC:
18> % ls /l
19> ls: cannot open directory '/l': Permission denied
20> % /usr/lib/x86_64-linux-gnu/lxc/lxc-user-nic delete lol lol /l/h/tt h h
21> cmd/lxc_user_nic.c: 1096: main: Failed to open "/l/h/tt" <----- file does not exist.
22> % /usr/lib/x86_64-linux-gnu/lxc/lxc-user-nic delete lol lol /l/h/t h h
23> cmd/lxc_user_nic.c: 1101: main: Path "/l/h/t" does not refer to a network namespace path <---- file exist!
24
25Upstream-Status: Backport from https://github.com/lxc/lxc/commit/1b0469530d7a38b8f8990e114b52530d1bf7f3b8
26CVE: CVE-2022-47952
27
28Signed-off-by: MaherAzzouzi <maherazz04@gmail.com>
29Acked-by: Serge Hallyn <serge@hallyn.com>
30Signed-off-by: Xiangyu Chen <xiangyu.chen@windriver.com>
31---
32 src/lxc/cmd/lxc_user_nic.c | 15 ++++++---------
33 1 file changed, 6 insertions(+), 9 deletions(-)
34
35diff --git a/src/lxc/cmd/lxc_user_nic.c b/src/lxc/cmd/lxc_user_nic.c
36index a91e2259d..69bc6f17d 100644
37--- a/src/lxc/cmd/lxc_user_nic.c
38+++ b/src/lxc/cmd/lxc_user_nic.c
39@@ -1085,20 +1085,17 @@ int main(int argc, char *argv[])
40 } else if (request == LXC_USERNIC_DELETE) {
41 char opath[LXC_PROC_PID_FD_LEN];
42
43- /* Open the path with O_PATH which will not trigger an actual
44- * open(). Don't report an errno to the caller to not leak
45- * information whether the path exists or not.
46- * When stracing setuid is stripped so this is not a concern
47- * either.
48- */
49+ // Keep in mind CVE-2022-47952: It's crucial not to leak any
50+ // information whether open() succeeded of failed.
51+
52 netns_fd = open(args.pid, O_PATH | O_CLOEXEC);
53 if (netns_fd < 0) {
54- usernic_error("Failed to open \"%s\"\n", args.pid);
55+ usernic_error("Failed while opening netns file for \"%s\"\n", args.pid);
56 _exit(EXIT_FAILURE);
57 }
58
59 if (!fhas_fs_type(netns_fd, NSFS_MAGIC)) {
60- usernic_error("Path \"%s\" does not refer to a network namespace path\n", args.pid);
61+ usernic_error("Failed while opening netns file for \"%s\"\n", args.pid);
62 close(netns_fd);
63 _exit(EXIT_FAILURE);
64 }
65@@ -1112,7 +1109,7 @@ int main(int argc, char *argv[])
66 /* Now get an fd that we can use in setns() calls. */
67 ret = open(opath, O_RDONLY | O_CLOEXEC);
68 if (ret < 0) {
69- CMD_SYSERROR("Failed to open \"%s\"\n", args.pid);
70+ CMD_SYSERROR("Failed while opening netns file for \"%s\"\n", args.pid);
71 close(netns_fd);
72 _exit(EXIT_FAILURE);
73 }
74--
752.34.1
76
diff --git a/recipes-containers/lxc/lxc_git.bb b/recipes-containers/lxc/lxc_git.bb
index 9cabe054..a99d7ee7 100644
--- a/recipes-containers/lxc/lxc_git.bb
+++ b/recipes-containers/lxc/lxc_git.bb
@@ -47,6 +47,7 @@ SRC_URI = "git://github.com/lxc/lxc.git;branch=master;protocol=https \
47 file://0001-use-sd_bus_call_method_async-to-replace-the-asyncv-o.patch \ 47 file://0001-use-sd_bus_call_method_async-to-replace-the-asyncv-o.patch \
48 file://dnsmasq.conf \ 48 file://dnsmasq.conf \
49 file://lxc-net \ 49 file://lxc-net \
50 file://0001-Patching-an-incoming-CVE-CVE-2022-47952.patch \
50 " 51 "
51 52
52SRCREV = "133aa416ca2a5996090ec0e697e253646364d274" 53SRCREV = "133aa416ca2a5996090ec0e697e253646364d274"