diff options
-rw-r--r-- | recipes-containers/lxc/files/0001-Patching-an-incoming-CVE-CVE-2022-47952.patch | 76 | ||||
-rw-r--r-- | recipes-containers/lxc/lxc_git.bb | 1 |
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 @@ | |||
1 | From 1b0469530d7a38b8f8990e114b52530d1bf7f3b8 Mon Sep 17 00:00:00 2001 | ||
2 | From: Maher Azzouzi <maherazz04@gmail.com> | ||
3 | Date: Sun, 25 Dec 2022 13:50:25 +0100 | ||
4 | Subject: [PATCH] Patching an incoming CVE (CVE-2022-47952) | ||
5 | |||
6 | lxc-user-nic in lxc through 5.0.1 is installed setuid root, and may | ||
7 | allow local users to infer whether any file exists, even within a | ||
8 | protected directory tree, because "Failed to open" often indicates | ||
9 | that a file does not exist, whereas "does not refer to a network | ||
10 | namespace path" often indicates that a file exists. NOTE: this is | ||
11 | different from CVE-2018-6556 because the CVE-2018-6556 fix design was | ||
12 | based on the premise that "we will report back to the user that the | ||
13 | open() failed but the user has no way of knowing why it failed"; | ||
14 | however, in many realistic cases, there are no plausible reasons for | ||
15 | failing except that the file does not exist. | ||
16 | |||
17 | PoC: | ||
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 | |||
25 | Upstream-Status: Backport from https://github.com/lxc/lxc/commit/1b0469530d7a38b8f8990e114b52530d1bf7f3b8 | ||
26 | CVE: CVE-2022-47952 | ||
27 | |||
28 | Signed-off-by: MaherAzzouzi <maherazz04@gmail.com> | ||
29 | Acked-by: Serge Hallyn <serge@hallyn.com> | ||
30 | Signed-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 | |||
35 | diff --git a/src/lxc/cmd/lxc_user_nic.c b/src/lxc/cmd/lxc_user_nic.c | ||
36 | index 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 | -- | ||
75 | 2.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 | ||
52 | SRCREV = "133aa416ca2a5996090ec0e697e253646364d274" | 53 | SRCREV = "133aa416ca2a5996090ec0e697e253646364d274" |