Browse code

kernels: Fix multiple CVEs

Fix CVE-2018-8043, CVE-2017-18216, CVE-2018-8087 and CVE-2017-18241.

Change-Id: I12cfdf6c33f546353b5be97c462567f316119042
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/5125
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Bo Gan <ganb@vmware.com>

Srivatsa S. Bhat authored on 2018/05/05 07:58:51
Showing 6 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,47 @@
0
+From d4fdf8ba0e5808ba9ad6b44337783bd9935e0982 Mon Sep 17 00:00:00 2001
1
+From: Yunlei He <heyunlei@huawei.com>
2
+Date: Thu, 1 Jun 2017 16:43:51 +0800
3
+Subject: [PATCH] f2fs: fix a panic caused by NULL flush_cmd_control
4
+
5
+Mount fs with option noflush_merge, boot failed for illegal address
6
+fcc in function f2fs_issue_flush:
7
+
8
+        if (!test_opt(sbi, FLUSH_MERGE)) {
9
+                ret = submit_flush_wait(sbi);
10
+                atomic_inc(&fcc->issued_flush);   ->  Here, fcc illegal
11
+                return ret;
12
+        }
13
+
14
+Signed-off-by: Yunlei He <heyunlei@huawei.com>
15
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
16
+Signed-off-by: Srivatsa S. Bhat <srivatsa@csail.mit.edu>
17
+---
18
+ fs/f2fs/segment.c | 5 ++++-
19
+ 1 file changed, 4 insertions(+), 1 deletion(-)
20
+
21
+diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
22
+index f77b325..87406ef 100644
23
+--- a/fs/f2fs/segment.c
24
+@@ -395,6 +395,9 @@ int create_flush_cmd_control(struct f2fs_sb_info *sbi)
25
+ 	init_waitqueue_head(&fcc->flush_wait_queue);
26
+ 	init_llist_head(&fcc->issue_list);
27
+ 	SM_I(sbi)->cmd_control_info = fcc;
28
++	if (!test_opt(sbi, FLUSH_MERGE))
29
++		return err;
30
++
31
+ 	fcc->f2fs_issue_flush = kthread_run(issue_flush_thread, sbi,
32
+ 				"f2fs_flush-%u:%u", MAJOR(dev), MINOR(dev));
33
+ 	if (IS_ERR(fcc->f2fs_issue_flush)) {
34
+@@ -2313,7 +2316,7 @@ int build_segment_manager(struct f2fs_sb_info *sbi)
35
+ 
36
+ 	INIT_LIST_HEAD(&sm_info->sit_entry_set);
37
+ 
38
+-	if (test_opt(sbi, FLUSH_MERGE) && !f2fs_readonly(sbi->sb)) {
39
++	if (!f2fs_readonly(sbi->sb)) {
40
+ 		err = create_flush_cmd_control(sbi);
41
+ 		if (err)
42
+ 			return err;
43
+-- 
44
+2.7.4
45
+
0 46
new file mode 100644
... ...
@@ -0,0 +1,38 @@
0
+From 0ddcff49b672239dda94d70d0fcf50317a9f4b51 Mon Sep 17 00:00:00 2001
1
+From: "weiyongjun (A)" <weiyongjun1@huawei.com>
2
+Date: Thu, 18 Jan 2018 02:23:34 +0000
3
+Subject: [PATCH] mac80211_hwsim: fix possible memory leak in
4
+ hwsim_new_radio_nl()
5
+
6
+'hwname' is malloced in hwsim_new_radio_nl() and should be freed
7
+before leaving from the error handling cases, otherwise it will cause
8
+memory leak.
9
+
10
+Fixes: ff4dd73dd2b4 ("mac80211_hwsim: check HWSIM_ATTR_RADIO_NAME length")
11
+Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
12
+Reviewed-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
13
+Signed-off-by: Johannes Berg <johannes.berg@intel.com>
14
+Signed-off-by: Srivatsa S. Bhat <srivatsa@csail.mit.edu>
15
+---
16
+ drivers/net/wireless/mac80211_hwsim.c | 4 +++-
17
+ 1 file changed, 3 insertions(+), 1 deletion(-)
18
+
19
+diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
20
+index 8a9164d..e8b770a 100644
21
+--- a/drivers/net/wireless/mac80211_hwsim.c
22
+@@ -2925,8 +2925,10 @@ static int hwsim_new_radio_nl(struct sk_buff *msg, struct genl_info *info)
23
+ 	if (info->attrs[HWSIM_ATTR_REG_CUSTOM_REG]) {
24
+ 		u32 idx = nla_get_u32(info->attrs[HWSIM_ATTR_REG_CUSTOM_REG]);
25
+ 
26
+-		if (idx >= ARRAY_SIZE(hwsim_world_regdom_custom))
27
++		if (idx >= ARRAY_SIZE(hwsim_world_regdom_custom)) {
28
++			kfree(hwname);
29
+ 			return -EINVAL;
30
++		}
31
+ 		param.regd = hwsim_world_regdom_custom[idx];
32
+ 	}
33
+ 
34
+-- 
35
+2.7.4
36
+
0 37
new file mode 100644
... ...
@@ -0,0 +1,45 @@
0
+From 297a6961ffb8ff4dc66c9fbf53b924bd1dda05d5 Mon Sep 17 00:00:00 2001
1
+From: Wei Yongjun <weiyongjun1@huawei.com>
2
+Date: Thu, 11 Jan 2018 11:21:51 +0000
3
+Subject: [PATCH] net: phy: mdio-bcm-unimac: fix potential NULL dereference in
4
+ unimac_mdio_probe()
5
+
6
+platform_get_resource() may fail and return NULL, so we should
7
+better check it's return value to avoid a NULL pointer dereference
8
+a bit later in the code.
9
+
10
+This is detected by Coccinelle semantic patch.
11
+
12
+@@
13
+expression pdev, res, n, t, e, e1, e2;
14
+@@
15
+
16
+res = platform_get_resource(pdev, t, n);
17
++ if (!res)
18
++   return -EINVAL;
19
+... when != res == NULL
20
+e = devm_ioremap(e1, res->start, e2);
21
+
22
+Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
23
+Signed-off-by: David S. Miller <davem@davemloft.net>
24
+Signed-off-by: Srivatsa S. Bhat <srivatsa@csail.mit.edu>
25
+---
26
+ drivers/net/phy/mdio-bcm-unimac.c | 2 ++
27
+ 1 file changed, 2 insertions(+)
28
+
29
+diff --git a/drivers/net/phy/mdio-bcm-unimac.c b/drivers/net/phy/mdio-bcm-unimac.c
30
+index 4bde5e7..fd8692b 100644
31
+--- a/drivers/net/phy/mdio-bcm-unimac.c
32
+@@ -177,6 +177,8 @@ static int unimac_mdio_probe(struct platform_device *pdev)
33
+ 		return -ENOMEM;
34
+ 
35
+ 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
36
++	if (!r)
37
++		return -EINVAL;
38
+ 
39
+ 	/* Just ioremap, as this MDIO block is usually integrated into an
40
+ 	 * Ethernet MAC controller register range
41
+-- 
42
+2.7.4
43
+
0 44
new file mode 100644
... ...
@@ -0,0 +1,208 @@
0
+From 853bc26a7ea39e354b9f8889ae7ad1492ffa28d2 Mon Sep 17 00:00:00 2001
1
+From: alex chen <alex.chen@huawei.com>
2
+Date: Wed, 15 Nov 2017 17:31:48 -0800
3
+Subject: [PATCH] ocfs2: subsystem.su_mutex is required while accessing the
4
+ item->ci_parent
5
+
6
+The subsystem.su_mutex is required while accessing the item->ci_parent,
7
+otherwise, NULL pointer dereference to the item->ci_parent will be
8
+triggered in the following situation:
9
+
10
+add node                     delete node
11
+sys_write
12
+ vfs_write
13
+  configfs_write_file
14
+   o2nm_node_store
15
+    o2nm_node_local_write
16
+                             do_rmdir
17
+                              vfs_rmdir
18
+                               configfs_rmdir
19
+                                mutex_lock(&subsys->su_mutex);
20
+                                unlink_obj
21
+                                 item->ci_group = NULL;
22
+                                 item->ci_parent = NULL;
23
+	 to_o2nm_cluster_from_node
24
+	  node->nd_item.ci_parent->ci_parent
25
+	  BUG since of NULL pointer dereference to nd_item.ci_parent
26
+
27
+Moreover, the o2nm_cluster also should be protected by the
28
+subsystem.su_mutex.
29
+
30
+[alex.chen@huawei.com: v2]
31
+  Link: http://lkml.kernel.org/r/59EEAA69.9080703@huawei.com
32
+Link: http://lkml.kernel.org/r/59E9B36A.10700@huawei.com
33
+Signed-off-by: Alex Chen <alex.chen@huawei.com>
34
+Reviewed-by: Jun Piao <piaojun@huawei.com>
35
+Reviewed-by: Joseph Qi <jiangqi903@gmail.com>
36
+Cc: Mark Fasheh <mfasheh@versity.com>
37
+Cc: Joel Becker <jlbec@evilplan.org>
38
+Cc: Junxiao Bi <junxiao.bi@oracle.com>
39
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
40
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
41
+Signed-off-by: Srivatsa S. Bhat <srivatsa@csail.mit.edu>
42
+---
43
+ fs/ocfs2/cluster/nodemanager.c | 63 ++++++++++++++++++++++++++++++++++++------
44
+ 1 file changed, 55 insertions(+), 8 deletions(-)
45
+
46
+diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c
47
+index 72afdca..3c45a93 100644
48
+--- a/fs/ocfs2/cluster/nodemanager.c
49
+@@ -40,6 +40,9 @@ char *o2nm_fence_method_desc[O2NM_FENCE_METHODS] = {
50
+ 		"panic",	/* O2NM_FENCE_PANIC */
51
+ };
52
+ 
53
++static inline void o2nm_lock_subsystem(void);
54
++static inline void o2nm_unlock_subsystem(void);
55
++
56
+ struct o2nm_node *o2nm_get_node_by_num(u8 node_num)
57
+ {
58
+ 	struct o2nm_node *node = NULL;
59
+@@ -181,7 +184,10 @@ static struct o2nm_cluster *to_o2nm_cluster_from_node(struct o2nm_node *node)
60
+ {
61
+ 	/* through the first node_set .parent
62
+ 	 * mycluster/nodes/mynode == o2nm_cluster->o2nm_node_group->o2nm_node */
63
+-	return to_o2nm_cluster(node->nd_item.ci_parent->ci_parent);
64
++	if (node->nd_item.ci_parent)
65
++		return to_o2nm_cluster(node->nd_item.ci_parent->ci_parent);
66
++	else
67
++		return NULL;
68
+ }
69
+ 
70
+ enum {
71
+@@ -194,7 +200,7 @@ static ssize_t o2nm_node_num_store(struct config_item *item, const char *page,
72
+ 				   size_t count)
73
+ {
74
+ 	struct o2nm_node *node = to_o2nm_node(item);
75
+-	struct o2nm_cluster *cluster = to_o2nm_cluster_from_node(node);
76
++	struct o2nm_cluster *cluster;
77
+ 	unsigned long tmp;
78
+ 	char *p = (char *)page;
79
+ 	int ret = 0;
80
+@@ -214,6 +220,13 @@ static ssize_t o2nm_node_num_store(struct config_item *item, const char *page,
81
+ 	    !test_bit(O2NM_NODE_ATTR_PORT, &node->nd_set_attributes))
82
+ 		return -EINVAL; /* XXX */
83
+ 
84
++	o2nm_lock_subsystem();
85
++	cluster = to_o2nm_cluster_from_node(node);
86
++	if (!cluster) {
87
++		o2nm_unlock_subsystem();
88
++		return -EINVAL;
89
++	}
90
++
91
+ 	write_lock(&cluster->cl_nodes_lock);
92
+ 	if (cluster->cl_nodes[tmp])
93
+ 		ret = -EEXIST;
94
+@@ -226,6 +239,8 @@ static ssize_t o2nm_node_num_store(struct config_item *item, const char *page,
95
+ 		set_bit(tmp, cluster->cl_nodes_bitmap);
96
+ 	}
97
+ 	write_unlock(&cluster->cl_nodes_lock);
98
++	o2nm_unlock_subsystem();
99
++
100
+ 	if (ret)
101
+ 		return ret;
102
+ 
103
+@@ -269,7 +284,7 @@ static ssize_t o2nm_node_ipv4_address_store(struct config_item *item,
104
+ 					    size_t count)
105
+ {
106
+ 	struct o2nm_node *node = to_o2nm_node(item);
107
+-	struct o2nm_cluster *cluster = to_o2nm_cluster_from_node(node);
108
++	struct o2nm_cluster *cluster;
109
+ 	int ret, i;
110
+ 	struct rb_node **p, *parent;
111
+ 	unsigned int octets[4];
112
+@@ -286,6 +301,13 @@ static ssize_t o2nm_node_ipv4_address_store(struct config_item *item,
113
+ 		be32_add_cpu(&ipv4_addr, octets[i] << (i * 8));
114
+ 	}
115
+ 
116
++	o2nm_lock_subsystem();
117
++	cluster = to_o2nm_cluster_from_node(node);
118
++	if (!cluster) {
119
++		o2nm_unlock_subsystem();
120
++		return -EINVAL;
121
++	}
122
++
123
+ 	ret = 0;
124
+ 	write_lock(&cluster->cl_nodes_lock);
125
+ 	if (o2nm_node_ip_tree_lookup(cluster, ipv4_addr, &p, &parent))
126
+@@ -298,6 +320,8 @@ static ssize_t o2nm_node_ipv4_address_store(struct config_item *item,
127
+ 		rb_insert_color(&node->nd_ip_node, &cluster->cl_node_ip_tree);
128
+ 	}
129
+ 	write_unlock(&cluster->cl_nodes_lock);
130
++	o2nm_unlock_subsystem();
131
++
132
+ 	if (ret)
133
+ 		return ret;
134
+ 
135
+@@ -315,7 +339,7 @@ static ssize_t o2nm_node_local_store(struct config_item *item, const char *page,
136
+ 				     size_t count)
137
+ {
138
+ 	struct o2nm_node *node = to_o2nm_node(item);
139
+-	struct o2nm_cluster *cluster = to_o2nm_cluster_from_node(node);
140
++	struct o2nm_cluster *cluster;
141
+ 	unsigned long tmp;
142
+ 	char *p = (char *)page;
143
+ 	ssize_t ret;
144
+@@ -333,17 +357,26 @@ static ssize_t o2nm_node_local_store(struct config_item *item, const char *page,
145
+ 	    !test_bit(O2NM_NODE_ATTR_PORT, &node->nd_set_attributes))
146
+ 		return -EINVAL; /* XXX */
147
+ 
148
++	o2nm_lock_subsystem();
149
++	cluster = to_o2nm_cluster_from_node(node);
150
++	if (!cluster) {
151
++		ret = -EINVAL;
152
++		goto out;
153
++	}
154
++
155
+ 	/* the only failure case is trying to set a new local node
156
+ 	 * when a different one is already set */
157
+ 	if (tmp && tmp == cluster->cl_has_local &&
158
+-	    cluster->cl_local_node != node->nd_num)
159
+-		return -EBUSY;
160
++	    cluster->cl_local_node != node->nd_num) {
161
++		ret = -EBUSY;
162
++		goto out;
163
++	}
164
+ 
165
+ 	/* bring up the rx thread if we're setting the new local node. */
166
+ 	if (tmp && !cluster->cl_has_local) {
167
+ 		ret = o2net_start_listening(node);
168
+ 		if (ret)
169
+-			return ret;
170
++			goto out;
171
+ 	}
172
+ 
173
+ 	if (!tmp && cluster->cl_has_local &&
174
+@@ -358,7 +391,11 @@ static ssize_t o2nm_node_local_store(struct config_item *item, const char *page,
175
+ 		cluster->cl_local_node = node->nd_num;
176
+ 	}
177
+ 
178
+-	return count;
179
++	ret = count;
180
++
181
++out:
182
++	o2nm_unlock_subsystem();
183
++	return ret;
184
+ }
185
+ 
186
+ CONFIGFS_ATTR(o2nm_node_, num);
187
+@@ -750,6 +787,16 @@ static struct o2nm_cluster_group o2nm_cluster_group = {
188
+ 	},
189
+ };
190
+ 
191
++static inline void o2nm_lock_subsystem(void)
192
++{
193
++	mutex_lock(&o2nm_cluster_group.cs_subsys.su_mutex);
194
++}
195
++
196
++static inline void o2nm_unlock_subsystem(void)
197
++{
198
++	mutex_unlock(&o2nm_cluster_group.cs_subsys.su_mutex);
199
++}
200
++
201
+ int o2nm_depend_item(struct config_item *item)
202
+ {
203
+ 	return configfs_depend_item(&o2nm_cluster_group.cs_subsys, item);
204
+-- 
205
+2.7.4
206
+
... ...
@@ -2,7 +2,7 @@
2 2
 Summary:       Kernel
3 3
 Name:          linux-esx
4 4
 Version:       4.4.131
5
-Release:       1%{?dist}
5
+Release:       2%{?dist}
6 6
 License:       GPLv2
7 7
 URL:           http://www.kernel.org/
8 8
 Group:         System Environment/Kernel
... ...
@@ -42,6 +42,14 @@ Patch27:       0001-net-create-skb_gso_validate_mac_len.patch
42 42
 Patch28:       0002-bnx2x-disable-GSO-where-gso_size-is-too-big-for-hard.patch
43 43
 # Fix for CVE-2017-18255
44 44
 Patch29:       0001-perf-core-Fix-the-perf_cpu_time_max_percent-check.patch
45
+# Fix for CVE-2018-8043
46
+Patch30:       0001-net-phy-mdio-bcm-unimac-fix-potential-NULL-dereferen.patch
47
+# Fix for CVE-2017-18216
48
+Patch31:       0001-ocfs2-subsystem.su_mutex-is-required-while-accessing.patch
49
+# Fix for CVE-2018-8087
50
+Patch32:       0001-mac80211_hwsim-fix-possible-memory-leak-in-hwsim_new.patch
51
+# Fix for CVE-2017-18241
52
+Patch33:       0001-f2fs-fix-a-panic-caused-by-NULL-flush_cmd_control.patch
45 53
 
46 54
 # For Spectre
47 55
 Patch52: 0141-locking-barriers-introduce-new-observable-speculatio.patch
... ...
@@ -123,6 +131,10 @@ The Linux package contains the Linux kernel doc files
123 123
 %patch27 -p1
124 124
 %patch28 -p1
125 125
 %patch29 -p1
126
+%patch30 -p1
127
+%patch31 -p1
128
+%patch32 -p1
129
+%patch33 -p1
126 130
 
127 131
 %patch52 -p1
128 132
 %patch55 -p1
... ...
@@ -226,6 +238,8 @@ ln -sf linux-%{uname_r}.cfg /boot/photon.cfg
226 226
 /usr/src/linux-headers-%{uname_r}
227 227
 
228 228
 %changelog
229
+*   Fri May 04 2018 Srivatsa S. Bhat <srivatsa@csail.mit.edu> 4.4.131-2
230
+-   Fix CVE-2018-8043, CVE-2017-18216, CVE-2018-8087, CVE-2017-18241.
229 231
 *   Fri May 04 2018 Srivatsa S. Bhat <srivatsa@csail.mit.edu> 4.4.131-1
230 232
 -   Update to version 4.4.131
231 233
 *   Wed May 02 2018 Srivatsa S. Bhat <srivatsa@csail.mit.edu> 4.4.130-2
... ...
@@ -2,7 +2,7 @@
2 2
 Summary:        Kernel
3 3
 Name:           linux
4 4
 Version:    	4.4.131
5
-Release:        1%{?kat_build:.%kat_build}%{?dist}
5
+Release:        2%{?kat_build:.%kat_build}%{?dist}
6 6
 License:    	GPLv2
7 7
 URL:        	http://www.kernel.org/
8 8
 Group:        	System Environment/Kernel
... ...
@@ -41,6 +41,14 @@ Patch19:        0001-net-create-skb_gso_validate_mac_len.patch
41 41
 Patch20:        0002-bnx2x-disable-GSO-where-gso_size-is-too-big-for-hard.patch
42 42
 # Fix for CVE-2017-18255
43 43
 Patch21:        0001-perf-core-Fix-the-perf_cpu_time_max_percent-check.patch
44
+# Fix for CVE-2018-8043
45
+Patch22:        0001-net-phy-mdio-bcm-unimac-fix-potential-NULL-dereferen.patch
46
+# Fix for CVE-2017-18216
47
+Patch23:        0001-ocfs2-subsystem.su_mutex-is-required-while-accessing.patch
48
+# Fix for CVE-2018-8087
49
+Patch24:        0001-mac80211_hwsim-fix-possible-memory-leak-in-hwsim_new.patch
50
+# Fix for CVE-2017-18241
51
+Patch25:        0001-f2fs-fix-a-panic-caused-by-NULL-flush_cmd_control.patch
44 52
 
45 53
 # For Spectre
46 54
 Patch52: 0141-locking-barriers-introduce-new-observable-speculatio.patch
... ...
@@ -153,6 +161,10 @@ This package contains the 'perf' performance analysis tools for Linux kernel.
153 153
 %patch19 -p1
154 154
 %patch20 -p1
155 155
 %patch21 -p1
156
+%patch22 -p1
157
+%patch23 -p1
158
+%patch24 -p1
159
+%patch25 -p1
156 160
 
157 161
 %patch52 -p1
158 162
 %patch55 -p1
... ...
@@ -324,6 +336,8 @@ ln -sf %{name}-%{uname_r}.cfg /boot/photon.cfg
324 324
 /usr/share/perf-core
325 325
 
326 326
 %changelog
327
+*   Fri May 04 2018 Srivatsa S. Bhat <srivatsa@csail.mit.edu> 4.4.131-2
328
+-   Fix CVE-2018-8043, CVE-2017-18216, CVE-2018-8087, CVE-2017-18241.
327 329
 *   Fri May 04 2018 Srivatsa S. Bhat <srivatsa@csail.mit.edu> 4.4.131-1
328 330
 -   Update to version 4.4.131
329 331
 *   Wed May 02 2018 Srivatsa S. Bhat <srivatsa@csail.mit.edu> 4.4.130-2