Browse code

kernels: Update to version 4.4.140 and fix CVE-2017-18249

Change-Id: I1ed46a28b8bcc73087e73ce154cec440a7a65b77
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/5360
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Srinidhi Rao <srinidhir@vmware.com>
Reviewed-by: Alexey Makhalov <amakhalov@vmware.com>

Srivatsa S. Bhat authored on 2018/07/17 07:49:00
Showing 8 changed files
... ...
@@ -1,6 +1,6 @@
1 1
 Summary:	Linux API header files
2 2
 Name:		linux-api-headers
3
-Version:	4.4.139
3
+Version:	4.4.140
4 4
 Release:	1%{?dist}
5 5
 License:	GPLv2
6 6
 URL:		http://www.kernel.org/
... ...
@@ -8,7 +8,7 @@ Group:		System Environment/Kernel
8 8
 Vendor:		VMware, Inc.
9 9
 Distribution: Photon
10 10
 Source0:    	http://www.kernel.org/pub/linux/kernel/v4.x/linux-%{version}.tar.xz
11
-%define sha1 linux=ce4028904ab97c1942cc1c1b917520065529dc34
11
+%define sha1 linux=55dc1299e981cb4ef8ef0c92a4df52c2f4df4835
12 12
 BuildArch:	noarch
13 13
 # From SPECS/linux and used by linux-esx only
14 14
 # It provides f*xattrat syscalls
... ...
@@ -29,6 +29,8 @@ find /%{buildroot}%{_includedir} \( -name .install -o -name ..install.cmd \) -de
29 29
 %defattr(-,root,root)
