summaryrefslogtreecommitdiffstats
path: root/recipes-containers/lxc/files/0001-Patching-an-incoming-CVE-CVE-2022-47952.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-containers/lxc/files/0001-Patching-an-incoming-CVE-CVE-2022-47952.patch')
-rw-r--r--recipes-containers/lxc/files/0001-Patching-an-incoming-CVE-CVE-2022-47952.patch76
1 files changed, 76 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