1 |
commit: e6d9be74b3e7338b6962aabb831d42f3b594f44f |
2 |
Author: Alice Ferrazzi <alicef <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri May 28 12:17:14 2021 +0000 |
4 |
Commit: Alice Ferrazzi <alicef <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri May 28 12:17:25 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=e6d9be74 |
7 |
|
8 |
Linux patch 5.12.8 |
9 |
|
10 |
Signed-off-by: Alice Ferrazzi <alicef <AT> gentoo.org> |
11 |
|
12 |
0000_README | 4 + |
13 |
1007_linux-5.12.8.patch | 288 ++++++++++++++++++++++++++++++++++++++++++++++++ |
14 |
2 files changed, 292 insertions(+) |
15 |
|
16 |
diff --git a/0000_README b/0000_README |
17 |
index 22c40ca..90784e9 100644 |
18 |
--- a/0000_README |
19 |
+++ b/0000_README |
20 |
@@ -71,6 +71,10 @@ Patch: 1006_linux-5.12.7.patch |
21 |
From: http://www.kernel.org |
22 |
Desc: Linux 5.12.7 |
23 |
|
24 |
+Patch: 1007_linux-5.12.8.patch |
25 |
+From: http://www.kernel.org |
26 |
+Desc: Linux 5.12.8 |
27 |
+ |
28 |
Patch: 1500_XATTR_USER_PREFIX.patch |
29 |
From: https://bugs.gentoo.org/show_bug.cgi?id=470644 |
30 |
Desc: Support for namespace user.pax.* on tmpfs. |
31 |
|
32 |
diff --git a/1007_linux-5.12.8.patch b/1007_linux-5.12.8.patch |
33 |
new file mode 100644 |
34 |
index 0000000..1cfbe69 |
35 |
--- /dev/null |
36 |
+++ b/1007_linux-5.12.8.patch |
37 |
@@ -0,0 +1,288 @@ |
38 |
+diff --git a/Makefile b/Makefile |
39 |
+index 6a73dee7c2219..a20afcb7d2bf4 100644 |
40 |
+--- a/Makefile |
41 |
++++ b/Makefile |
42 |
+@@ -1,7 +1,7 @@ |
43 |
+ # SPDX-License-Identifier: GPL-2.0 |
44 |
+ VERSION = 5 |
45 |
+ PATCHLEVEL = 12 |
46 |
+-SUBLEVEL = 7 |
47 |
++SUBLEVEL = 8 |
48 |
+ EXTRAVERSION = |
49 |
+ NAME = Frozen Wasteland |
50 |
+ |
51 |
+diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c |
52 |
+index 48ee3deab64b1..9a6825feaf53f 100644 |
53 |
+--- a/arch/x86/kvm/svm/svm.c |
54 |
++++ b/arch/x86/kvm/svm/svm.c |
55 |
+@@ -3815,15 +3815,15 @@ static noinstr void svm_vcpu_enter_exit(struct kvm_vcpu *vcpu, |
56 |
+ * have them in state 'on' as recorded before entering guest mode. |
57 |
+ * Same as enter_from_user_mode(). |
58 |
+ * |
59 |
+- * guest_exit_irqoff() restores host context and reinstates RCU if |
60 |
+- * enabled and required. |
61 |
++ * context_tracking_guest_exit() restores host context and reinstates |
62 |
++ * RCU if enabled and required. |
63 |
+ * |
64 |
+ * This needs to be done before the below as native_read_msr() |
65 |
+ * contains a tracepoint and x86_spec_ctrl_restore_host() calls |
66 |
+ * into world and some more. |
67 |
+ */ |
68 |
+ lockdep_hardirqs_off(CALLER_ADDR0); |
69 |
+- guest_exit_irqoff(); |
70 |
++ context_tracking_guest_exit(); |
71 |
+ |
72 |
+ instrumentation_begin(); |
73 |
+ trace_hardirqs_off_finish(); |
74 |
+diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c |
75 |
+index f68ed9a1abcc9..ae63d59be38c7 100644 |
76 |
+--- a/arch/x86/kvm/vmx/vmx.c |
77 |
++++ b/arch/x86/kvm/vmx/vmx.c |
78 |
+@@ -6701,15 +6701,15 @@ static noinstr void vmx_vcpu_enter_exit(struct kvm_vcpu *vcpu, |
79 |
+ * have them in state 'on' as recorded before entering guest mode. |
80 |
+ * Same as enter_from_user_mode(). |
81 |
+ * |
82 |
+- * guest_exit_irqoff() restores host context and reinstates RCU if |
83 |
+- * enabled and required. |
84 |
++ * context_tracking_guest_exit() restores host context and reinstates |
85 |
++ * RCU if enabled and required. |
86 |
+ * |
87 |
+ * This needs to be done before the below as native_read_msr() |
88 |
+ * contains a tracepoint and x86_spec_ctrl_restore_host() calls |
89 |
+ * into world and some more. |
90 |
+ */ |
91 |
+ lockdep_hardirqs_off(CALLER_ADDR0); |
92 |
+- guest_exit_irqoff(); |
93 |
++ context_tracking_guest_exit(); |
94 |
+ |
95 |
+ instrumentation_begin(); |
96 |
+ trace_hardirqs_off_finish(); |
97 |
+diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c |
98 |
+index 87311d39f9145..86678f8b35020 100644 |
99 |
+--- a/arch/x86/kvm/x86.c |
100 |
++++ b/arch/x86/kvm/x86.c |
101 |
+@@ -9236,6 +9236,15 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) |
102 |
+ local_irq_disable(); |
103 |
+ kvm_after_interrupt(vcpu); |
104 |
+ |
105 |
++ /* |
106 |
++ * Wait until after servicing IRQs to account guest time so that any |
107 |
++ * ticks that occurred while running the guest are properly accounted |
108 |
++ * to the guest. Waiting until IRQs are enabled degrades the accuracy |
109 |
++ * of accounting via context tracking, but the loss of accuracy is |
110 |
++ * acceptable for all known use cases. |
111 |
++ */ |
112 |
++ vtime_account_guest_exit(); |
113 |
++ |
114 |
+ if (lapic_in_kernel(vcpu)) { |
115 |
+ s64 delta = vcpu->arch.apic->lapic_timer.advance_expire_delta; |
116 |
+ if (delta != S64_MIN) { |
117 |
+diff --git a/include/linux/context_tracking.h b/include/linux/context_tracking.h |
118 |
+index bceb064985214..4f4556232dcf7 100644 |
119 |
+--- a/include/linux/context_tracking.h |
120 |
++++ b/include/linux/context_tracking.h |
121 |
+@@ -131,16 +131,26 @@ static __always_inline void guest_enter_irqoff(void) |
122 |
+ } |
123 |
+ } |
124 |
+ |
125 |
+-static __always_inline void guest_exit_irqoff(void) |
126 |
++static __always_inline void context_tracking_guest_exit(void) |
127 |
+ { |
128 |
+ if (context_tracking_enabled()) |
129 |
+ __context_tracking_exit(CONTEXT_GUEST); |
130 |
++} |
131 |
+ |
132 |
+- instrumentation_begin(); |
133 |
++static __always_inline void vtime_account_guest_exit(void) |
134 |
++{ |
135 |
+ if (vtime_accounting_enabled_this_cpu()) |
136 |
+ vtime_guest_exit(current); |
137 |
+ else |
138 |
+ current->flags &= ~PF_VCPU; |
139 |
++} |
140 |
++ |
141 |
++static __always_inline void guest_exit_irqoff(void) |
142 |
++{ |
143 |
++ context_tracking_guest_exit(); |
144 |
++ |
145 |
++ instrumentation_begin(); |
146 |
++ vtime_account_guest_exit(); |
147 |
+ instrumentation_end(); |
148 |
+ } |
149 |
+ |
150 |
+@@ -159,12 +169,19 @@ static __always_inline void guest_enter_irqoff(void) |
151 |
+ instrumentation_end(); |
152 |
+ } |
153 |
+ |
154 |
++static __always_inline void context_tracking_guest_exit(void) { } |
155 |
++ |
156 |
++static __always_inline void vtime_account_guest_exit(void) |
157 |
++{ |
158 |
++ vtime_account_kernel(current); |
159 |
++ current->flags &= ~PF_VCPU; |
160 |
++} |
161 |
++ |
162 |
+ static __always_inline void guest_exit_irqoff(void) |
163 |
+ { |
164 |
+ instrumentation_begin(); |
165 |
+ /* Flush the guest cputime we spent on the guest */ |
166 |
+- vtime_account_kernel(current); |
167 |
+- current->flags &= ~PF_VCPU; |
168 |
++ vtime_account_guest_exit(); |
169 |
+ instrumentation_end(); |
170 |
+ } |
171 |
+ #endif /* CONFIG_VIRT_CPU_ACCOUNTING_GEN */ |
172 |
+diff --git a/include/net/nfc/nci_core.h b/include/net/nfc/nci_core.h |
173 |
+index 43c9c5d2bedbd..33979017b7824 100644 |
174 |
+--- a/include/net/nfc/nci_core.h |
175 |
++++ b/include/net/nfc/nci_core.h |
176 |
+@@ -298,6 +298,7 @@ int nci_nfcc_loopback(struct nci_dev *ndev, void *data, size_t data_len, |
177 |
+ struct sk_buff **resp); |
178 |
+ |
179 |
+ struct nci_hci_dev *nci_hci_allocate(struct nci_dev *ndev); |
180 |
++void nci_hci_deallocate(struct nci_dev *ndev); |
181 |
+ int nci_hci_send_event(struct nci_dev *ndev, u8 gate, u8 event, |
182 |
+ const u8 *param, size_t param_len); |
183 |
+ int nci_hci_send_cmd(struct nci_dev *ndev, u8 gate, |
184 |
+diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c |
185 |
+index 7fa6fc6bedf1f..21247e49fe82b 100644 |
186 |
+--- a/kernel/bpf/verifier.c |
187 |
++++ b/kernel/bpf/verifier.c |
188 |
+@@ -5863,18 +5863,10 @@ enum { |
189 |
+ }; |
190 |
+ |
191 |
+ static int retrieve_ptr_limit(const struct bpf_reg_state *ptr_reg, |
192 |
+- const struct bpf_reg_state *off_reg, |
193 |
+- u32 *alu_limit, u8 opcode) |
194 |
++ u32 *alu_limit, bool mask_to_left) |
195 |
+ { |
196 |
+- bool off_is_neg = off_reg->smin_value < 0; |
197 |
+- bool mask_to_left = (opcode == BPF_ADD && off_is_neg) || |
198 |
+- (opcode == BPF_SUB && !off_is_neg); |
199 |
+ u32 max = 0, ptr_limit = 0; |
200 |
+ |
201 |
+- if (!tnum_is_const(off_reg->var_off) && |
202 |
+- (off_reg->smin_value < 0) != (off_reg->smax_value < 0)) |
203 |
+- return REASON_BOUNDS; |
204 |
+- |
205 |
+ switch (ptr_reg->type) { |
206 |
+ case PTR_TO_STACK: |
207 |
+ /* Offset 0 is out-of-bounds, but acceptable start for the |
208 |
+@@ -5940,15 +5932,20 @@ static bool sanitize_needed(u8 opcode) |
209 |
+ return opcode == BPF_ADD || opcode == BPF_SUB; |
210 |
+ } |
211 |
+ |
212 |
++struct bpf_sanitize_info { |
213 |
++ struct bpf_insn_aux_data aux; |
214 |
++ bool mask_to_left; |
215 |
++}; |
216 |
++ |
217 |
+ static int sanitize_ptr_alu(struct bpf_verifier_env *env, |
218 |
+ struct bpf_insn *insn, |
219 |
+ const struct bpf_reg_state *ptr_reg, |
220 |
+ const struct bpf_reg_state *off_reg, |
221 |
+ struct bpf_reg_state *dst_reg, |
222 |
+- struct bpf_insn_aux_data *tmp_aux, |
223 |
++ struct bpf_sanitize_info *info, |
224 |
+ const bool commit_window) |
225 |
+ { |
226 |
+- struct bpf_insn_aux_data *aux = commit_window ? cur_aux(env) : tmp_aux; |
227 |
++ struct bpf_insn_aux_data *aux = commit_window ? cur_aux(env) : &info->aux; |
228 |
+ struct bpf_verifier_state *vstate = env->cur_state; |
229 |
+ bool off_is_imm = tnum_is_const(off_reg->var_off); |
230 |
+ bool off_is_neg = off_reg->smin_value < 0; |
231 |
+@@ -5969,7 +5966,16 @@ static int sanitize_ptr_alu(struct bpf_verifier_env *env, |
232 |
+ if (vstate->speculative) |
233 |
+ goto do_sim; |
234 |
+ |
235 |
+- err = retrieve_ptr_limit(ptr_reg, off_reg, &alu_limit, opcode); |
236 |
++ if (!commit_window) { |
237 |
++ if (!tnum_is_const(off_reg->var_off) && |
238 |
++ (off_reg->smin_value < 0) != (off_reg->smax_value < 0)) |
239 |
++ return REASON_BOUNDS; |
240 |
++ |
241 |
++ info->mask_to_left = (opcode == BPF_ADD && off_is_neg) || |
242 |
++ (opcode == BPF_SUB && !off_is_neg); |
243 |
++ } |
244 |
++ |
245 |
++ err = retrieve_ptr_limit(ptr_reg, &alu_limit, info->mask_to_left); |
246 |
+ if (err < 0) |
247 |
+ return err; |
248 |
+ |
249 |
+@@ -5977,8 +5983,8 @@ static int sanitize_ptr_alu(struct bpf_verifier_env *env, |
250 |
+ /* In commit phase we narrow the masking window based on |
251 |
+ * the observed pointer move after the simulated operation. |
252 |
+ */ |
253 |
+- alu_state = tmp_aux->alu_state; |
254 |
+- alu_limit = abs(tmp_aux->alu_limit - alu_limit); |
255 |
++ alu_state = info->aux.alu_state; |
256 |
++ alu_limit = abs(info->aux.alu_limit - alu_limit); |
257 |
+ } else { |
258 |
+ alu_state = off_is_neg ? BPF_ALU_NEG_VALUE : 0; |
259 |
+ alu_state |= off_is_imm ? BPF_ALU_IMMEDIATE : 0; |
260 |
+@@ -5993,8 +5999,12 @@ do_sim: |
261 |
+ /* If we're in commit phase, we're done here given we already |
262 |
+ * pushed the truncated dst_reg into the speculative verification |
263 |
+ * stack. |
264 |
++ * |
265 |
++ * Also, when register is a known constant, we rewrite register-based |
266 |
++ * operation to immediate-based, and thus do not need masking (and as |
267 |
++ * a consequence, do not need to simulate the zero-truncation either). |
268 |
+ */ |
269 |
+- if (commit_window) |
270 |
++ if (commit_window || off_is_imm) |
271 |
+ return 0; |
272 |
+ |
273 |
+ /* Simulate and find potential out-of-bounds access under |
274 |
+@@ -6139,7 +6149,7 @@ static int adjust_ptr_min_max_vals(struct bpf_verifier_env *env, |
275 |
+ smin_ptr = ptr_reg->smin_value, smax_ptr = ptr_reg->smax_value; |
276 |
+ u64 umin_val = off_reg->umin_value, umax_val = off_reg->umax_value, |
277 |
+ umin_ptr = ptr_reg->umin_value, umax_ptr = ptr_reg->umax_value; |
278 |
+- struct bpf_insn_aux_data tmp_aux = {}; |
279 |
++ struct bpf_sanitize_info info = {}; |
280 |
+ u8 opcode = BPF_OP(insn->code); |
281 |
+ u32 dst = insn->dst_reg; |
282 |
+ int ret; |
283 |
+@@ -6208,7 +6218,7 @@ static int adjust_ptr_min_max_vals(struct bpf_verifier_env *env, |
284 |
+ |
285 |
+ if (sanitize_needed(opcode)) { |
286 |
+ ret = sanitize_ptr_alu(env, insn, ptr_reg, off_reg, dst_reg, |
287 |
+- &tmp_aux, false); |
288 |
++ &info, false); |
289 |
+ if (ret < 0) |
290 |
+ return sanitize_err(env, insn, ret, off_reg, dst_reg); |
291 |
+ } |
292 |
+@@ -6349,7 +6359,7 @@ static int adjust_ptr_min_max_vals(struct bpf_verifier_env *env, |
293 |
+ return -EACCES; |
294 |
+ if (sanitize_needed(opcode)) { |
295 |
+ ret = sanitize_ptr_alu(env, insn, dst_reg, off_reg, dst_reg, |
296 |
+- &tmp_aux, true); |
297 |
++ &info, true); |
298 |
+ if (ret < 0) |
299 |
+ return sanitize_err(env, insn, ret, off_reg, dst_reg); |
300 |
+ } |
301 |
+diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c |
302 |
+index 59257400697d1..142d71c8d6521 100644 |
303 |
+--- a/net/nfc/nci/core.c |
304 |
++++ b/net/nfc/nci/core.c |
305 |
+@@ -1191,6 +1191,7 @@ EXPORT_SYMBOL(nci_allocate_device); |
306 |
+ void nci_free_device(struct nci_dev *ndev) |
307 |
+ { |
308 |
+ nfc_free_device(ndev->nfc_dev); |
309 |
++ nci_hci_deallocate(ndev); |
310 |
+ kfree(ndev); |
311 |
+ } |
312 |
+ EXPORT_SYMBOL(nci_free_device); |
313 |
+diff --git a/net/nfc/nci/hci.c b/net/nfc/nci/hci.c |
314 |
+index 6b275a387a92a..96865142104f4 100644 |
315 |
+--- a/net/nfc/nci/hci.c |
316 |
++++ b/net/nfc/nci/hci.c |
317 |
+@@ -792,3 +792,8 @@ struct nci_hci_dev *nci_hci_allocate(struct nci_dev *ndev) |
318 |
+ |
319 |
+ return hdev; |
320 |
+ } |
321 |
++ |
322 |
++void nci_hci_deallocate(struct nci_dev *ndev) |
323 |
++{ |
324 |
++ kfree(ndev->hci_dev); |
325 |
++} |