diff options
author | Roy Li <rongqing.li@windriver.com> | 2015-04-24 10:37:14 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-04-28 07:56:56 +0100 |
commit | b6288432bfe241141408bd46b68d57bca2b185ea (patch) | |
tree | 265512aa99b1335ba66f3f8e79a8bf07d68cb615 /meta/recipes-devtools | |
parent | c3537bd112744ad34f12a3a16b7ef71558bfdc98 (diff) | |
download | poky-b6288432bfe241141408bd46b68d57bca2b185ea.tar.gz |
rsync: backport a patch to fix CVE-2014-9512
rsync 3.1.1 allows remote attackers to write to arbitrary files via a symlink
attack on a file in the synchronization path.
Backport Complain-if-an-inc-recursive-path-is-not-right-for-i.patch to fix it
(From OE-Core rev: f280b4f28231ea5a416266ae022d6e4c4ea91117)
Signed-off-by: Roy Li <rongqing.li@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools')
-rw-r--r-- | meta/recipes-devtools/rsync/rsync-3.1.1/0001-Complain-if-an-inc-recursive-path-is-not-right-for-i.patch | 135 | ||||
-rw-r--r-- | meta/recipes-devtools/rsync/rsync_3.1.1.bb | 4 |
2 files changed, 138 insertions, 1 deletions
diff --git a/meta/recipes-devtools/rsync/rsync-3.1.1/0001-Complain-if-an-inc-recursive-path-is-not-right-for-i.patch b/meta/recipes-devtools/rsync/rsync-3.1.1/0001-Complain-if-an-inc-recursive-path-is-not-right-for-i.patch new file mode 100644 index 0000000000..5ece5420a3 --- /dev/null +++ b/meta/recipes-devtools/rsync/rsync-3.1.1/0001-Complain-if-an-inc-recursive-path-is-not-right-for-i.patch | |||
@@ -0,0 +1,135 @@ | |||
1 | From 962f8b90045ab331fc04c9e65f80f1a53e68243b Mon Sep 17 00:00:00 2001 | ||
2 | From: Wayne Davison <wayned@samba.org> | ||
3 | Date: Wed, 31 Dec 2014 12:41:03 -0800 | ||
4 | Subject: [PATCH] Complain if an inc-recursive path is not right for its dir. | ||
5 | This ensures that a malicious sender can't use a just-sent symlink as a | ||
6 | trasnfer path. | ||
7 | |||
8 | Upstream-Status: BackPort | ||
9 | |||
10 | Fix the CVE-2014-9512, rsync 3.1.1 allows remote attackers to write to arbitrary | ||
11 | files via a symlink attack on a file in the synchronization path. | ||
12 | |||
13 | BackPort and fix this patch to make it able to apply to source code | ||
14 | |||
15 | Signed-off-by: Roy Li <rongqing.li@windriver.com> | ||
16 | --- | ||
17 | flist.c | 22 ++++++++++++++++++++-- | ||
18 | io.c | 2 +- | ||
19 | main.c | 4 ++-- | ||
20 | rsync.c | 2 +- | ||
21 | proto.h | 2 +- | ||
22 | 6 files changed, 31 insertions(+), 8 deletions(-) | ||
23 | |||
24 | diff --git a/flist.c b/flist.c | ||
25 | index c24672e..92e4b65 100644 | ||
26 | --- a/flist.c | ||
27 | +++ b/flist.c | ||
28 | @@ -2435,8 +2435,9 @@ struct file_list *send_file_list(int f, int argc, char *argv[]) | ||
29 | return flist; | ||
30 | } | ||
31 | |||
32 | -struct file_list *recv_file_list(int f) | ||
33 | +struct file_list *recv_file_list(int f, int dir_ndx) | ||
34 | { | ||
35 | + const char *good_dirname = NULL; | ||
36 | struct file_list *flist; | ||
37 | int dstart, flags; | ||
38 | int64 start_read; | ||
39 | @@ -2492,6 +2493,23 @@ struct file_list *recv_file_list(int f) | ||
40 | flist_expand(flist, 1); | ||
41 | file = recv_file_entry(f, flist, flags); | ||
42 | |||
43 | + if (inc_recurse) { | ||
44 | + static const char empty_dir[] = "\0"; | ||
45 | + const char *cur_dir = file->dirname ? file->dirname : empty_dir; | ||
46 | + if (relative_paths && *cur_dir == '/') | ||
47 | + cur_dir++; | ||
48 | + if (cur_dir != good_dirname) { | ||
49 | + const char *d = dir_ndx >= 0 ? f_name(dir_flist->files[dir_ndx], NULL) : empty_dir; | ||
50 | + if (strcmp(cur_dir, d) != 0) { | ||
51 | + rprintf(FERROR, | ||
52 | + "ABORTING due to invalid dir prefix from sender: %s (should be: %s)\n", | ||
53 | + cur_dir, d); | ||
54 | + exit_cleanup(RERR_PROTOCOL); | ||
55 | + } | ||
56 | + good_dirname = cur_dir; | ||
57 | + } | ||
58 | + } | ||
59 | + | ||
60 | if (S_ISREG(file->mode)) { | ||
61 | /* Already counted */ | ||
62 | } else if (S_ISDIR(file->mode)) { | ||
63 | @@ -2615,7 +2633,7 @@ void recv_additional_file_list(int f) | ||
64 | rprintf(FINFO, "[%s] receiving flist for dir %d\n", | ||
65 | who_am_i(), ndx); | ||
66 | } | ||
67 | - flist = recv_file_list(f); | ||
68 | + flist = recv_file_list(f, ndx); | ||
69 | flist->parent_ndx = ndx; | ||
70 | } | ||
71 | } | ||
72 | diff --git a/io.c b/io.c | ||
73 | index b9a9bd0..a868fa9 100644 | ||
74 | --- a/io.c | ||
75 | +++ b/io.c | ||
76 | @@ -1685,7 +1685,7 @@ void wait_for_receiver(void) | ||
77 | rprintf(FINFO, "[%s] receiving flist for dir %d\n", | ||
78 | who_am_i(), ndx); | ||
79 | } | ||
80 | - flist = recv_file_list(iobuf.in_fd); | ||
81 | + flist = recv_file_list(iobuf.in_fd, ndx); | ||
82 | flist->parent_ndx = ndx; | ||
83 | #ifdef SUPPORT_HARD_LINKS | ||
84 | if (preserve_hard_links) | ||
85 | diff --git a/main.c b/main.c | ||
86 | index e7a13f7..713b818 100644 | ||
87 | --- a/main.c | ||
88 | +++ b/main.c | ||
89 | @@ -1009,7 +1009,7 @@ static void do_server_recv(int f_in, int f_out, int argc, char *argv[]) | ||
90 | filesfrom_fd = -1; | ||
91 | } | ||
92 | |||
93 | - flist = recv_file_list(f_in); | ||
94 | + flist = recv_file_list(f_in, -1); | ||
95 | if (!flist) { | ||
96 | rprintf(FERROR,"server_recv: recv_file_list error\n"); | ||
97 | exit_cleanup(RERR_FILESELECT); | ||
98 | @@ -1183,7 +1183,7 @@ int client_run(int f_in, int f_out, pid_t pid, int argc, char *argv[]) | ||
99 | |||
100 | if (write_batch && !am_server) | ||
101 | start_write_batch(f_in); | ||
102 | - flist = recv_file_list(f_in); | ||
103 | + flist = recv_file_list(f_in, -1); | ||
104 | if (inc_recurse && file_total == 1) | ||
105 | recv_additional_file_list(f_in); | ||
106 | |||
107 | diff --git a/rsync.c b/rsync.c | ||
108 | index 68ff6b1..c3ecc51 100644 | ||
109 | --- a/rsync.c | ||
110 | +++ b/rsync.c | ||
111 | @@ -364,7 +364,7 @@ int read_ndx_and_attrs(int f_in, int f_out, int *iflag_ptr, uchar *type_ptr, | ||
112 | } | ||
113 | /* Send all the data we read for this flist to the generator. */ | ||
114 | start_flist_forward(ndx); | ||
115 | - flist = recv_file_list(f_in); | ||
116 | + flist = recv_file_list(f_in, ndx); | ||
117 | flist->parent_ndx = ndx; | ||
118 | stop_flist_forward(); | ||
119 | } | ||
120 | diff --git a/proto.h b/proto.h | ||
121 | index 22fc539..247c558 100644 | ||
122 | --- a/proto.h | ||
123 | +++ b/proto.h | ||
124 | @@ -89,7 +89,7 @@ struct file_struct *make_file(const char *fname, struct file_list *flist, | ||
125 | void unmake_file(struct file_struct *file); | ||
126 | void send_extra_file_list(int f, int at_least); | ||
127 | struct file_list *send_file_list(int f, int argc, char *argv[]); | ||
128 | -struct file_list *recv_file_list(int f); | ||
129 | +struct file_list *recv_file_list(int f, int dir_ndx); | ||
130 | void recv_additional_file_list(int f); | ||
131 | int flist_find(struct file_list *flist, struct file_struct *f); | ||
132 | int flist_find_ignore_dirness(struct file_list *flist, struct file_struct *f); | ||
133 | -- | ||
134 | 1.9.1 | ||
135 | |||
diff --git a/meta/recipes-devtools/rsync/rsync_3.1.1.bb b/meta/recipes-devtools/rsync/rsync_3.1.1.bb index 5ff8ae8bb4..3a79154511 100644 --- a/meta/recipes-devtools/rsync/rsync_3.1.1.bb +++ b/meta/recipes-devtools/rsync/rsync_3.1.1.bb | |||
@@ -1,7 +1,9 @@ | |||
1 | require rsync.inc | 1 | require rsync.inc |
2 | 2 | ||
3 | 3 | ||
4 | SRC_URI += "file://acinclude.m4" | 4 | SRC_URI += "file://acinclude.m4 \ |
5 | file://0001-Complain-if-an-inc-recursive-path-is-not-right-for-i.patch \ | ||
6 | " | ||
5 | 7 | ||
6 | SRC_URI[md5sum] = "43bd6676f0b404326eee2d63be3cdcfe" | 8 | SRC_URI[md5sum] = "43bd6676f0b404326eee2d63be3cdcfe" |
7 | SRC_URI[sha256sum] = "7de4364fcf5fe42f3bdb514417f1c40d10bbca896abe7e7f2c581c6ea08a2621" | 9 | SRC_URI[sha256sum] = "7de4364fcf5fe42f3bdb514417f1c40d10bbca896abe7e7f2c581c6ea08a2621" |