30 30
 %{_includedir}/*
31 31
 %changelog
32
+*   Mon Jul 16 2018 Srivatsa S. Bhat <srivatsa@csail.mit.edu> 4.4.140-1
33
+-   Update to version 4.4.140
32 34
 *   Tue Jul 03 2018 Srivatsa S. Bhat <srivatsa@csail.mit.edu> 4.4.139-1
33 35
 -   Update to version 4.4.139
34 36
 *   Mon Jun 25 2018 Srivatsa S. Bhat <srivatsa@csail.mit.edu> 4.4.138-1
35 37
new file mode 100644
... ...
@@ -0,0 +1,166 @@
0
+From e61ebdeb4893582189c03ac2e86ff6c1b2ccb03b Mon Sep 17 00:00:00 2001
1
+From: Jaegeuk Kim <jaegeuk@kernel.org>
2
+Date: Sat, 2 Jan 2016 09:19:41 -0800
3
+Subject: [PATCH 1/4] f2fs: cover more area with nat_tree_lock
4
+
5
+commit a51311938e14c17f5a94d30baac9d7bec71f5858 upstream.
6
+
7
+There was a subtle bug on nat cache management which incurs wrong nid allocation
8
+or wrong block addresses when try_to_free_nats is triggered heavily.
9
+This patch enlarges the previous coverage of nat_tree_lock to avoid data race.
10
+
11
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
12
+Signed-off-by: Srivatsa S. Bhat <srivatsa@csail.mit.edu>
13
+---
14
+ fs/f2fs/node.c | 29 ++++++++++++-----------------
15
+ 1 file changed, 12 insertions(+), 17 deletions(-)
16
+
17
+diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
18
+index 7bcbc6e..8f6784f 100644
19
+--- a/fs/f2fs/node.c
20
+@@ -261,13 +261,11 @@ static void cache_nat_entry(struct f2fs_nm_info *nm_i, nid_t nid,
21
+ {
22
+ 	struct nat_entry *e;
23
+ 
24
+-	down_write(&nm_i->nat_tree_lock);
25
+ 	e = __lookup_nat_cache(nm_i, nid);
26
+ 	if (!e) {
27
+ 		e = grab_nat_entry(nm_i, nid);
28
+ 		node_info_from_raw_nat(&e->ni, ne);
29
+ 	}
30
+-	up_write(&nm_i->nat_tree_lock);
31
+ }
32
+ 
33
+ static void set_node_addr(struct f2fs_sb_info *sbi, struct node_info *ni,
34
+@@ -379,6 +377,8 @@ void get_node_info(struct f2fs_sb_info *sbi, nid_t nid, struct node_info *ni)
35
+ 
36
+ 	memset(&ne, 0, sizeof(struct f2fs_nat_entry));
37
+ 
38
++	down_write(&nm_i->nat_tree_lock);
39
++
40
+ 	/* Check current segment summary */
41
+ 	mutex_lock(&curseg->curseg_mutex);
42
+ 	i = lookup_journal_in_cursum(sum, NAT_JOURNAL, nid, 0);
43
+@@ -399,6 +399,7 @@ void get_node_info(struct f2fs_sb_info *sbi, nid_t nid, struct node_info *ni)
44
+ cache:
45
+ 	/* cache nat entry */
46
+ 	cache_nat_entry(NM_I(sbi), nid, &ne);
47
++	up_write(&nm_i->nat_tree_lock);
48
+ }
49
+ 
50
+ /*
51
+@@ -1440,13 +1441,10 @@ static int add_free_nid(struct f2fs_sb_info *sbi, nid_t nid, bool build)
52
+ 
53
+ 	if (build) {
54
+ 		/* do not add allocated nids */
55
+-		down_read(&nm_i->nat_tree_lock);
56
+ 		ne = __lookup_nat_cache(nm_i, nid);
57
+-		if (ne &&
58
+-			(!get_nat_flag(ne, IS_CHECKPOINTED) ||
59
++		if (ne && (!get_nat_flag(ne, IS_CHECKPOINTED) ||
60
+ 				nat_get_blkaddr(ne) != NULL_ADDR))
61
+ 			allocated = true;
62
+-		up_read(&nm_i->nat_tree_lock);
63
+ 		if (allocated)
64
+ 			return 0;
65
+ 	}
66
+@@ -1532,6 +1530,8 @@ static void build_free_nids(struct f2fs_sb_info *sbi)
67
+ 	ra_meta_pages(sbi, NAT_BLOCK_OFFSET(nid), FREE_NID_PAGES,
68
+ 							META_NAT, true);
69
+ 
70
++	down_read(&nm_i->nat_tree_lock);
71
++
72
+ 	while (1) {
73
+ 		struct page *page = get_current_nat_page(sbi, nid);
74
+ 
75
+@@ -1560,6 +1560,7 @@ static void build_free_nids(struct f2fs_sb_info *sbi)
76
+ 			remove_free_nid(nm_i, nid);
77
+ 	}
78
+ 	mutex_unlock(&curseg->curseg_mutex);
79
++	up_read(&nm_i->nat_tree_lock);
80
+ 
81
+ 	ra_meta_pages(sbi, NAT_BLOCK_OFFSET(nm_i->next_scan_nid),
82
+ 					nm_i->ra_nid_pages, META_NAT, false);
83
+@@ -1842,14 +1843,12 @@ static void remove_nats_in_journal(struct f2fs_sb_info *sbi)
84
+ 
85
+ 		raw_ne = nat_in_journal(sum, i);
86
+ 
87
+-		down_write(&nm_i->nat_tree_lock);
88
+ 		ne = __lookup_nat_cache(nm_i, nid);
89
+ 		if (!ne) {
90
+ 			ne = grab_nat_entry(nm_i, nid);
91
+ 			node_info_from_raw_nat(&ne->ni, &raw_ne);
92
+ 		}
93
+ 		__set_nat_cache_dirty(nm_i, ne);
94
+-		up_write(&nm_i->nat_tree_lock);
95
+ 	}
96
+ 	update_nats_in_cursum(sum, -i);
97
+ 	mutex_unlock(&curseg->curseg_mutex);
98
+@@ -1883,7 +1882,6 @@ static void __flush_nat_entry_set(struct f2fs_sb_info *sbi,
99
+ 	struct f2fs_nat_block *nat_blk;
100
+ 	struct nat_entry *ne, *cur;
101
+ 	struct page *page = NULL;
102
+-	struct f2fs_nm_info *nm_i = NM_I(sbi);
103
+ 
104
+ 	/*
105
+ 	 * there are two steps to flush nat entries:
106
+@@ -1920,12 +1918,8 @@ static void __flush_nat_entry_set(struct f2fs_sb_info *sbi,
107
+ 			raw_ne = &nat_blk->entries[nid - start_nid];
108
+ 		}
109
+ 		raw_nat_from_node_info(raw_ne, &ne->ni);
110
+-
111
+-		down_write(&NM_I(sbi)->nat_tree_lock);
112
+ 		nat_reset_flag(ne);
113
+ 		__clear_nat_cache_dirty(NM_I(sbi), ne);
114
+-		up_write(&NM_I(sbi)->nat_tree_lock);
115
+-
116
+ 		if (nat_get_blkaddr(ne) == NULL_ADDR)
117
+ 			add_free_nid(sbi, nid, false);
118
+ 	}
119
+@@ -1937,9 +1931,7 @@ static void __flush_nat_entry_set(struct f2fs_sb_info *sbi,
120
+ 
121
+ 	f2fs_bug_on(sbi, set->entry_cnt);
122
+ 
123
+-	down_write(&nm_i->nat_tree_lock);
124
+ 	radix_tree_delete(&NM_I(sbi)->nat_set_root, set->set);
125
+-	up_write(&nm_i->nat_tree_lock);
126
+ 	kmem_cache_free(nat_entry_set_slab, set);
127
+ }
128
+ 
129
+@@ -1959,6 +1951,9 @@ void flush_nat_entries(struct f2fs_sb_info *sbi)
130
+ 
131
+ 	if (!nm_i->dirty_nat_cnt)
132
+ 		return;
133
++
134
++	down_write(&nm_i->nat_tree_lock);
135
++
136
+ 	/*
137
+ 	 * if there are no enough space in journal to store dirty nat
138
+ 	 * entries, remove all entries from journal and merge them
139
+@@ -1967,7 +1962,6 @@ void flush_nat_entries(struct f2fs_sb_info *sbi)
140
+ 	if (!__has_cursum_space(sum, nm_i->dirty_nat_cnt, NAT_JOURNAL))
141
+ 		remove_nats_in_journal(sbi);
142
+ 
143
+-	down_write(&nm_i->nat_tree_lock);
144
+ 	while ((found = __gang_lookup_nat_set(nm_i,
145
+ 					set_idx, SETVEC_SIZE, setvec))) {
146
+ 		unsigned idx;
147
+@@ -1976,12 +1970,13 @@ void flush_nat_entries(struct f2fs_sb_info *sbi)
148
+ 			__adjust_nat_entry_set(setvec[idx], &sets,
149
+ 							MAX_NAT_JENTRIES(sum));
150
+ 	}
151
+-	up_write(&nm_i->nat_tree_lock);
152
+ 
153
+ 	/* flush dirty nats in nat entry set */
154
+ 	list_for_each_entry_safe(set, tmp, &sets, set_list)
155
+ 		__flush_nat_entry_set(sbi, set);
156
+ 
157
++	up_write(&nm_i->nat_tree_lock);
158
++
159
+ 	f2fs_bug_on(sbi, nm_i->dirty_nat_cnt);
160
+ }
161
+ 
162
+-- 
163
+2.7.4
164
+
0 165
new file mode 100644
... ...
@@ -0,0 +1,50 @@
0
+From 55160d13998452c3a9f60234d6c9cc10c1098ead Mon Sep 17 00:00:00 2001
1
+From: Jaegeuk Kim <jaegeuk@kernel.org>
2
+Date: Sat, 2 Jan 2016 09:23:27 -0800
3
+Subject: [PATCH 2/4] Revert "f2fs: check the node block address of newly
4
+ allocated nid"
5
+
6
+commit 957efb0c2144cc5ff1795f43bf2d2ca430eaa227 upstream.
7
+
8
+Original issue is fixed by:
9
+
10
+  f2fs: cover more area with nat_tree_lock
11
+
12
+This reverts commit 24928634f81b1592e83b37dcd89ed45c28f12feb.
13
+
14
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
15
+Signed-off-by: Srivatsa S. Bhat <srivatsa@csail.mit.edu>
16
+---
17
+ fs/f2fs/node.c | 9 ---------
18
+ 1 file changed, 9 deletions(-)
19
+
20
+diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
21
+index 8f6784f..5ff9224 100644
22
+--- a/fs/f2fs/node.c
23
+@@ -1583,8 +1583,6 @@ retry:
24
+ 
25
+ 	/* We should not use stale free nids created by build_free_nids */
26
+ 	if (nm_i->fcnt && !on_build_free_nids(nm_i)) {
27
+-		struct node_info ni;
28
+-
29
+ 		f2fs_bug_on(sbi, list_empty(&nm_i->free_nid_list));
30
+ 		list_for_each_entry(i, &nm_i->free_nid_list, list)
31
+ 			if (i->state == NID_NEW)
32
+@@ -1595,13 +1593,6 @@ retry:
33
+ 		i->state = NID_ALLOC;
34
+ 		nm_i->fcnt--;
35
+ 		spin_unlock(&nm_i->free_nid_list_lock);
36
+-
37
+-		/* check nid is allocated already */
38
+-		get_node_info(sbi, *nid, &ni);
39
+-		if (ni.blk_addr != NULL_ADDR) {
40
+-			alloc_nid_done(sbi, *nid);
41
+-			goto retry;
42
+-		}
43
+ 		return true;
44
+ 	}
45
+ 	spin_unlock(&nm_i->free_nid_list_lock);
46
+-- 
47
+2.7.4
48
+
0 49
new file mode 100644
... ...
@@ -0,0 +1,39 @@
0
+From 6dc3cc6deeb03e181fcac1f57fd55deebc234873 Mon Sep 17 00:00:00 2001
1
+From: Jaegeuk Kim <jaegeuk@kernel.org>
2
+Date: Wed, 4 May 2016 09:58:10 -0700
3
+Subject: [PATCH 3/4] f2fs: remove an obsolete variable
4
+
5
+commit fb58ae22067e0595d974e3d856522c1ed6d2d7bf upstream.
6
+
7
+This patch removes an obsolete variable used in add_free_nid.
8
+
9
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
10
+Signed-off-by: Srivatsa S. Bhat <srivatsa@csail.mit.edu>
11
+---
12
+ fs/f2fs/node.c | 3 ---
13
+ 1 file changed, 3 deletions(-)
14
+
15
+diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
16
+index 5ff9224..1b10cd3 100644
17
+--- a/fs/f2fs/node.c
18
+@@ -1430,7 +1430,6 @@ static int add_free_nid(struct f2fs_sb_info *sbi, nid_t nid, bool build)
19
+ 	struct f2fs_nm_info *nm_i = NM_I(sbi);
20
+ 	struct free_nid *i;
21
+ 	struct nat_entry *ne;
22
+-	bool allocated = false;
23
+ 
24
+ 	if (!available_free_memory(sbi, FREE_NIDS))
25
+ 		return -1;
26
+@@ -1444,8 +1443,6 @@ static int add_free_nid(struct f2fs_sb_info *sbi, nid_t nid, bool build)
27
+ 		ne = __lookup_nat_cache(nm_i, nid);
28
+ 		if (ne && (!get_nat_flag(ne, IS_CHECKPOINTED) ||
29
+ 				nat_get_blkaddr(ne) != NULL_ADDR))
30
+-			allocated = true;
31
+-		if (allocated)
32
+ 			return 0;
33
+ 	}
34
+ 
35
+-- 
36
+2.7.4
37
+
0 38
new file mode 100644
... ...
@@ -0,0 +1,146 @@
0
+From 60594341975112eb05e84ecbf319f99db268548e Mon Sep 17 00:00:00 2001
1
+From: Chao Yu <yuchao0@huawei.com>
2
+Date: Wed, 22 Mar 2017 14:45:05 +0800
3
+Subject: [PATCH 4/4] f2fs: fix race condition in between free nid
4
+ allocator/initializer
5
+
6
+commit 30a61ddf8117c26ac5b295e1233eaa9629a94ca3 upstream.
7
+
8
+In below concurrent case, allocated nid can be loaded into free nid cache
9
+and be allocated again.
10
+
11
+Thread A				Thread B
12
+- f2fs_create
13
+ - f2fs_new_inode
14
+  - alloc_nid
15
+   - __insert_nid_to_list(ALLOC_NID_LIST)
16
+					- f2fs_balance_fs_bg
17
+					 - build_free_nids
18
+					  - __build_free_nids
19
+					   - scan_nat_page
20
+					    - add_free_nid
21
+					     - __lookup_nat_cache
22
+ - f2fs_add_link
23
+  - init_inode_metadata
24
+   - new_inode_page
25
+    - new_node_page
26
+     - set_node_addr
27
+ - alloc_nid_done
28
+  - __remove_nid_from_list(ALLOC_NID_LIST)
29
+					     - __insert_nid_to_list(FREE_NID_LIST)
30
+
31
+This patch makes nat cache lookup and free nid list operation being atomical
32
+to avoid this race condition.
33
+
34
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
35
+Signed-off-by: Chao Yu <yuchao0@huawei.com>
36
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
37
+[ Srivatsa: Backported to 4.4.y ]
38
+Signed-off-by: Srivatsa S. Bhat <srivatsa@csail.mit.edu>
39
+---
40
+ fs/f2fs/node.c | 72 +++++++++++++++++++++++++++++++++++++++++-----------------
41
+ 1 file changed, 51 insertions(+), 21 deletions(-)
42
+
43
+diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
44
+index 1b10cd3..53a023b 100644
45
+--- a/fs/f2fs/node.c
46
+@@ -1428,8 +1428,10 @@ static void __del_from_free_nid_list(struct f2fs_nm_info *nm_i,
47
+ static int add_free_nid(struct f2fs_sb_info *sbi, nid_t nid, bool build)
48
+ {
49
+ 	struct f2fs_nm_info *nm_i = NM_I(sbi);
50
+-	struct free_nid *i;
51
++	struct free_nid *i, *e;
52
+ 	struct nat_entry *ne;
53
++	int err = -EINVAL;
54
++	int ret = 0;
55
+ 
56
+ 	if (!available_free_memory(sbi, FREE_NIDS))
57
+ 		return -1;
58
+@@ -1438,35 +1440,63 @@ static int add_free_nid(struct f2fs_sb_info *sbi, nid_t nid, bool build)
59
+ 	if (unlikely(nid == 0))
60
+ 		return 0;
61
+ 
62
+-	if (build) {
63
+-		/* do not add allocated nids */
64
+-		ne = __lookup_nat_cache(nm_i, nid);
65
+-		if (ne && (!get_nat_flag(ne, IS_CHECKPOINTED) ||
66
+-				nat_get_blkaddr(ne) != NULL_ADDR))
67
+-			return 0;
68
+-	}
69
+-
70
+ 	i = f2fs_kmem_cache_alloc(free_nid_slab, GFP_NOFS);
71
+ 	i->nid = nid;
72
+ 	i->state = NID_NEW;
73
+ 
74
+-	if (radix_tree_preload(GFP_NOFS)) {
75
+-		kmem_cache_free(free_nid_slab, i);
76
+-		return 0;
77
+-	}
78
++	if (radix_tree_preload(GFP_NOFS))
79
++		goto err;
80
+ 
81
+ 	spin_lock(&nm_i->free_nid_list_lock);
82
+-	if (radix_tree_insert(&nm_i->free_nid_root, i->nid, i)) {
83
+-		spin_unlock(&nm_i->free_nid_list_lock);
84
+-		radix_tree_preload_end();
85
+-		kmem_cache_free(free_nid_slab, i);
86
+-		return 0;
87
++
88
++	if (build) {
89
++
90
++		/*
91
++		 *   Thread A             Thread B
92
++		 *  - f2fs_create
93
++		 *   - f2fs_new_inode
94
++		 *    - alloc_nid
95
++		 *     - __insert_nid_to_list(ALLOC_NID_LIST)
96
++		 *                     - f2fs_balance_fs_bg
97
++		 *                      - build_free_nids
98
++		 *                       - __build_free_nids
99
++		 *                        - scan_nat_page
100
++		 *                         - add_free_nid
101
++		 *                          - __lookup_nat_cache
102
++		 *  - f2fs_add_link
103
++		 *   - init_inode_metadata
104
++		 *    - new_inode_page
105
++		 *     - new_node_page
106
++		 *      - set_node_addr
107
++		 *  - alloc_nid_done
108
++		 *   - __remove_nid_from_list(ALLOC_NID_LIST)
109
++		 *                         - __insert_nid_to_list(FREE_NID_LIST)
110
++		 */
111
++		ne = __lookup_nat_cache(nm_i, nid);
112
++		if (ne && (!get_nat_flag(ne, IS_CHECKPOINTED) ||
113
++				nat_get_blkaddr(ne) != NULL_ADDR))
114
++			goto err_out;
115
++
116
++		e = __lookup_free_nid_list(nm_i, nid);
117
++		if (e) {
118
++			if (e->state == NID_NEW)
119
++				ret = 1;
120
++			goto err_out;
121
++		}
122
++	}
123
++	ret = 1;
124
++	err = radix_tree_insert(&nm_i->free_nid_root, i->nid, i);
125
++	if (!err) {
126
++		list_add_tail(&i->list, &nm_i->free_nid_list);
127
++		nm_i->fcnt++;
128
+ 	}
129
+-	list_add_tail(&i->list, &nm_i->free_nid_list);
130
+-	nm_i->fcnt++;
131
++err_out:
132
+ 	spin_unlock(&nm_i->free_nid_list_lock);
133
+ 	radix_tree_preload_end();
134
+-	return 1;
135
++err:
136
++	if (err)
137
++		kmem_cache_free(free_nid_slab, i);
138
++	return ret;
139
+ }
140
+ 
141
+ static void remove_free_nid(struct f2fs_nm_info *nm_i, nid_t nid)
142
+-- 
143
+2.7.4
144
+
0 145
deleted file mode 100644
... ...
@@ -1,150 +0,0 @@
1
-From 00f30dfb8966dc12d852807c1c691c28a33c966c Mon Sep 17 00:00:00 2001
2
-From: Masami Hiramatsu <mhiramat@kernel.org>
3
-Date: Tue, 12 Jun 2018 23:10:56 +0000
4
-Subject: [PATCH] kprobes/x86: Do not modify singlestep buffer while resuming
5
-
6
-commit 804dec5bda9b4fcdab5f67fe61db4a0498af5221 upstream.
7
-
8
-Do not modify singlestep execution buffer (kprobe.ainsn.insn)
9
-while resuming from single-stepping, instead, modifies
10
-the buffer to add a jump back instruction at preparing
11
-buffer.
12
-
13
-Commit 176bee4cfcec ("kprobes/x86: Set kprobes pages read-only")
14
-introduced a bug in stable 4.4.y by making singlestep buffer page
15
-read-only. Attempts to modify singlestep buffer, to insert a jump
16
-instruction, at resume_execution() lead to kernel panic.
17
-
18
-  BUG: unable to handle kernel paging request at ffffffffa0011001
19
-  IP: [<ffffffff8105711c>] resume_execution+0x14c/0x1a0
20
-  PGD 1c0f067 PUD 1c10063 PMD 42ac74067 PTE 41cc35061
21
-  Oops: 0003 [#1] SMP
22
-  Modules linked in: stap_6eaf26e7bd7018624e4c19b7486f4bb8_1857(OE) ipt_MASQUERADE(E) nf_nat_masquerade_ipv4(E) <...>
23
-  CPU: 5 PID: 1857 Comm: stapio Tainted: G           OE   4.4.136+ #1
24
-  Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 01/24/2017
25
-  task: ffff880425044940 ti: ffff88042d160000 task.ti: ffff88042d160000
26
-  RIP: 0010:[<ffffffff8105711c>]  [<ffffffff8105711c>] resume_execution+0x14c/0x1a0
27
-  RSP: 0018:ffff88043fd4aeb0  EFLAGS: 00010086
28
-  RAX: ffffffffa0011001 RBX: ffff88043fd4af58 RCX: 0000000000000006
29
-  RDX: ffffffff811b9f71 RSI: ffff88043fd4af58 RDI: 0000000000000055
30
-  RBP: ffff88043fd4aee8 R08: 0000000000000001 R09: ffff88041cce8100
31
-  R10: 0000000000000004 R11: ffff8804252d9238 R12: ffff88042c6051c0
32
-  R13: ffffffff811b9f70 R14: ffff88042d163f08 R15: ffffffffa0011000
33
-  FS:  00007f05f6439740(0000) GS:ffff88043fd40000(0000) knlGS:0000000000000000
34
-  CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
35
-  CR2: ffffffffa0011001 CR3: 000000042944a000 CR4: 0000000000160670
36
-  Stack:
37
-   ffff88043fd4fee0 0000000000000000 ffff88043fd4fee0 ffff88043fd4af58
38
-   ffff88042c6051c0 0000000000000000 00007ffd23764640 ffff88043fd4af10
39
-   ffffffff810571a8 ffff88043fd4af58 ffff880425044940 0000000000000000
40
-  Call Trace:
41
-   <#DB>
42
-   [<ffffffff810571a8>] kprobe_debug_handler+0x38/0xd0
43
-   [<ffffffff81016de2>] do_debug+0x82/0x1b0
44
-   [<ffffffff817e6aa5>] debug+0x35/0x70
45
-   <<EOE>>
46
-   [<ffffffff811bac51>] ? SyS_read+0x41/0xa0
47
-   [<ffffffff817e48a1>] entry_SYSCALL_64_fastpath+0x1e/0x95
48
-
49
-Issue was found and fix was verified by running systemtap:
50
-  stap -v -e 'probe vfs.read {printf("read performed\n"); exit()}'
51
-
52
-Fixes: 176bee4cfcec ("kprobes/x86: Set kprobes pages read-only")
53
-Cc: stable@vger.kernel.org # v4.4
54
-Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
55
-Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
56
-Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
57
-Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
58
-Cc: Borislav Petkov <bp@alien8.de>
59
-Cc: Brian Gerst <brgerst@gmail.com>
60
-Cc: David S . Miller <davem@davemloft.net>
61
-Cc: Denys Vlasenko <dvlasenk@redhat.com>
62
-Cc: H. Peter Anvin <hpa@zytor.com>
63
-Cc: Josh Poimboeuf <jpoimboe@redhat.com>
64
-Cc: Linus Torvalds <torvalds@linux-foundation.org>
65
-Cc: Peter Zijlstra <peterz@infradead.org>
66
-Cc: Thomas Gleixner <tglx@linutronix.de>
67
-Cc: Ye Xiaolong <xiaolong.ye@intel.com>
68
-Link: http://lkml.kernel.org/r/149076361560.22469.1610155860343077495.stgit@devbox
69
-Signed-off-by: Ingo Molnar <mingo@kernel.org>
70
-Reviewed-by/Acked-by: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
71
-Signed-off-by: Alexey Makhalov <amakhalov@vmware.com>
72
- arch/x86/kernel/kprobes/core.c | 42 ++++++++++++++++++++----------------------
73
- 1 file changed, 20 insertions(+), 22 deletions(-)
74
-
75
-diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
76
-index df9be5b91270..1f5c47a49e35 100644
77
-+++ b/arch/x86/kernel/kprobes/core.c
78
-@@ -411,25 +411,38 @@ void free_insn_page(void *page)
79
- 	module_memfree(page);
80
- }
81
- 
82
-+/* Prepare reljump right after instruction to boost */
83
-+static void prepare_boost(struct kprobe *p, int length)
84
-+{
85
-+	if (can_boost(p->ainsn.insn, p->addr) &&
86
-+	    MAX_INSN_SIZE - length >= RELATIVEJUMP_SIZE) {
87
-+		/*
88
-+		 * These instructions can be executed directly if it
89
-+		 * jumps back to correct address.
90
-+		 */
91
-+		synthesize_reljump(p->ainsn.insn + length, p->addr + length);
92
-+		p->ainsn.boostable = 1;
93
-+	} else {
94
-+		p->ainsn.boostable = -1;
95
-+	}
96
-+}
97
-+
98
- static int arch_copy_kprobe(struct kprobe *p)
99
- {
100
--	int ret;
101
-+	int len;
102
- 
103
- 	set_memory_rw((unsigned long)p->ainsn.insn & PAGE_MASK, 1);
104
- 
105
- 	/* Copy an instruction with recovering if other optprobe modifies it.*/
106
--	ret = __copy_instruction(p->ainsn.insn, p->addr);
107
--	if (!ret)
108
-+	len = __copy_instruction(p->ainsn.insn, p->addr);
109
-+	if (!len)
110
- 		return -EINVAL;
111
- 
112
- 	/*
113
- 	 * __copy_instruction can modify the displacement of the instruction,
114
- 	 * but it doesn't affect boostable check.
115
- 	 */
116
--	if (can_boost(p->ainsn.insn, p->addr))
117
--		p->ainsn.boostable = 0;
118
--	else
119
--		p->ainsn.boostable = -1;
120
-+	prepare_boost(p, len);
121
- 
122
- 	set_memory_ro((unsigned long)p->ainsn.insn & PAGE_MASK, 1);
123
- 
124
-@@ -894,21 +907,6 @@ static void resume_execution(struct kprobe *p, struct pt_regs *regs,
125
- 		break;
126
- 	}
127
- 
128
--	if (p->ainsn.boostable == 0) {
129
--		if ((regs->ip > copy_ip) &&
130
--		    (regs->ip - copy_ip) + 5 < MAX_INSN_SIZE) {
131
--			/*
132
--			 * These instructions can be executed directly if it
133
--			 * jumps back to correct address.
134
--			 */
135
--			synthesize_reljump((void *)regs->ip,
136
--				(void *)orig_ip + (regs->ip - copy_ip));
137
--			p->ainsn.boostable = 1;
138
--		} else {
139
--			p->ainsn.boostable = -1;
140
--		}
141
--	}
142
--
143
- 	regs->ip += orig_ip - copy_ip;
144
- 
145
- no_change:
146
-2.14.2
147
-
... ...
@@ -1,15 +1,15 @@
1 1
 %global security_hardening none
2 2
 Summary:       Kernel
3 3
 Name:          linux-esx
4
-Version:       4.4.139
5
-Release:       2%{?dist}
4
+Version:       4.4.140
5
+Release:       1%{?dist}
6 6
 License:       GPLv2
7 7
 URL:           http://www.kernel.org/
8 8
 Group:         System Environment/Kernel
9 9
 Vendor:        VMware, Inc.
10 10
 Distribution:  Photon
11 11
 Source0:       http://www.kernel.org/pub/linux/kernel/v4.x/linux-%{version}.tar.xz
12
-%define sha1 linux=ce4028904ab97c1942cc1c1b917520065529dc34
12
+%define sha1 linux=55dc1299e981cb4ef8ef0c92a4df52c2f4df4835
13 13
 Source1:       config-esx
14 14
 Patch0:        double-tcp_mem-limits.patch
15 15
 Patch1:        linux-4.4-sysctl-sched_weighted_cpuload_uses_rla.patch
... ...
@@ -23,7 +23,6 @@ Patch8:        04-quiet-boot.patch
23 23
 Patch9:        05-pv-ops.patch
24 24
 Patch10:       06-sunrpc.patch
25 25
 Patch11:       vmxnet3-1.4.6.0-avoid-calling-pskb_may_pull-with-interrupts-disabled.patch
26
-Patch12:       kprobes-x86-Do-not-modify-singlestep-buffer-while-re.patch
27 26
 Patch13:       REVERT-sched-fair-Beef-up-wake_wide.patch
28 27
 Patch14:       e1000e-prevent-div-by-zero-if-TIMINCA-is-zero.patch
29 28
 
... ...
@@ -51,7 +50,11 @@ Patch34:       0001-hwrng-rdrand-Add-RNG-driver-based-on-x86-rdrand-inst.patch
51 51
 Patch35:       0001-scsi-libsas-direct-call-probe-and-destruct.patch
52 52
 # Fix for CVE-2018-10323
53 53
 Patch36:       0001-xfs-set-format-back-to-extents-if-xfs_bmap_extents_t.patch
54
-
54
+# Fix for CVE-2017-18249 (following 4 patches)
55
+Patch37:       0001-f2fs-cover-more-area-with-nat_tree_lock.patch
56
+Patch38:       0002-Revert-f2fs-check-the-node-block-address-of-newly-al.patch
57
+Patch39:       0003-f2fs-remove-an-obsolete-variable.patch
58
+Patch40:       0004-f2fs-fix-race-condition-in-between-free-nid-allocato.patch
55 59
 
56 60
 # For Spectre
57 61
 Patch52: 0141-locking-barriers-introduce-new-observable-speculatio.patch
... ...
@@ -221,7 +224,6 @@ The Linux package contains the Linux kernel doc files
221 221
 %patch9 -p1
222 222
 %patch10 -p1
223 223
 %patch11 -p1
224
-%patch12 -p1
225 224
 %patch13 -p1
226 225
 %patch14 -p1
227 226
 
... ...
@@ -243,6 +245,10 @@ The Linux package contains the Linux kernel doc files
243 243
 %patch34 -p1
244 244
 %patch35 -p1
245 245
 %patch36 -p1
246
+%patch37 -p1
247
+%patch38 -p1
248
+%patch39 -p1
249
+%patch40 -p1
246 250
 
247 251
 %patch52 -p1
248 252
 %patch55 -p1
... ...
@@ -448,6 +454,8 @@ ln -sf linux-%{uname_r}.cfg /boot/photon.cfg
448 448
 /usr/src/linux-headers-%{uname_r}
449 449
 
450 450
 %changelog
451
+*   Mon Jul 16 2018 Srivatsa S. Bhat <srivatsa@csail.mit.edu> 4.4.140-1
452
+-   Update to version 4.4.140 and fix CVE-2017-18249
451 453
 *   Tue Jul 10 2018 Srivatsa S. Bhat <srivatsa@csail.mit.edu> 4.4.139-2
452 454
 -   Fix CVE-2017-18232 and CVE-2018-10323.
453 455
 *   Tue Jul 03 2018 Srivatsa S. Bhat <srivatsa@csail.mit.edu> 4.4.139-1
... ...
@@ -1,15 +1,15 @@
1 1
 %global security_hardening none
2 2
 Summary:        Kernel
3 3
 Name:           linux
4
-Version:    	4.4.139
5
-Release:        3%{?kat_build:.%kat_build}%{?dist}
4
+Version:    	4.4.140
5
+Release:        1%{?kat_build:.%kat_build}%{?dist}
6 6
 License:    	GPLv2
7 7
 URL:        	http://www.kernel.org/
8 8
 Group:        	System Environment/Kernel
9 9
 Vendor:         VMware, Inc.
10 10
 Distribution: 	Photon
11 11
 Source0:    	http://www.kernel.org/pub/linux/kernel/v4.x/%{name}-%{version}.tar.xz
12
-%define sha1 linux=ce4028904ab97c1942cc1c1b917520065529dc34
12
+%define sha1 linux=55dc1299e981cb4ef8ef0c92a4df52c2f4df4835
13 13
 Source1:	config
14 14
 %define ena_version 1.1.3
15 15
 Source2:    	https://github.com/amzn/amzn-drivers/archive/ena_linux_1.1.3.tar.gz
... ...
@@ -26,7 +26,6 @@ Patch7:	        vmxnet3-1.4.6.0-avoid-calling-pskb_may_pull-with-interrupts-disa
26 26
 Patch8:		perf-top-sigsegv-fix.patch
27 27
 Patch9:         REVERT-sched-fair-Beef-up-wake_wide.patch
28 28
 Patch10:        e1000e-prevent-div-by-zero-if-TIMINCA-is-zero.patch
29
-Patch11:        kprobes-x86-Do-not-modify-singlestep-buffer-while-re.patch
30 29
 Patch12:        vmxnet3-1.4.6.0-fix-lock-imbalance-in-vmxnet3_tq_xmit.patch
31 30
 Patch13:        vmxnet3-1.4.7.0-set-CHECKSUM_UNNECESSARY-for-IPv6-packets.patch
32 31
 Patch14:        vmxnet3-1.4.8.0-segCnt-can-be-1-for-LRO-packets.patch
... ...
@@ -51,6 +50,11 @@ Patch27:        0001-hwrng-rdrand-Add-RNG-driver-based-on-x86-rdrand-inst.patch
51 51
 Patch28:        0001-scsi-libsas-direct-call-probe-and-destruct.patch
52 52
 # Fix for CVE-2018-10323
53 53
 Patch29:        0001-xfs-set-format-back-to-extents-if-xfs_bmap_extents_t.patch
54
+# Fix for CVE-2017-18249 (following 4 patches)
55
+Patch30:        0001-f2fs-cover-more-area-with-nat_tree_lock.patch
56
+Patch31:        0002-Revert-f2fs-check-the-node-block-address-of-newly-al.patch
57
+Patch32:        0003-f2fs-remove-an-obsolete-variable.patch
58
+Patch33:        0004-f2fs-fix-race-condition-in-between-free-nid-allocato.patch
54 59
 
55 60
 # For Spectre
56 61
 Patch52: 0141-locking-barriers-introduce-new-observable-speculatio.patch
... ...
@@ -257,7 +261,6 @@ This package contains the 'perf' performance analysis tools for Linux kernel.
257 257
 %patch8 -p1
258 258
 %patch9 -p1
259 259
 %patch10 -p1
260
-%patch11 -p1
261 260
 %patch12 -p1
262 261
 %patch13 -p1
263 262
 %patch14 -p1
... ...
@@ -274,6 +277,10 @@ This package contains the 'perf' performance analysis tools for Linux kernel.
274 274
 %patch27 -p1
275 275
 %patch28 -p1
276 276
 %patch29 -p1
277
+%patch30 -p1
278
+%patch31 -p1
279
+%patch32 -p1
280
+%patch33 -p1
277 281
 
278 282
 %patch52 -p1
279 283
 %patch55 -p1
... ...
@@ -547,6 +554,8 @@ ln -sf %{name}-%{uname_r}.cfg /boot/photon.cfg
547 547
 /usr/share/perf-core
548 548
 
549 549
 %changelog
550
+*   Mon Jul 16 2018 Srivatsa S. Bhat <srivatsa@csail.mit.edu> 4.4.140-1
551
+-   Update to version 4.4.140 and fix CVE-2017-18249
550 552
 *   Wed Jul 11 2018 Srivatsa S. Bhat <srivatsa@csail.mit.edu> 4.4.139-3
551 553
 -   Use AppArmor security module by default.
552 554
 *   Tue Jul 10 2018 Srivatsa S. Bhat <srivatsa@csail.mit.edu> 4.4.139-2