diff options
14 files changed, 15 insertions, 747 deletions
diff --git a/meta-yocto-bsp/conf/machine/genericx86-64.conf b/meta-yocto-bsp/conf/machine/genericx86-64.conf index f19a1c1527..16e7fefc47 100644 --- a/meta-yocto-bsp/conf/machine/genericx86-64.conf +++ b/meta-yocto-bsp/conf/machine/genericx86-64.conf | |||
@@ -3,7 +3,7 @@ | |||
3 | #@DESCRIPTION: Machine configuration for generic x86_64 (64-bit) PCs and servers. Supports a moderately wide range of drivers that should boot and be usable on "typical" hardware. | 3 | #@DESCRIPTION: Machine configuration for generic x86_64 (64-bit) PCs and servers. Supports a moderately wide range of drivers that should boot and be usable on "typical" hardware. |
4 | 4 | ||
5 | DEFAULTTUNE ?= "core2-64" | 5 | DEFAULTTUNE ?= "core2-64" |
6 | require conf/machine/include/x86/tune-core2.inc | 6 | require conf/machine/include/x86/tune-x86-64-v3.inc |
7 | require conf/machine/include/genericx86-common.inc | 7 | require conf/machine/include/genericx86-common.inc |
8 | 8 | ||
9 | #For runqemu | 9 | #For runqemu |
diff --git a/meta-yocto-bsp/conf/machine/genericx86.conf b/meta-yocto-bsp/conf/machine/genericx86.conf index 34e1448a8c..4d378cc7f0 100644 --- a/meta-yocto-bsp/conf/machine/genericx86.conf +++ b/meta-yocto-bsp/conf/machine/genericx86.conf | |||
@@ -3,7 +3,7 @@ | |||
3 | #@DESCRIPTION: Machine configuration for generic x86 (32-bit) PCs. Supports a moderately wide range of drivers that should boot and be usable on "typical" hardware. | 3 | #@DESCRIPTION: Machine configuration for generic x86 (32-bit) PCs. Supports a moderately wide range of drivers that should boot and be usable on "typical" hardware. |
4 | 4 | ||
5 | DEFAULTTUNE ?= "core2-32" | 5 | DEFAULTTUNE ?= "core2-32" |
6 | require conf/machine/include/x86/tune-core2.inc | 6 | require conf/machine/include/x86/tune-corei7.inc |
7 | require conf/machine/include/genericx86-common.inc | 7 | require conf/machine/include/genericx86-common.inc |
8 | 8 | ||
9 | #For runqemu | 9 | #For runqemu |
diff --git a/meta/recipes-devtools/patch/patch/0001-Don-t-leak-temporary-file-on-failed-ed-style-patch.patch b/meta/recipes-devtools/patch/patch/0001-Don-t-leak-temporary-file-on-failed-ed-style-patch.patch deleted file mode 100644 index 78345e925e..0000000000 --- a/meta/recipes-devtools/patch/patch/0001-Don-t-leak-temporary-file-on-failed-ed-style-patch.patch +++ /dev/null | |||
@@ -1,94 +0,0 @@ | |||
1 | From 7f770b9c20da1a192dad8cb572a6391f2773285a Mon Sep 17 00:00:00 2001 | ||
2 | From: Jean Delvare <jdelvare@suse.de> | ||
3 | Date: Thu, 3 May 2018 14:31:55 +0200 | ||
4 | Subject: [PATCH 1/2] Don't leak temporary file on failed ed-style patch | ||
5 | |||
6 | Now that we write ed-style patches to a temporary file before we | ||
7 | apply them, we need to ensure that the temporary file is removed | ||
8 | before we leave, even on fatal error. | ||
9 | |||
10 | * src/pch.c (do_ed_script): Use global TMPEDNAME instead of local | ||
11 | tmpname. Don't unlink the file directly, instead tag it for removal | ||
12 | at exit time. | ||
13 | * src/patch.c (cleanup): Unlink TMPEDNAME at exit. | ||
14 | |||
15 | This closes bug #53820: | ||
16 | https://savannah.gnu.org/bugs/index.php?53820 | ||
17 | |||
18 | Fixes: 123eaff0d5d1 ("Fix arbitrary command execution in ed-style patches (CVE-2018-1000156)") | ||
19 | |||
20 | CVE: CVE-2018-1000156 | ||
21 | Upstream-Status: Backport [http://git.savannah.gnu.org/cgit/patch.git/commit/?id=19599883ffb6a450d2884f081f8ecf68edbed7ee] | ||
22 | Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> | ||
23 | --- | ||
24 | src/common.h | 2 ++ | ||
25 | src/pch.c | 12 +++++------- | ||
26 | 2 files changed, 7 insertions(+), 7 deletions(-) | ||
27 | |||
28 | diff --git a/src/common.h b/src/common.h | ||
29 | index ec50b40..22238b5 100644 | ||
30 | --- a/src/common.h | ||
31 | +++ b/src/common.h | ||
32 | @@ -94,10 +94,12 @@ XTERN char const *origsuff; | ||
33 | XTERN char const * TMPINNAME; | ||
34 | XTERN char const * TMPOUTNAME; | ||
35 | XTERN char const * TMPPATNAME; | ||
36 | +XTERN char const * TMPEDNAME; | ||
37 | |||
38 | XTERN bool TMPINNAME_needs_removal; | ||
39 | XTERN bool TMPOUTNAME_needs_removal; | ||
40 | XTERN bool TMPPATNAME_needs_removal; | ||
41 | +XTERN bool TMPEDNAME_needs_removal; | ||
42 | |||
43 | #ifdef DEBUGGING | ||
44 | XTERN int debug; | ||
45 | diff --git a/src/pch.c b/src/pch.c | ||
46 | index 16e001a..c1a62cf 100644 | ||
47 | --- a/src/pch.c | ||
48 | +++ b/src/pch.c | ||
49 | @@ -2392,7 +2392,6 @@ do_ed_script (char const *inname, char const *outname, | ||
50 | file_offset beginning_of_this_line; | ||
51 | size_t chars_read; | ||
52 | FILE *tmpfp = 0; | ||
53 | - char const *tmpname; | ||
54 | int tmpfd; | ||
55 | pid_t pid; | ||
56 | |||
57 | @@ -2404,12 +2403,13 @@ do_ed_script (char const *inname, char const *outname, | ||
58 | invalid commands and treats the next line as a new command, which | ||
59 | can lead to arbitrary command execution. */ | ||
60 | |||
61 | - tmpfd = make_tempfile (&tmpname, 'e', NULL, O_RDWR | O_BINARY, 0); | ||
62 | + tmpfd = make_tempfile (&TMPEDNAME, 'e', NULL, O_RDWR | O_BINARY, 0); | ||
63 | if (tmpfd == -1) | ||
64 | - pfatal ("Can't create temporary file %s", quotearg (tmpname)); | ||
65 | + pfatal ("Can't create temporary file %s", quotearg (TMPEDNAME)); | ||
66 | + TMPEDNAME_needs_removal = true; | ||
67 | tmpfp = fdopen (tmpfd, "w+b"); | ||
68 | if (! tmpfp) | ||
69 | - pfatal ("Can't open stream for file %s", quotearg (tmpname)); | ||
70 | + pfatal ("Can't open stream for file %s", quotearg (TMPEDNAME)); | ||
71 | } | ||
72 | |||
73 | for (;;) { | ||
74 | @@ -2449,8 +2449,7 @@ do_ed_script (char const *inname, char const *outname, | ||
75 | write_fatal (); | ||
76 | |||
77 | if (lseek (tmpfd, 0, SEEK_SET) == -1) | ||
78 | - pfatal ("Can't rewind to the beginning of file %s", quotearg (tmpname)); | ||
79 | - | ||
80 | + pfatal ("Can't rewind to the beginning of file %s", quotearg (TMPEDNAME)); | ||
81 | if (! dry_run && ! skip_rest_of_patch) { | ||
82 | int exclusive = *outname_needs_removal ? 0 : O_EXCL; | ||
83 | *outname_needs_removal = true; | ||
84 | @@ -2482,7 +2481,6 @@ do_ed_script (char const *inname, char const *outname, | ||
85 | } | ||
86 | |||
87 | fclose (tmpfp); | ||
88 | - safe_unlink (tmpname); | ||
89 | |||
90 | if (ofp) | ||
91 | { | ||
92 | -- | ||
93 | 2.17.0 | ||
94 | |||
diff --git a/meta/recipes-devtools/patch/patch/0001-Don-t-leak-temporary-file-on-failed-multi-file-ed.patch b/meta/recipes-devtools/patch/patch/0001-Don-t-leak-temporary-file-on-failed-multi-file-ed.patch deleted file mode 100644 index 8ffffef47e..0000000000 --- a/meta/recipes-devtools/patch/patch/0001-Don-t-leak-temporary-file-on-failed-multi-file-ed.patch +++ /dev/null | |||
@@ -1,81 +0,0 @@ | |||
1 | From 369dcccdfa6336e5a873d6d63705cfbe04c55727 Mon Sep 17 00:00:00 2001 | ||
2 | From: Jean Delvare <jdelvare@suse.de> | ||
3 | Date: Mon, 7 May 2018 15:14:45 +0200 | ||
4 | Subject: Don't leak temporary file on failed multi-file ed-style patch | ||
5 | |||
6 | The previous fix worked fine with single-file ed-style patches, but | ||
7 | would still leak temporary files in the case of multi-file ed-style | ||
8 | patch. Fix that case as well, and extend the test case to check for | ||
9 | it. | ||
10 | |||
11 | * src/patch.c (main): Unlink TMPEDNAME if needed before moving to | ||
12 | the next file in a patch. | ||
13 | |||
14 | This closes bug #53820: | ||
15 | https://savannah.gnu.org/bugs/index.php?53820 | ||
16 | |||
17 | Fixes: 123eaff0d5d1 ("Fix arbitrary command execution in ed-style patches (CVE-2018-1000156)") | ||
18 | Fixes: 19599883ffb6 ("Don't leak temporary file on failed ed-style patch") | ||
19 | |||
20 | CVE: CVE-2018-1000156 | ||
21 | Upstream-Status: Backport [http://git.savannah.gnu.org/cgit/patch.git/commit/?id=369dcccdfa6336e5a873d6d63705cfbe04c55727] | ||
22 | Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> | ||
23 | --- | ||
24 | src/patch.c | 1 + | ||
25 | tests/ed-style | 31 +++++++++++++++++++++++++++++++ | ||
26 | 2 files changed, 32 insertions(+) | ||
27 | |||
28 | diff --git a/src/patch.c b/src/patch.c | ||
29 | index 9146597..81c7a02 100644 | ||
30 | --- a/src/patch.c | ||
31 | +++ b/src/patch.c | ||
32 | @@ -236,6 +236,7 @@ main (int argc, char **argv) | ||
33 | } | ||
34 | remove_if_needed (TMPOUTNAME, &TMPOUTNAME_needs_removal); | ||
35 | } | ||
36 | + remove_if_needed (TMPEDNAME, &TMPEDNAME_needs_removal); | ||
37 | |||
38 | if (! skip_rest_of_patch && ! file_type) | ||
39 | { | ||
40 | diff --git a/tests/ed-style b/tests/ed-style | ||
41 | index 6b6ef9d..504e6e5 100644 | ||
42 | --- a/tests/ed-style | ||
43 | +++ b/tests/ed-style | ||
44 | @@ -38,3 +38,34 @@ EOF | ||
45 | check 'cat foo' <<EOF | ||
46 | foo | ||
47 | EOF | ||
48 | + | ||
49 | +# Test the case where one ed-style patch modifies several files | ||
50 | + | ||
51 | +cat > ed3.diff <<EOF | ||
52 | +--- foo | ||
53 | ++++ foo | ||
54 | +1c | ||
55 | +bar | ||
56 | +. | ||
57 | +--- baz | ||
58 | ++++ baz | ||
59 | +0a | ||
60 | +baz | ||
61 | +. | ||
62 | +EOF | ||
63 | + | ||
64 | +# Apparently we can't create a file with such a patch, while it works fine | ||
65 | +# when the file name is provided on the command line | ||
66 | +cat > baz <<EOF | ||
67 | +EOF | ||
68 | + | ||
69 | +check 'patch -e -i ed3.diff' <<EOF | ||
70 | +EOF | ||
71 | + | ||
72 | +check 'cat foo' <<EOF | ||
73 | +bar | ||
74 | +EOF | ||
75 | + | ||
76 | +check 'cat baz' <<EOF | ||
77 | +baz | ||
78 | +EOF | ||
79 | -- | ||
80 | cgit v1.0-41-gc330 | ||
81 | |||
diff --git a/meta/recipes-devtools/patch/patch/0001-Fix-swapping-fake-lines-in-pch_swap.patch b/meta/recipes-devtools/patch/patch/0001-Fix-swapping-fake-lines-in-pch_swap.patch deleted file mode 100644 index 049149eb9e..0000000000 --- a/meta/recipes-devtools/patch/patch/0001-Fix-swapping-fake-lines-in-pch_swap.patch +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
1 | From 9c986353e420ead6e706262bf204d6e03322c300 Mon Sep 17 00:00:00 2001 | ||
2 | From: Andreas Gruenbacher <agruen@gnu.org> | ||
3 | Date: Fri, 17 Aug 2018 13:35:40 +0200 | ||
4 | Subject: [PATCH] Fix swapping fake lines in pch_swap | ||
5 | |||
6 | * src/pch.c (pch_swap): Fix swapping p_bfake and p_efake when there is a | ||
7 | blank line in the middle of a context-diff hunk: that empty line stays | ||
8 | in the middle of the hunk and isn't swapped. | ||
9 | |||
10 | Fixes: https://savannah.gnu.org/bugs/index.php?53133 | ||
11 | Signed-off-by: Andreas Gruenbacher <agruen@gnu.org> | ||
12 | |||
13 | Upstream-Status: Backport [https://git.savannah.gnu.org/git/patch.git] | ||
14 | CVE: CVE-2018-6952 | ||
15 | Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> | ||
16 | |||
17 | --- | ||
18 | src/pch.c | 2 +- | ||
19 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
20 | |||
21 | diff --git a/src/pch.c b/src/pch.c | ||
22 | index e92bc64..a500ad9 100644 | ||
23 | --- a/src/pch.c | ||
24 | +++ b/src/pch.c | ||
25 | @@ -2122,7 +2122,7 @@ pch_swap (void) | ||
26 | } | ||
27 | if (p_efake >= 0) { /* fix non-freeable ptr range */ | ||
28 | if (p_efake <= i) | ||
29 | - n = p_end - i + 1; | ||
30 | + n = p_end - p_ptrn_lines; | ||
31 | else | ||
32 | n = -i; | ||
33 | p_efake += n; | ||
34 | -- | ||
35 | 2.10.2 | ||
36 | |||
diff --git a/meta/recipes-devtools/patch/patch/0001-Invoke-ed-directly-instead-of-using-the-shell.patch b/meta/recipes-devtools/patch/patch/0001-Invoke-ed-directly-instead-of-using-the-shell.patch deleted file mode 100644 index d13d419f51..0000000000 --- a/meta/recipes-devtools/patch/patch/0001-Invoke-ed-directly-instead-of-using-the-shell.patch +++ /dev/null | |||
@@ -1,44 +0,0 @@ | |||
1 | From 3fcd042d26d70856e826a42b5f93dc4854d80bf0 Mon Sep 17 00:00:00 2001 | ||
2 | From: Andreas Gruenbacher <agruen@gnu.org> | ||
3 | Date: Fri, 6 Apr 2018 19:36:15 +0200 | ||
4 | Subject: [PATCH] Invoke ed directly instead of using the shell | ||
5 | |||
6 | * src/pch.c (do_ed_script): Invoke ed directly instead of using a shell | ||
7 | command to avoid quoting vulnerabilities. | ||
8 | |||
9 | CVE: CVE-2019-13638 CVE-2018-20969 | ||
10 | Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/patch.git/patch/?id=3fcd042d26d70856e826a42b5f93dc4854d80bf0] | ||
11 | Signed-off-by: Trevor Gamblin <trevor.gamblin@windriver.com> | ||
12 | |||
13 | --- | ||
14 | src/pch.c | 6 ++---- | ||
15 | 1 file changed, 2 insertions(+), 4 deletions(-) | ||
16 | |||
17 | |||
18 | diff --git a/src/pch.c b/src/pch.c | ||
19 | index 4fd5a05..16e001a 100644 | ||
20 | --- a/src/pch.c | ||
21 | +++ b/src/pch.c | ||
22 | @@ -2459,9 +2459,6 @@ do_ed_script (char const *inname, char const *outname, | ||
23 | *outname_needs_removal = true; | ||
24 | copy_file (inname, outname, 0, exclusive, instat.st_mode, true); | ||
25 | } | ||
26 | - sprintf (buf, "%s %s%s", editor_program, | ||
27 | - verbosity == VERBOSE ? "" : "- ", | ||
28 | - outname); | ||
29 | fflush (stdout); | ||
30 | |||
31 | pid = fork(); | ||
32 | @@ -2470,7 +2467,8 @@ do_ed_script (char const *inname, char const *outname, | ||
33 | else if (pid == 0) | ||
34 | { | ||
35 | dup2 (tmpfd, 0); | ||
36 | - execl ("/bin/sh", "sh", "-c", buf, (char *) 0); | ||
37 | + assert (outname[0] != '!' && outname[0] != '-'); | ||
38 | + execlp (editor_program, editor_program, "-", outname, (char *) NULL); | ||
39 | _exit (2); | ||
40 | } | ||
41 | else | ||
42 | -- | ||
43 | 2.7.4 | ||
44 | |||
diff --git a/meta/recipes-devtools/patch/patch/0001-Unset-need_charset_alias-when-building-for-musl.patch b/meta/recipes-devtools/patch/patch/0001-Unset-need_charset_alias-when-building-for-musl.patch deleted file mode 100644 index ba1a4bab4c..0000000000 --- a/meta/recipes-devtools/patch/patch/0001-Unset-need_charset_alias-when-building-for-musl.patch +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | From b9565dc2fe0c4f7daaec91b7e83bc7313dee2f4a Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Mon, 13 Apr 2015 17:02:13 -0700 | ||
4 | Subject: [PATCH] Unset need_charset_alias when building for musl | ||
5 | |||
6 | localcharset uses ac_cv_gnu_library_2_1 from glibc21.m4 | ||
7 | which actually shoudl be fixed in gnulib and then all downstream | ||
8 | projects will get it eventually. For now we apply the fix to | ||
9 | coreutils | ||
10 | |||
11 | Upstream-Status: Pending | ||
12 | |||
13 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
14 | --- | ||
15 | lib/gnulib.mk | 2 +- | ||
16 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
17 | |||
18 | diff --git a/lib/gnulib.mk b/lib/gnulib.mk | ||
19 | index e1d74db..c0e92dd 100644 | ||
20 | --- a/lib/gnulib.mk | ||
21 | +++ b/lib/gnulib.mk | ||
22 | @@ -1882,7 +1882,7 @@ install-exec-localcharset: all-local | ||
23 | case '$(host_os)' in \ | ||
24 | darwin[56]*) \ | ||
25 | need_charset_alias=true ;; \ | ||
26 | - darwin* | cygwin* | mingw* | pw32* | cegcc*) \ | ||
27 | + darwin* | cygwin* | mingw* | pw32* | cegcc* | linux-musl*) \ | ||
28 | need_charset_alias=false ;; \ | ||
29 | *) \ | ||
30 | need_charset_alias=true ;; \ | ||
31 | -- | ||
32 | 2.1.4 | ||
33 | |||
diff --git a/meta/recipes-devtools/patch/patch/0002-Fix-segfault-with-mangled-rename-patch.patch b/meta/recipes-devtools/patch/patch/0002-Fix-segfault-with-mangled-rename-patch.patch deleted file mode 100644 index b0bd6fa83a..0000000000 --- a/meta/recipes-devtools/patch/patch/0002-Fix-segfault-with-mangled-rename-patch.patch +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
1 | From f290f48a621867084884bfff87f8093c15195e6a Mon Sep 17 00:00:00 2001 | ||
2 | From: Andreas Gruenbacher <agruen@gnu.org> | ||
3 | Date: Mon, 12 Feb 2018 16:48:24 +0100 | ||
4 | Subject: [PATCH] Fix segfault with mangled rename patch | ||
5 | |||
6 | http://savannah.gnu.org/bugs/?53132 | ||
7 | * src/pch.c (intuit_diff_type): Ensure that two filenames are specified | ||
8 | for renames and copies (fix the existing check). | ||
9 | |||
10 | Upstream-Status: Backport [http://git.savannah.gnu.org/cgit/patch.git/commit/?id=f290f48a621867084884bfff87f8093c15195e6a] | ||
11 | CVE: CVE-2018-6951 | ||
12 | |||
13 | Signed-off-by: Jackie Huang <jackie.huang@windriver.com> | ||
14 | |||
15 | --- | ||
16 | src/pch.c | 3 ++- | ||
17 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
18 | |||
19 | diff --git a/src/pch.c b/src/pch.c | ||
20 | index ff9ed2c..bc6278c 100644 | ||
21 | --- a/src/pch.c | ||
22 | +++ b/src/pch.c | ||
23 | @@ -974,7 +974,8 @@ intuit_diff_type (bool need_header, mode_t *p_file_type) | ||
24 | if ((pch_rename () || pch_copy ()) | ||
25 | && ! inname | ||
26 | && ! ((i == OLD || i == NEW) && | ||
27 | - p_name[! reverse] && | ||
28 | + p_name[reverse] && p_name[! reverse] && | ||
29 | + name_is_valid (p_name[reverse]) && | ||
30 | name_is_valid (p_name[! reverse]))) | ||
31 | { | ||
32 | say ("Cannot %s file without two valid file names\n", pch_rename () ? "rename" : "copy"); | ||
33 | -- | ||
34 | 2.7.4 | ||
35 | |||
diff --git a/meta/recipes-devtools/patch/patch/0003-Allow-input-files-to-be-missing-for-ed-style-patches.patch b/meta/recipes-devtools/patch/patch/0003-Allow-input-files-to-be-missing-for-ed-style-patches.patch deleted file mode 100644 index 2a09d0c03b..0000000000 --- a/meta/recipes-devtools/patch/patch/0003-Allow-input-files-to-be-missing-for-ed-style-patches.patch +++ /dev/null | |||
@@ -1,38 +0,0 @@ | |||
1 | From b5a91a01e5d0897facdd0f49d64b76b0f02b43e1 Mon Sep 17 00:00:00 2001 | ||
2 | From: Andreas Gruenbacher <agruen@gnu.org> | ||
3 | Date: Fri, 6 Apr 2018 11:34:51 +0200 | ||
4 | Subject: [PATCH] Allow input files to be missing for ed-style patches | ||
5 | |||
6 | * src/pch.c (do_ed_script): Allow input files to be missing so that new | ||
7 | files will be created as with non-ed-style patches. | ||
8 | |||
9 | Upstream-Status: Backport [http://git.savannah.gnu.org/cgit/patch.git/commit/?id=b5a91a01e5d0897facdd0f49d64b76b0f02b43e1] | ||
10 | CVE: CVE-2018-1000156 | ||
11 | |||
12 | Signed-off-by: Jackie Huang <jackie.huang@windriver.com> | ||
13 | --- | ||
14 | src/pch.c | 8 +++++--- | ||
15 | 1 file changed, 5 insertions(+), 3 deletions(-) | ||
16 | |||
17 | diff --git a/src/pch.c b/src/pch.c | ||
18 | index bc6278c..0c5cc26 100644 | ||
19 | --- a/src/pch.c | ||
20 | +++ b/src/pch.c | ||
21 | @@ -2394,9 +2394,11 @@ do_ed_script (char const *inname, char const *outname, | ||
22 | |||
23 | if (! dry_run && ! skip_rest_of_patch) { | ||
24 | int exclusive = *outname_needs_removal ? 0 : O_EXCL; | ||
25 | - assert (! inerrno); | ||
26 | - *outname_needs_removal = true; | ||
27 | - copy_file (inname, outname, 0, exclusive, instat.st_mode, true); | ||
28 | + if (inerrno != ENOENT) | ||
29 | + { | ||
30 | + *outname_needs_removal = true; | ||
31 | + copy_file (inname, outname, 0, exclusive, instat.st_mode, true); | ||
32 | + } | ||
33 | sprintf (buf, "%s %s%s", editor_program, | ||
34 | verbosity == VERBOSE ? "" : "- ", | ||
35 | outname); | ||
36 | -- | ||
37 | 2.7.4 | ||
38 | |||
diff --git a/meta/recipes-devtools/patch/patch/0004-Fix-arbitrary-command-execution-in-ed-style-patches-.patch b/meta/recipes-devtools/patch/patch/0004-Fix-arbitrary-command-execution-in-ed-style-patches-.patch deleted file mode 100644 index d74c2f182e..0000000000 --- a/meta/recipes-devtools/patch/patch/0004-Fix-arbitrary-command-execution-in-ed-style-patches-.patch +++ /dev/null | |||
@@ -1,215 +0,0 @@ | |||
1 | From 123eaff0d5d1aebe128295959435b9ca5909c26d Mon Sep 17 00:00:00 2001 | ||
2 | From: Andreas Gruenbacher <agruen@gnu.org> | ||
3 | Date: Fri, 6 Apr 2018 12:14:49 +0200 | ||
4 | Subject: [PATCH] Fix arbitrary command execution in ed-style patches (CVE-2018-1000156) | ||
5 | |||
6 | * src/pch.c (do_ed_script): Write ed script to a temporary file instead | ||
7 | of piping it to ed: this will cause ed to abort on invalid commands | ||
8 | instead of rejecting them and carrying on. | ||
9 | * tests/ed-style: New test case. | ||
10 | * tests/Makefile.am (TESTS): Add test case. | ||
11 | |||
12 | Upstream-Status: Backport [http://git.savannah.gnu.org/cgit/patch.git/commit/?id=123eaff0d5d1aebe128295959435b9ca5909c26d] | ||
13 | CVE: CVE-2018-1000156 | ||
14 | |||
15 | Signed-off-by: Jackie Huang <jackie.huang@windriver.com> | ||
16 | --- | ||
17 | src/pch.c | 91 ++++++++++++++++++++++++++++++++++++++++--------------- | ||
18 | tests/Makefile.am | 1 + | ||
19 | tests/ed-style | 41 +++++++++++++++++++++++++ | ||
20 | 3 files changed, 108 insertions(+), 25 deletions(-) | ||
21 | create mode 100644 tests/ed-style | ||
22 | |||
23 | diff --git a/src/pch.c b/src/pch.c | ||
24 | index 0c5cc26..4fd5a05 100644 | ||
25 | --- a/src/pch.c | ||
26 | +++ b/src/pch.c | ||
27 | @@ -33,6 +33,7 @@ | ||
28 | # include <io.h> | ||
29 | #endif | ||
30 | #include <safe.h> | ||
31 | +#include <sys/wait.h> | ||
32 | |||
33 | #define INITHUNKMAX 125 /* initial dynamic allocation size */ | ||
34 | |||
35 | @@ -2389,24 +2390,28 @@ do_ed_script (char const *inname, char const *outname, | ||
36 | static char const editor_program[] = EDITOR_PROGRAM; | ||
37 | |||
38 | file_offset beginning_of_this_line; | ||
39 | - FILE *pipefp = 0; | ||
40 | size_t chars_read; | ||
41 | + FILE *tmpfp = 0; | ||
42 | + char const *tmpname; | ||
43 | + int tmpfd; | ||
44 | + pid_t pid; | ||
45 | + | ||
46 | + if (! dry_run && ! skip_rest_of_patch) | ||
47 | + { | ||
48 | + /* Write ed script to a temporary file. This causes ed to abort on | ||
49 | + invalid commands such as when line numbers or ranges exceed the | ||
50 | + number of available lines. When ed reads from a pipe, it rejects | ||
51 | + invalid commands and treats the next line as a new command, which | ||
52 | + can lead to arbitrary command execution. */ | ||
53 | + | ||
54 | + tmpfd = make_tempfile (&tmpname, 'e', NULL, O_RDWR | O_BINARY, 0); | ||
55 | + if (tmpfd == -1) | ||
56 | + pfatal ("Can't create temporary file %s", quotearg (tmpname)); | ||
57 | + tmpfp = fdopen (tmpfd, "w+b"); | ||
58 | + if (! tmpfp) | ||
59 | + pfatal ("Can't open stream for file %s", quotearg (tmpname)); | ||
60 | + } | ||
61 | |||
62 | - if (! dry_run && ! skip_rest_of_patch) { | ||
63 | - int exclusive = *outname_needs_removal ? 0 : O_EXCL; | ||
64 | - if (inerrno != ENOENT) | ||
65 | - { | ||
66 | - *outname_needs_removal = true; | ||
67 | - copy_file (inname, outname, 0, exclusive, instat.st_mode, true); | ||
68 | - } | ||
69 | - sprintf (buf, "%s %s%s", editor_program, | ||
70 | - verbosity == VERBOSE ? "" : "- ", | ||
71 | - outname); | ||
72 | - fflush (stdout); | ||
73 | - pipefp = popen(buf, binary_transput ? "wb" : "w"); | ||
74 | - if (!pipefp) | ||
75 | - pfatal ("Can't open pipe to %s", quotearg (buf)); | ||
76 | - } | ||
77 | for (;;) { | ||
78 | char ed_command_letter; | ||
79 | beginning_of_this_line = file_tell (pfp); | ||
80 | @@ -2417,14 +2422,14 @@ do_ed_script (char const *inname, char const *outname, | ||
81 | } | ||
82 | ed_command_letter = get_ed_command_letter (buf); | ||
83 | if (ed_command_letter) { | ||
84 | - if (pipefp) | ||
85 | - if (! fwrite (buf, sizeof *buf, chars_read, pipefp)) | ||
86 | + if (tmpfp) | ||
87 | + if (! fwrite (buf, sizeof *buf, chars_read, tmpfp)) | ||
88 | write_fatal (); | ||
89 | if (ed_command_letter != 'd' && ed_command_letter != 's') { | ||
90 | p_pass_comments_through = true; | ||
91 | while ((chars_read = get_line ()) != 0) { | ||
92 | - if (pipefp) | ||
93 | - if (! fwrite (buf, sizeof *buf, chars_read, pipefp)) | ||
94 | + if (tmpfp) | ||
95 | + if (! fwrite (buf, sizeof *buf, chars_read, tmpfp)) | ||
96 | write_fatal (); | ||
97 | if (chars_read == 2 && strEQ (buf, ".\n")) | ||
98 | break; | ||
99 | @@ -2437,13 +2442,49 @@ do_ed_script (char const *inname, char const *outname, | ||
100 | break; | ||
101 | } | ||
102 | } | ||
103 | - if (!pipefp) | ||
104 | + if (!tmpfp) | ||
105 | return; | ||
106 | - if (fwrite ("w\nq\n", sizeof (char), (size_t) 4, pipefp) == 0 | ||
107 | - || fflush (pipefp) != 0) | ||
108 | + if (fwrite ("w\nq\n", sizeof (char), (size_t) 4, tmpfp) == 0 | ||
109 | + || fflush (tmpfp) != 0) | ||
110 | write_fatal (); | ||
111 | - if (pclose (pipefp) != 0) | ||
112 | - fatal ("%s FAILED", editor_program); | ||
113 | + | ||
114 | + if (lseek (tmpfd, 0, SEEK_SET) == -1) | ||
115 | + pfatal ("Can't rewind to the beginning of file %s", quotearg (tmpname)); | ||
116 | + | ||
117 | + if (! dry_run && ! skip_rest_of_patch) { | ||
118 | + int exclusive = *outname_needs_removal ? 0 : O_EXCL; | ||
119 | + *outname_needs_removal = true; | ||
120 | + if (inerrno != ENOENT) | ||
121 | + { | ||
122 | + *outname_needs_removal = true; | ||
123 | + copy_file (inname, outname, 0, exclusive, instat.st_mode, true); | ||
124 | + } | ||
125 | + sprintf (buf, "%s %s%s", editor_program, | ||
126 | + verbosity == VERBOSE ? "" : "- ", | ||
127 | + outname); | ||
128 | + fflush (stdout); | ||
129 | + | ||
130 | + pid = fork(); | ||
131 | + if (pid == -1) | ||
132 | + pfatal ("Can't fork"); | ||
133 | + else if (pid == 0) | ||
134 | + { | ||
135 | + dup2 (tmpfd, 0); | ||
136 | + execl ("/bin/sh", "sh", "-c", buf, (char *) 0); | ||
137 | + _exit (2); | ||
138 | + } | ||
139 | + else | ||
140 | + { | ||
141 | + int wstatus; | ||
142 | + if (waitpid (pid, &wstatus, 0) == -1 | ||
143 | + || ! WIFEXITED (wstatus) | ||
144 | + || WEXITSTATUS (wstatus) != 0) | ||
145 | + fatal ("%s FAILED", editor_program); | ||
146 | + } | ||
147 | + } | ||
148 | + | ||
149 | + fclose (tmpfp); | ||
150 | + safe_unlink (tmpname); | ||
151 | |||
152 | if (ofp) | ||
153 | { | ||
154 | diff --git a/tests/Makefile.am b/tests/Makefile.am | ||
155 | index 6b6df63..16f8693 100644 | ||
156 | --- a/tests/Makefile.am | ||
157 | +++ b/tests/Makefile.am | ||
158 | @@ -32,6 +32,7 @@ TESTS = \ | ||
159 | crlf-handling \ | ||
160 | dash-o-append \ | ||
161 | deep-directories \ | ||
162 | + ed-style \ | ||
163 | empty-files \ | ||
164 | false-match \ | ||
165 | fifo \ | ||
166 | diff --git a/tests/ed-style b/tests/ed-style | ||
167 | new file mode 100644 | ||
168 | index 0000000..d8c0689 | ||
169 | --- /dev/null | ||
170 | +++ b/tests/ed-style | ||
171 | @@ -0,0 +1,41 @@ | ||
172 | +# Copyright (C) 2018 Free Software Foundation, Inc. | ||
173 | +# | ||
174 | +# Copying and distribution of this file, with or without modification, | ||
175 | +# in any medium, are permitted without royalty provided the copyright | ||
176 | +# notice and this notice are preserved. | ||
177 | + | ||
178 | +. $srcdir/test-lib.sh | ||
179 | + | ||
180 | +require cat | ||
181 | +use_local_patch | ||
182 | +use_tmpdir | ||
183 | + | ||
184 | +# ============================================================== | ||
185 | + | ||
186 | +cat > ed1.diff <<EOF | ||
187 | +0a | ||
188 | +foo | ||
189 | +. | ||
190 | +EOF | ||
191 | + | ||
192 | +check 'patch -e foo -i ed1.diff' <<EOF | ||
193 | +EOF | ||
194 | + | ||
195 | +check 'cat foo' <<EOF | ||
196 | +foo | ||
197 | +EOF | ||
198 | + | ||
199 | +cat > ed2.diff <<EOF | ||
200 | +1337a | ||
201 | +r !echo bar | ||
202 | +,p | ||
203 | +EOF | ||
204 | + | ||
205 | +check 'patch -e foo -i ed2.diff 2> /dev/null || echo "Status: $?"' <<EOF | ||
206 | +? | ||
207 | +Status: 2 | ||
208 | +EOF | ||
209 | + | ||
210 | +check 'cat foo' <<EOF | ||
211 | +foo | ||
212 | +EOF | ||
213 | -- | ||
214 | 2.7.4 | ||
215 | |||
diff --git a/meta/recipes-devtools/patch/patch/CVE-2019-13636.patch b/meta/recipes-devtools/patch/patch/CVE-2019-13636.patch deleted file mode 100644 index 8059d9fe19..0000000000 --- a/meta/recipes-devtools/patch/patch/CVE-2019-13636.patch +++ /dev/null | |||
@@ -1,113 +0,0 @@ | |||
1 | From dce4683cbbe107a95f1f0d45fabc304acfb5d71a Mon Sep 17 00:00:00 2001 | ||
2 | From: Andreas Gruenbacher <agruen@gnu.org> | ||
3 | Date: Mon, 15 Jul 2019 16:21:48 +0200 | ||
4 | Subject: Don't follow symlinks unless --follow-symlinks is given | ||
5 | |||
6 | * src/inp.c (plan_a, plan_b), src/util.c (copy_to_fd, copy_file, | ||
7 | append_to_file): Unless the --follow-symlinks option is given, open files with | ||
8 | the O_NOFOLLOW flag to avoid following symlinks. So far, we were only doing | ||
9 | that consistently for input files. | ||
10 | * src/util.c (create_backup): When creating empty backup files, (re)create them | ||
11 | with O_CREAT | O_EXCL to avoid following symlinks in that case as well. | ||
12 | |||
13 | CVE: CVE-2019-13636 | ||
14 | Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/patch.git/patch/?id=dce4683cbbe107a95f1f0d45fabc304acfb5d71a] | ||
15 | Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> | ||
16 | |||
17 | --- | ||
18 | src/inp.c | 12 ++++++++++-- | ||
19 | src/util.c | 14 +++++++++++--- | ||
20 | 2 files changed, 21 insertions(+), 5 deletions(-) | ||
21 | |||
22 | diff --git a/src/inp.c b/src/inp.c | ||
23 | index 32d0919..22d7473 100644 | ||
24 | --- a/src/inp.c | ||
25 | +++ b/src/inp.c | ||
26 | @@ -238,8 +238,13 @@ plan_a (char const *filename) | ||
27 | { | ||
28 | if (S_ISREG (instat.st_mode)) | ||
29 | { | ||
30 | - int ifd = safe_open (filename, O_RDONLY|binary_transput, 0); | ||
31 | + int flags = O_RDONLY | binary_transput; | ||
32 | size_t buffered = 0, n; | ||
33 | + int ifd; | ||
34 | + | ||
35 | + if (! follow_symlinks) | ||
36 | + flags |= O_NOFOLLOW; | ||
37 | + ifd = safe_open (filename, flags, 0); | ||
38 | if (ifd < 0) | ||
39 | pfatal ("can't open file %s", quotearg (filename)); | ||
40 | |||
41 | @@ -340,6 +345,7 @@ plan_a (char const *filename) | ||
42 | static void | ||
43 | plan_b (char const *filename) | ||
44 | { | ||
45 | + int flags = O_RDONLY | binary_transput; | ||
46 | int ifd; | ||
47 | FILE *ifp; | ||
48 | int c; | ||
49 | @@ -353,7 +359,9 @@ plan_b (char const *filename) | ||
50 | |||
51 | if (instat.st_size == 0) | ||
52 | filename = NULL_DEVICE; | ||
53 | - if ((ifd = safe_open (filename, O_RDONLY | binary_transput, 0)) < 0 | ||
54 | + if (! follow_symlinks) | ||
55 | + flags |= O_NOFOLLOW; | ||
56 | + if ((ifd = safe_open (filename, flags, 0)) < 0 | ||
57 | || ! (ifp = fdopen (ifd, binary_transput ? "rb" : "r"))) | ||
58 | pfatal ("Can't open file %s", quotearg (filename)); | ||
59 | if (TMPINNAME_needs_removal) | ||
60 | diff --git a/src/util.c b/src/util.c | ||
61 | index 1cc08ba..fb38307 100644 | ||
62 | --- a/src/util.c | ||
63 | +++ b/src/util.c | ||
64 | @@ -388,7 +388,7 @@ create_backup (char const *to, const struct stat *to_st, bool leave_original) | ||
65 | |||
66 | try_makedirs_errno = ENOENT; | ||
67 | safe_unlink (bakname); | ||
68 | - while ((fd = safe_open (bakname, O_CREAT | O_WRONLY | O_TRUNC, 0666)) < 0) | ||
69 | + while ((fd = safe_open (bakname, O_CREAT | O_EXCL | O_WRONLY | O_TRUNC, 0666)) < 0) | ||
70 | { | ||
71 | if (errno != try_makedirs_errno) | ||
72 | pfatal ("Can't create file %s", quotearg (bakname)); | ||
73 | @@ -579,10 +579,13 @@ create_file (char const *file, int open_flags, mode_t mode, | ||
74 | static void | ||
75 | copy_to_fd (const char *from, int tofd) | ||
76 | { | ||
77 | + int from_flags = O_RDONLY | O_BINARY; | ||
78 | int fromfd; | ||
79 | ssize_t i; | ||
80 | |||
81 | - if ((fromfd = safe_open (from, O_RDONLY | O_BINARY, 0)) < 0) | ||
82 | + if (! follow_symlinks) | ||
83 | + from_flags |= O_NOFOLLOW; | ||
84 | + if ((fromfd = safe_open (from, from_flags, 0)) < 0) | ||
85 | pfatal ("Can't reopen file %s", quotearg (from)); | ||
86 | while ((i = read (fromfd, buf, bufsize)) != 0) | ||
87 | { | ||
88 | @@ -625,6 +628,8 @@ copy_file (char const *from, char const *to, struct stat *tost, | ||
89 | else | ||
90 | { | ||
91 | assert (S_ISREG (mode)); | ||
92 | + if (! follow_symlinks) | ||
93 | + to_flags |= O_NOFOLLOW; | ||
94 | tofd = create_file (to, O_WRONLY | O_BINARY | to_flags, mode, | ||
95 | to_dir_known_to_exist); | ||
96 | copy_to_fd (from, tofd); | ||
97 | @@ -640,9 +645,12 @@ copy_file (char const *from, char const *to, struct stat *tost, | ||
98 | void | ||
99 | append_to_file (char const *from, char const *to) | ||
100 | { | ||
101 | + int to_flags = O_WRONLY | O_APPEND | O_BINARY; | ||
102 | int tofd; | ||
103 | |||
104 | - if ((tofd = safe_open (to, O_WRONLY | O_BINARY | O_APPEND, 0)) < 0) | ||
105 | + if (! follow_symlinks) | ||
106 | + to_flags |= O_NOFOLLOW; | ||
107 | + if ((tofd = safe_open (to, to_flags, 0)) < 0) | ||
108 | pfatal ("Can't reopen file %s", quotearg (to)); | ||
109 | copy_to_fd (from, tofd); | ||
110 | if (close (tofd) != 0) | ||
111 | -- | ||
112 | cgit v1.0-41-gc330 | ||
113 | |||
diff --git a/meta/recipes-devtools/patch/patch/CVE-2019-20633.patch b/meta/recipes-devtools/patch/patch/CVE-2019-20633.patch deleted file mode 100644 index 9b2c07cf1e..0000000000 --- a/meta/recipes-devtools/patch/patch/CVE-2019-20633.patch +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | From 15b158db3ae11cb835f2eb8d2eb48e09d1a4af48 Mon Sep 17 00:00:00 2001 | ||
2 | From: Andreas Gruenbacher <agruen@gnu.org> | ||
3 | Date: Mon, 15 Jul 2019 19:10:02 +0200 | ||
4 | Subject: Avoid invalid memory access in context format diffs | ||
5 | |||
6 | * src/pch.c (another_hunk): Avoid invalid memory access in context format | ||
7 | diffs. | ||
8 | |||
9 | CVE: CVE-2019-20633 | ||
10 | Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/patch.git/patch/?id=15b158db3ae11cb835f2eb8d2eb48e09d1a4af48] | ||
11 | Signed-off-by: Scott Murray <scott.murray@konsulko.com> | ||
12 | |||
13 | --- | ||
14 | src/pch.c | 1 + | ||
15 | 1 file changed, 1 insertion(+) | ||
16 | |||
17 | diff --git a/src/pch.c b/src/pch.c | ||
18 | index a500ad9..cb54e03 100644 | ||
19 | --- a/src/pch.c | ||
20 | +++ b/src/pch.c | ||
21 | @@ -1328,6 +1328,7 @@ another_hunk (enum diff difftype, bool rev) | ||
22 | ptrn_prefix_context = context; | ||
23 | ptrn_suffix_context = context; | ||
24 | if (repl_beginning | ||
25 | + || p_end <= 0 | ||
26 | || (p_end | ||
27 | != p_ptrn_lines + 1 + (p_Char[p_end - 1] == '\n'))) | ||
28 | { | ||
29 | -- | ||
30 | cgit v1.2.1 | ||
31 | |||
diff --git a/meta/recipes-devtools/patch/patch_2.7.6.bb b/meta/recipes-devtools/patch/patch_2.7.6.bb deleted file mode 100644 index 3dc3b5863c..0000000000 --- a/meta/recipes-devtools/patch/patch_2.7.6.bb +++ /dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | require patch.inc | ||
2 | LICENSE = "GPL-3.0-only" | ||
3 | |||
4 | SRC_URI += "file://0001-Unset-need_charset_alias-when-building-for-musl.patch \ | ||
5 | file://0002-Fix-segfault-with-mangled-rename-patch.patch \ | ||
6 | file://0003-Allow-input-files-to-be-missing-for-ed-style-patches.patch \ | ||
7 | file://0004-Fix-arbitrary-command-execution-in-ed-style-patches-.patch \ | ||
8 | file://0001-Fix-swapping-fake-lines-in-pch_swap.patch \ | ||
9 | file://CVE-2019-13636.patch \ | ||
10 | file://0001-Invoke-ed-directly-instead-of-using-the-shell.patch \ | ||
11 | file://0001-Don-t-leak-temporary-file-on-failed-ed-style-patch.patch \ | ||
12 | file://0001-Don-t-leak-temporary-file-on-failed-multi-file-ed.patch \ | ||
13 | file://CVE-2019-20633.patch \ | ||
14 | " | ||
15 | |||
16 | SRC_URI[sha256sum] = "8cf86e00ad3aaa6d26aca30640e86b0e3e1f395ed99f189b06d4c9f74bc58a4e" | ||
17 | |||
18 | LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504" | ||
19 | |||
20 | PACKAGECONFIG ?= "${@bb.utils.filter('DISTRO_FEATURES', 'xattr', d)}" | ||
21 | PACKAGECONFIG[xattr] = "--enable-xattr,--disable-xattr,attr," | ||
22 | |||
23 | PROVIDES:append:class-native = " patch-replacement-native" | ||
24 | |||
25 | BBCLASSEXTEND = "native nativesdk" | ||
diff --git a/meta/recipes-devtools/patch/patch_2.8.bb b/meta/recipes-devtools/patch/patch_2.8.bb new file mode 100644 index 0000000000..6317ac775d --- /dev/null +++ b/meta/recipes-devtools/patch/patch_2.8.bb | |||
@@ -0,0 +1,13 @@ | |||
1 | require patch.inc | ||
2 | LICENSE = "GPL-3.0-only" | ||
3 | |||
4 | SRC_URI[sha256sum] = "308a4983ff324521b9b21310bfc2398ca861798f02307c79eb99bb0e0d2bf980" | ||
5 | |||
6 | LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504" | ||
7 | |||
8 | PACKAGECONFIG ?= "${@bb.utils.filter('DISTRO_FEATURES', 'xattr', d)}" | ||
9 | PACKAGECONFIG[xattr] = "--enable-xattr,--disable-xattr,attr," | ||
10 | |||
11 | PROVIDES:append:class-native = " patch-replacement-native" | ||
12 | |||
13 | BBCLASSEXTEND = "native nativesdk" | ||