1 |
commit: 3126ae6a6eb890b9182ee505393b5d3ea6bfa693 |
2 |
Author: Mike Pagano <mpagano <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Dec 26 15:29:19 2020 +0000 |
4 |
Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Dec 26 15:29:19 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=3126ae6a |
7 |
|
8 |
Linux patch 5.10.3 |
9 |
|
10 |
Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org> |
11 |
|
12 |
0000_README | 4 + |
13 |
1002_linux-5.10.3.patch | 1250 +++++++++++++++++++++++++++++++++++++++++++++++ |
14 |
2 files changed, 1254 insertions(+) |
15 |
|
16 |
diff --git a/0000_README b/0000_README |
17 |
index 52d8ee0..290bc2e 100644 |
18 |
--- a/0000_README |
19 |
+++ b/0000_README |
20 |
@@ -51,6 +51,10 @@ Patch: 1001_linux-5.10.2.patch |
21 |
From: http://www.kernel.org |
22 |
Desc: Linux 5.10.2 |
23 |
|
24 |
+Patch: 1002_linux-5.10.3.patch |
25 |
+From: http://www.kernel.org |
26 |
+Desc: Linux 5.10.3 |
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/1002_linux-5.10.3.patch b/1002_linux-5.10.3.patch |
33 |
new file mode 100644 |
34 |
index 0000000..68d93c6 |
35 |
--- /dev/null |
36 |
+++ b/1002_linux-5.10.3.patch |
37 |
@@ -0,0 +1,1250 @@ |
38 |
+diff --git a/Makefile b/Makefile |
39 |
+index 44f4cd2e58a80..a72bc404123d5 100644 |
40 |
+--- a/Makefile |
41 |
++++ b/Makefile |
42 |
+@@ -1,7 +1,7 @@ |
43 |
+ # SPDX-License-Identifier: GPL-2.0 |
44 |
+ VERSION = 5 |
45 |
+ PATCHLEVEL = 10 |
46 |
+-SUBLEVEL = 2 |
47 |
++SUBLEVEL = 3 |
48 |
+ EXTRAVERSION = |
49 |
+ NAME = Kleptomaniac Octopus |
50 |
+ |
51 |
+diff --git a/arch/arm/boot/dts/exynos5410-odroidxu.dts b/arch/arm/boot/dts/exynos5410-odroidxu.dts |
52 |
+index 75b4150c26d72..bd1d8499a108b 100644 |
53 |
+--- a/arch/arm/boot/dts/exynos5410-odroidxu.dts |
54 |
++++ b/arch/arm/boot/dts/exynos5410-odroidxu.dts |
55 |
+@@ -327,6 +327,8 @@ |
56 |
+ regulator-name = "vddq_lcd"; |
57 |
+ regulator-min-microvolt = <1800000>; |
58 |
+ regulator-max-microvolt = <1800000>; |
59 |
++ /* Supplies also GPK and GPJ */ |
60 |
++ regulator-always-on; |
61 |
+ }; |
62 |
+ |
63 |
+ ldo8_reg: LDO8 { |
64 |
+@@ -637,11 +639,11 @@ |
65 |
+ }; |
66 |
+ |
67 |
+ &usbdrd_dwc3_0 { |
68 |
+- dr_mode = "host"; |
69 |
++ dr_mode = "peripheral"; |
70 |
+ }; |
71 |
+ |
72 |
+ &usbdrd_dwc3_1 { |
73 |
+- dr_mode = "peripheral"; |
74 |
++ dr_mode = "host"; |
75 |
+ }; |
76 |
+ |
77 |
+ &usbdrd3_0 { |
78 |
+diff --git a/arch/arm/boot/dts/exynos5410-pinctrl.dtsi b/arch/arm/boot/dts/exynos5410-pinctrl.dtsi |
79 |
+index e5d0a2a4f6483..d0aa18443a69b 100644 |
80 |
+--- a/arch/arm/boot/dts/exynos5410-pinctrl.dtsi |
81 |
++++ b/arch/arm/boot/dts/exynos5410-pinctrl.dtsi |
82 |
+@@ -560,6 +560,34 @@ |
83 |
+ interrupt-controller; |
84 |
+ #interrupt-cells = <2>; |
85 |
+ }; |
86 |
++ |
87 |
++ usb3_1_oc: usb3-1-oc { |
88 |
++ samsung,pins = "gpk2-4", "gpk2-5"; |
89 |
++ samsung,pin-function = <EXYNOS_PIN_FUNC_2>; |
90 |
++ samsung,pin-pud = <EXYNOS_PIN_PULL_UP>; |
91 |
++ samsung,pin-drv = <EXYNOS5420_PIN_DRV_LV1>; |
92 |
++ }; |
93 |
++ |
94 |
++ usb3_1_vbusctrl: usb3-1-vbusctrl { |
95 |
++ samsung,pins = "gpk2-6", "gpk2-7"; |
96 |
++ samsung,pin-function = <EXYNOS_PIN_FUNC_2>; |
97 |
++ samsung,pin-pud = <EXYNOS_PIN_PULL_DOWN>; |
98 |
++ samsung,pin-drv = <EXYNOS5420_PIN_DRV_LV1>; |
99 |
++ }; |
100 |
++ |
101 |
++ usb3_0_oc: usb3-0-oc { |
102 |
++ samsung,pins = "gpk3-0", "gpk3-1"; |
103 |
++ samsung,pin-function = <EXYNOS_PIN_FUNC_2>; |
104 |
++ samsung,pin-pud = <EXYNOS_PIN_PULL_UP>; |
105 |
++ samsung,pin-drv = <EXYNOS5420_PIN_DRV_LV1>; |
106 |
++ }; |
107 |
++ |
108 |
++ usb3_0_vbusctrl: usb3-0-vbusctrl { |
109 |
++ samsung,pins = "gpk3-2", "gpk3-3"; |
110 |
++ samsung,pin-function = <EXYNOS_PIN_FUNC_2>; |
111 |
++ samsung,pin-pud = <EXYNOS_PIN_PULL_DOWN>; |
112 |
++ samsung,pin-drv = <EXYNOS5420_PIN_DRV_LV1>; |
113 |
++ }; |
114 |
+ }; |
115 |
+ |
116 |
+ &pinctrl_2 { |
117 |
+diff --git a/arch/arm/boot/dts/exynos5410.dtsi b/arch/arm/boot/dts/exynos5410.dtsi |
118 |
+index 60a87684b1af6..584ce62361b13 100644 |
119 |
+--- a/arch/arm/boot/dts/exynos5410.dtsi |
120 |
++++ b/arch/arm/boot/dts/exynos5410.dtsi |
121 |
+@@ -390,6 +390,8 @@ |
122 |
+ &usbdrd3_0 { |
123 |
+ clocks = <&clock CLK_USBD300>; |
124 |
+ clock-names = "usbdrd30"; |
125 |
++ pinctrl-names = "default"; |
126 |
++ pinctrl-0 = <&usb3_0_oc>, <&usb3_0_vbusctrl>; |
127 |
+ }; |
128 |
+ |
129 |
+ &usbdrd_phy0 { |
130 |
+@@ -401,6 +403,8 @@ |
131 |
+ &usbdrd3_1 { |
132 |
+ clocks = <&clock CLK_USBD301>; |
133 |
+ clock-names = "usbdrd30"; |
134 |
++ pinctrl-names = "default"; |
135 |
++ pinctrl-0 = <&usb3_1_oc>, <&usb3_1_vbusctrl>; |
136 |
+ }; |
137 |
+ |
138 |
+ &usbdrd_dwc3_1 { |
139 |
+diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c |
140 |
+index e19df6cde35d1..170c94ec00685 100644 |
141 |
+--- a/arch/x86/kernel/traps.c |
142 |
++++ b/arch/x86/kernel/traps.c |
143 |
+@@ -299,11 +299,12 @@ DEFINE_IDTENTRY_ERRORCODE(exc_alignment_check) |
144 |
+ local_irq_enable(); |
145 |
+ |
146 |
+ if (handle_user_split_lock(regs, error_code)) |
147 |
+- return; |
148 |
++ goto out; |
149 |
+ |
150 |
+ do_trap(X86_TRAP_AC, SIGBUS, "alignment check", regs, |
151 |
+ error_code, BUS_ADRALN, NULL); |
152 |
+ |
153 |
++out: |
154 |
+ local_irq_disable(); |
155 |
+ } |
156 |
+ |
157 |
+diff --git a/crypto/af_alg.c b/crypto/af_alg.c |
158 |
+index d11db80d24cd1..9acb9d2c4bcf9 100644 |
159 |
+--- a/crypto/af_alg.c |
160 |
++++ b/crypto/af_alg.c |
161 |
+@@ -147,7 +147,7 @@ static int alg_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) |
162 |
+ const u32 allowed = CRYPTO_ALG_KERN_DRIVER_ONLY; |
163 |
+ struct sock *sk = sock->sk; |
164 |
+ struct alg_sock *ask = alg_sk(sk); |
165 |
+- struct sockaddr_alg *sa = (void *)uaddr; |
166 |
++ struct sockaddr_alg_new *sa = (void *)uaddr; |
167 |
+ const struct af_alg_type *type; |
168 |
+ void *private; |
169 |
+ int err; |
170 |
+@@ -155,7 +155,11 @@ static int alg_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) |
171 |
+ if (sock->state == SS_CONNECTED) |
172 |
+ return -EINVAL; |
173 |
+ |
174 |
+- if (addr_len < sizeof(*sa)) |
175 |
++ BUILD_BUG_ON(offsetof(struct sockaddr_alg_new, salg_name) != |
176 |
++ offsetof(struct sockaddr_alg, salg_name)); |
177 |
++ BUILD_BUG_ON(offsetof(struct sockaddr_alg, salg_name) != sizeof(*sa)); |
178 |
++ |
179 |
++ if (addr_len < sizeof(*sa) + 1) |
180 |
+ return -EINVAL; |
181 |
+ |
182 |
+ /* If caller uses non-allowed flag, return error. */ |
183 |
+@@ -163,7 +167,7 @@ static int alg_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) |
184 |
+ return -EINVAL; |
185 |
+ |
186 |
+ sa->salg_type[sizeof(sa->salg_type) - 1] = 0; |
187 |
+- sa->salg_name[sizeof(sa->salg_name) + addr_len - sizeof(*sa) - 1] = 0; |
188 |
++ sa->salg_name[addr_len - sizeof(*sa) - 1] = 0; |
189 |
+ |
190 |
+ type = alg_get_type(sa->salg_type); |
191 |
+ if (PTR_ERR(type) == -ENOENT) { |
192 |
+diff --git a/drivers/hid/i2c-hid/i2c-hid-dmi-quirks.c b/drivers/hid/i2c-hid/i2c-hid-dmi-quirks.c |
193 |
+index 35f3bfc3e6f59..8e0f67455c098 100644 |
194 |
+--- a/drivers/hid/i2c-hid/i2c-hid-dmi-quirks.c |
195 |
++++ b/drivers/hid/i2c-hid/i2c-hid-dmi-quirks.c |
196 |
+@@ -405,6 +405,14 @@ static const struct dmi_system_id i2c_hid_dmi_desc_override_table[] = { |
197 |
+ }, |
198 |
+ .driver_data = (void *)&sipodev_desc |
199 |
+ }, |
200 |
++ { |
201 |
++ .ident = "Vero K147", |
202 |
++ .matches = { |
203 |
++ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "VERO"), |
204 |
++ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "K147"), |
205 |
++ }, |
206 |
++ .driver_data = (void *)&sipodev_desc |
207 |
++ }, |
208 |
+ { } /* Terminate list */ |
209 |
+ }; |
210 |
+ |
211 |
+diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c |
212 |
+index 248cc82c838e7..1b320ab581caf 100644 |
213 |
+--- a/drivers/hwtracing/coresight/coresight-etb10.c |
214 |
++++ b/drivers/hwtracing/coresight/coresight-etb10.c |
215 |
+@@ -176,6 +176,7 @@ static int etb_enable_perf(struct coresight_device *csdev, void *data) |
216 |
+ unsigned long flags; |
217 |
+ struct etb_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); |
218 |
+ struct perf_output_handle *handle = data; |
219 |
++ struct cs_buffers *buf = etm_perf_sink_config(handle); |
220 |
+ |
221 |
+ spin_lock_irqsave(&drvdata->spinlock, flags); |
222 |
+ |
223 |
+@@ -186,7 +187,7 @@ static int etb_enable_perf(struct coresight_device *csdev, void *data) |
224 |
+ } |
225 |
+ |
226 |
+ /* Get a handle on the pid of the process to monitor */ |
227 |
+- pid = task_pid_nr(handle->event->owner); |
228 |
++ pid = buf->pid; |
229 |
+ |
230 |
+ if (drvdata->pid != -1 && drvdata->pid != pid) { |
231 |
+ ret = -EBUSY; |
232 |
+@@ -383,6 +384,7 @@ static void *etb_alloc_buffer(struct coresight_device *csdev, |
233 |
+ if (!buf) |
234 |
+ return NULL; |
235 |
+ |
236 |
++ buf->pid = task_pid_nr(event->owner); |
237 |
+ buf->snapshot = overwrite; |
238 |
+ buf->nr_pages = nr_pages; |
239 |
+ buf->data_pages = pages; |
240 |
+diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c |
241 |
+index abd706b216ac9..e516e5b879e3a 100644 |
242 |
+--- a/drivers/hwtracing/coresight/coresight-etm4x-core.c |
243 |
++++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c |
244 |
+@@ -124,8 +124,8 @@ static int etm4_enable_hw(struct etmv4_drvdata *drvdata) |
245 |
+ if (coresight_timeout(drvdata->base, TRCSTATR, TRCSTATR_IDLE_BIT, 1)) |
246 |
+ dev_err(etm_dev, |
247 |
+ "timeout while waiting for Idle Trace Status\n"); |
248 |
+- |
249 |
+- writel_relaxed(config->pe_sel, drvdata->base + TRCPROCSELR); |
250 |
++ if (drvdata->nr_pe) |
251 |
++ writel_relaxed(config->pe_sel, drvdata->base + TRCPROCSELR); |
252 |
+ writel_relaxed(config->cfg, drvdata->base + TRCCONFIGR); |
253 |
+ /* nothing specific implemented */ |
254 |
+ writel_relaxed(0x0, drvdata->base + TRCAUXCTLR); |
255 |
+@@ -141,8 +141,9 @@ static int etm4_enable_hw(struct etmv4_drvdata *drvdata) |
256 |
+ writel_relaxed(config->viiectlr, drvdata->base + TRCVIIECTLR); |
257 |
+ writel_relaxed(config->vissctlr, |
258 |
+ drvdata->base + TRCVISSCTLR); |
259 |
+- writel_relaxed(config->vipcssctlr, |
260 |
+- drvdata->base + TRCVIPCSSCTLR); |
261 |
++ if (drvdata->nr_pe_cmp) |
262 |
++ writel_relaxed(config->vipcssctlr, |
263 |
++ drvdata->base + TRCVIPCSSCTLR); |
264 |
+ for (i = 0; i < drvdata->nrseqstate - 1; i++) |
265 |
+ writel_relaxed(config->seq_ctrl[i], |
266 |
+ drvdata->base + TRCSEQEVRn(i)); |
267 |
+@@ -187,13 +188,15 @@ static int etm4_enable_hw(struct etmv4_drvdata *drvdata) |
268 |
+ writeq_relaxed(config->ctxid_pid[i], |
269 |
+ drvdata->base + TRCCIDCVRn(i)); |
270 |
+ writel_relaxed(config->ctxid_mask0, drvdata->base + TRCCIDCCTLR0); |
271 |
+- writel_relaxed(config->ctxid_mask1, drvdata->base + TRCCIDCCTLR1); |
272 |
++ if (drvdata->numcidc > 4) |
273 |
++ writel_relaxed(config->ctxid_mask1, drvdata->base + TRCCIDCCTLR1); |
274 |
+ |
275 |
+ for (i = 0; i < drvdata->numvmidc; i++) |
276 |
+ writeq_relaxed(config->vmid_val[i], |
277 |
+ drvdata->base + TRCVMIDCVRn(i)); |
278 |
+ writel_relaxed(config->vmid_mask0, drvdata->base + TRCVMIDCCTLR0); |
279 |
+- writel_relaxed(config->vmid_mask1, drvdata->base + TRCVMIDCCTLR1); |
280 |
++ if (drvdata->numvmidc > 4) |
281 |
++ writel_relaxed(config->vmid_mask1, drvdata->base + TRCVMIDCCTLR1); |
282 |
+ |
283 |
+ if (!drvdata->skip_power_up) { |
284 |
+ /* |
285 |
+@@ -779,7 +782,7 @@ static void etm4_init_arch_data(void *info) |
286 |
+ * LPOVERRIDE, bit[23] implementation supports |
287 |
+ * low-power state override |
288 |
+ */ |
289 |
+- if (BMVAL(etmidr5, 23, 23)) |
290 |
++ if (BMVAL(etmidr5, 23, 23) && (!drvdata->skip_power_up)) |
291 |
+ drvdata->lpoverride = true; |
292 |
+ else |
293 |
+ drvdata->lpoverride = false; |
294 |
+@@ -1178,7 +1181,8 @@ static int etm4_cpu_save(struct etmv4_drvdata *drvdata) |
295 |
+ state = drvdata->save_state; |
296 |
+ |
297 |
+ state->trcprgctlr = readl(drvdata->base + TRCPRGCTLR); |
298 |
+- state->trcprocselr = readl(drvdata->base + TRCPROCSELR); |
299 |
++ if (drvdata->nr_pe) |
300 |
++ state->trcprocselr = readl(drvdata->base + TRCPROCSELR); |
301 |
+ state->trcconfigr = readl(drvdata->base + TRCCONFIGR); |
302 |
+ state->trcauxctlr = readl(drvdata->base + TRCAUXCTLR); |
303 |
+ state->trceventctl0r = readl(drvdata->base + TRCEVENTCTL0R); |
304 |
+@@ -1194,7 +1198,8 @@ static int etm4_cpu_save(struct etmv4_drvdata *drvdata) |
305 |
+ state->trcvictlr = readl(drvdata->base + TRCVICTLR); |
306 |
+ state->trcviiectlr = readl(drvdata->base + TRCVIIECTLR); |
307 |
+ state->trcvissctlr = readl(drvdata->base + TRCVISSCTLR); |
308 |
+- state->trcvipcssctlr = readl(drvdata->base + TRCVIPCSSCTLR); |
309 |
++ if (drvdata->nr_pe_cmp) |
310 |
++ state->trcvipcssctlr = readl(drvdata->base + TRCVIPCSSCTLR); |
311 |
+ state->trcvdctlr = readl(drvdata->base + TRCVDCTLR); |
312 |
+ state->trcvdsacctlr = readl(drvdata->base + TRCVDSACCTLR); |
313 |
+ state->trcvdarcctlr = readl(drvdata->base + TRCVDARCCTLR); |
314 |
+@@ -1240,10 +1245,12 @@ static int etm4_cpu_save(struct etmv4_drvdata *drvdata) |
315 |
+ state->trcvmidcvr[i] = readq(drvdata->base + TRCVMIDCVRn(i)); |
316 |
+ |
317 |
+ state->trccidcctlr0 = readl(drvdata->base + TRCCIDCCTLR0); |
318 |
+- state->trccidcctlr1 = readl(drvdata->base + TRCCIDCCTLR1); |
319 |
++ if (drvdata->numcidc > 4) |
320 |
++ state->trccidcctlr1 = readl(drvdata->base + TRCCIDCCTLR1); |
321 |
+ |
322 |
+ state->trcvmidcctlr0 = readl(drvdata->base + TRCVMIDCCTLR0); |
323 |
+- state->trcvmidcctlr1 = readl(drvdata->base + TRCVMIDCCTLR1); |
324 |
++ if (drvdata->numvmidc > 4) |
325 |
++ state->trcvmidcctlr1 = readl(drvdata->base + TRCVMIDCCTLR1); |
326 |
+ |
327 |
+ state->trcclaimset = readl(drvdata->base + TRCCLAIMCLR); |
328 |
+ |
329 |
+@@ -1283,7 +1290,8 @@ static void etm4_cpu_restore(struct etmv4_drvdata *drvdata) |
330 |
+ writel_relaxed(state->trcclaimset, drvdata->base + TRCCLAIMSET); |
331 |
+ |
332 |
+ writel_relaxed(state->trcprgctlr, drvdata->base + TRCPRGCTLR); |
333 |
+- writel_relaxed(state->trcprocselr, drvdata->base + TRCPROCSELR); |
334 |
++ if (drvdata->nr_pe) |
335 |
++ writel_relaxed(state->trcprocselr, drvdata->base + TRCPROCSELR); |
336 |
+ writel_relaxed(state->trcconfigr, drvdata->base + TRCCONFIGR); |
337 |
+ writel_relaxed(state->trcauxctlr, drvdata->base + TRCAUXCTLR); |
338 |
+ writel_relaxed(state->trceventctl0r, drvdata->base + TRCEVENTCTL0R); |
339 |
+@@ -1299,7 +1307,8 @@ static void etm4_cpu_restore(struct etmv4_drvdata *drvdata) |
340 |
+ writel_relaxed(state->trcvictlr, drvdata->base + TRCVICTLR); |
341 |
+ writel_relaxed(state->trcviiectlr, drvdata->base + TRCVIIECTLR); |
342 |
+ writel_relaxed(state->trcvissctlr, drvdata->base + TRCVISSCTLR); |
343 |
+- writel_relaxed(state->trcvipcssctlr, drvdata->base + TRCVIPCSSCTLR); |
344 |
++ if (drvdata->nr_pe_cmp) |
345 |
++ writel_relaxed(state->trcvipcssctlr, drvdata->base + TRCVIPCSSCTLR); |
346 |
+ writel_relaxed(state->trcvdctlr, drvdata->base + TRCVDCTLR); |
347 |
+ writel_relaxed(state->trcvdsacctlr, drvdata->base + TRCVDSACCTLR); |
348 |
+ writel_relaxed(state->trcvdarcctlr, drvdata->base + TRCVDARCCTLR); |
349 |
+@@ -1350,10 +1359,12 @@ static void etm4_cpu_restore(struct etmv4_drvdata *drvdata) |
350 |
+ drvdata->base + TRCVMIDCVRn(i)); |
351 |
+ |
352 |
+ writel_relaxed(state->trccidcctlr0, drvdata->base + TRCCIDCCTLR0); |
353 |
+- writel_relaxed(state->trccidcctlr1, drvdata->base + TRCCIDCCTLR1); |
354 |
++ if (drvdata->numcidc > 4) |
355 |
++ writel_relaxed(state->trccidcctlr1, drvdata->base + TRCCIDCCTLR1); |
356 |
+ |
357 |
+ writel_relaxed(state->trcvmidcctlr0, drvdata->base + TRCVMIDCCTLR0); |
358 |
+- writel_relaxed(state->trcvmidcctlr1, drvdata->base + TRCVMIDCCTLR1); |
359 |
++ if (drvdata->numvmidc > 4) |
360 |
++ writel_relaxed(state->trcvmidcctlr1, drvdata->base + TRCVMIDCCTLR1); |
361 |
+ |
362 |
+ writel_relaxed(state->trcclaimset, drvdata->base + TRCCLAIMSET); |
363 |
+ |
364 |
+diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h |
365 |
+index 65a29293b6cb9..f5f654ea29946 100644 |
366 |
+--- a/drivers/hwtracing/coresight/coresight-priv.h |
367 |
++++ b/drivers/hwtracing/coresight/coresight-priv.h |
368 |
+@@ -87,6 +87,7 @@ enum cs_mode { |
369 |
+ * struct cs_buffer - keep track of a recording session' specifics |
370 |
+ * @cur: index of the current buffer |
371 |
+ * @nr_pages: max number of pages granted to us |
372 |
++ * @pid: PID this cs_buffer belongs to |
373 |
+ * @offset: offset within the current buffer |
374 |
+ * @data_size: how much we collected in this run |
375 |
+ * @snapshot: is this run in snapshot mode |
376 |
+@@ -95,6 +96,7 @@ enum cs_mode { |
377 |
+ struct cs_buffers { |
378 |
+ unsigned int cur; |
379 |
+ unsigned int nr_pages; |
380 |
++ pid_t pid; |
381 |
+ unsigned long offset; |
382 |
+ local_t data_size; |
383 |
+ bool snapshot; |
384 |
+diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c |
385 |
+index 44402d413ebbd..989d965f3d901 100644 |
386 |
+--- a/drivers/hwtracing/coresight/coresight-tmc-etf.c |
387 |
++++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c |
388 |
+@@ -227,6 +227,7 @@ static int tmc_enable_etf_sink_perf(struct coresight_device *csdev, void *data) |
389 |
+ unsigned long flags; |
390 |
+ struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); |
391 |
+ struct perf_output_handle *handle = data; |
392 |
++ struct cs_buffers *buf = etm_perf_sink_config(handle); |
393 |
+ |
394 |
+ spin_lock_irqsave(&drvdata->spinlock, flags); |
395 |
+ do { |
396 |
+@@ -243,7 +244,7 @@ static int tmc_enable_etf_sink_perf(struct coresight_device *csdev, void *data) |
397 |
+ } |
398 |
+ |
399 |
+ /* Get a handle on the pid of the process to monitor */ |
400 |
+- pid = task_pid_nr(handle->event->owner); |
401 |
++ pid = buf->pid; |
402 |
+ |
403 |
+ if (drvdata->pid != -1 && drvdata->pid != pid) { |
404 |
+ ret = -EBUSY; |
405 |
+@@ -399,6 +400,7 @@ static void *tmc_alloc_etf_buffer(struct coresight_device *csdev, |
406 |
+ if (!buf) |
407 |
+ return NULL; |
408 |
+ |
409 |
++ buf->pid = task_pid_nr(event->owner); |
410 |
+ buf->snapshot = overwrite; |
411 |
+ buf->nr_pages = nr_pages; |
412 |
+ buf->data_pages = pages; |
413 |
+diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c |
414 |
+index 714f9e867e5f6..3309b1344ffc0 100644 |
415 |
+--- a/drivers/hwtracing/coresight/coresight-tmc-etr.c |
416 |
++++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c |
417 |
+@@ -217,6 +217,8 @@ static int tmc_pages_alloc(struct tmc_pages *tmc_pages, |
418 |
+ } else { |
419 |
+ page = alloc_pages_node(node, |
420 |
+ GFP_KERNEL | __GFP_ZERO, 0); |
421 |
++ if (!page) |
422 |
++ goto err; |
423 |
+ } |
424 |
+ paddr = dma_map_page(real_dev, page, 0, PAGE_SIZE, dir); |
425 |
+ if (dma_mapping_error(real_dev, paddr)) |
426 |
+@@ -1550,7 +1552,7 @@ tmc_update_etr_buffer(struct coresight_device *csdev, |
427 |
+ |
428 |
+ /* Insert barrier packets at the beginning, if there was an overflow */ |
429 |
+ if (lost) |
430 |
+- tmc_etr_buf_insert_barrier_packet(etr_buf, etr_buf->offset); |
431 |
++ tmc_etr_buf_insert_barrier_packet(etr_buf, offset); |
432 |
+ tmc_etr_sync_perf_buffer(etr_perf, offset, size); |
433 |
+ |
434 |
+ /* |
435 |
+diff --git a/drivers/md/md.c b/drivers/md/md.c |
436 |
+index 0037c6ecab650..4136bd8142894 100644 |
437 |
+--- a/drivers/md/md.c |
438 |
++++ b/drivers/md/md.c |
439 |
+@@ -7590,8 +7590,11 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode, |
440 |
+ err = -EBUSY; |
441 |
+ goto out; |
442 |
+ } |
443 |
+- WARN_ON_ONCE(test_bit(MD_CLOSING, &mddev->flags)); |
444 |
+- set_bit(MD_CLOSING, &mddev->flags); |
445 |
++ if (test_and_set_bit(MD_CLOSING, &mddev->flags)) { |
446 |
++ mutex_unlock(&mddev->open_mutex); |
447 |
++ err = -EBUSY; |
448 |
++ goto out; |
449 |
++ } |
450 |
+ did_set_md_closing = true; |
451 |
+ mutex_unlock(&mddev->open_mutex); |
452 |
+ sync_blockdev(bdev); |
453 |
+diff --git a/drivers/media/usb/msi2500/msi2500.c b/drivers/media/usb/msi2500/msi2500.c |
454 |
+index 65be6f140fe83..1c60dfb647e5c 100644 |
455 |
+--- a/drivers/media/usb/msi2500/msi2500.c |
456 |
++++ b/drivers/media/usb/msi2500/msi2500.c |
457 |
+@@ -1230,7 +1230,7 @@ static int msi2500_probe(struct usb_interface *intf, |
458 |
+ } |
459 |
+ |
460 |
+ dev->master = master; |
461 |
+- master->bus_num = 0; |
462 |
++ master->bus_num = -1; |
463 |
+ master->num_chipselect = 1; |
464 |
+ master->transfer_one_message = msi2500_transfer_one_message; |
465 |
+ spi_master_set_devdata(master, dev); |
466 |
+diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c |
467 |
+index e158d3d62056b..9ebeb031329d9 100644 |
468 |
+--- a/drivers/scsi/megaraid/megaraid_sas_base.c |
469 |
++++ b/drivers/scsi/megaraid/megaraid_sas_base.c |
470 |
+@@ -8095,7 +8095,7 @@ megasas_mgmt_fw_ioctl(struct megasas_instance *instance, |
471 |
+ int error = 0, i; |
472 |
+ void *sense = NULL; |
473 |
+ dma_addr_t sense_handle; |
474 |
+- unsigned long *sense_ptr; |
475 |
++ void *sense_ptr; |
476 |
+ u32 opcode = 0; |
477 |
+ int ret = DCMD_SUCCESS; |
478 |
+ |
479 |
+@@ -8218,6 +8218,13 @@ megasas_mgmt_fw_ioctl(struct megasas_instance *instance, |
480 |
+ } |
481 |
+ |
482 |
+ if (ioc->sense_len) { |
483 |
++ /* make sure the pointer is part of the frame */ |
484 |
++ if (ioc->sense_off > |
485 |
++ (sizeof(union megasas_frame) - sizeof(__le64))) { |
486 |
++ error = -EINVAL; |
487 |
++ goto out; |
488 |
++ } |
489 |
++ |
490 |
+ sense = dma_alloc_coherent(&instance->pdev->dev, ioc->sense_len, |
491 |
+ &sense_handle, GFP_KERNEL); |
492 |
+ if (!sense) { |
493 |
+@@ -8225,12 +8232,11 @@ megasas_mgmt_fw_ioctl(struct megasas_instance *instance, |
494 |
+ goto out; |
495 |
+ } |
496 |
+ |
497 |
+- sense_ptr = |
498 |
+- (unsigned long *) ((unsigned long)cmd->frame + ioc->sense_off); |
499 |
++ sense_ptr = (void *)cmd->frame + ioc->sense_off; |
500 |
+ if (instance->consistent_mask_64bit) |
501 |
+- *sense_ptr = cpu_to_le64(sense_handle); |
502 |
++ put_unaligned_le64(sense_handle, sense_ptr); |
503 |
+ else |
504 |
+- *sense_ptr = cpu_to_le32(sense_handle); |
505 |
++ put_unaligned_le32(sense_handle, sense_ptr); |
506 |
+ } |
507 |
+ |
508 |
+ /* |
509 |
+diff --git a/drivers/soc/tegra/fuse/speedo-tegra210.c b/drivers/soc/tegra/fuse/speedo-tegra210.c |
510 |
+index 70d3f6e1aa33d..8050742237b76 100644 |
511 |
+--- a/drivers/soc/tegra/fuse/speedo-tegra210.c |
512 |
++++ b/drivers/soc/tegra/fuse/speedo-tegra210.c |
513 |
+@@ -94,7 +94,7 @@ static int get_process_id(int value, const u32 *speedos, unsigned int num) |
514 |
+ unsigned int i; |
515 |
+ |
516 |
+ for (i = 0; i < num; i++) |
517 |
+- if (value < speedos[num]) |
518 |
++ if (value < speedos[i]) |
519 |
+ return i; |
520 |
+ |
521 |
+ return -EINVAL; |
522 |
+diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c |
523 |
+index f41cba10b86b9..828f9ad1be49c 100644 |
524 |
+--- a/drivers/tty/serial/serial_core.c |
525 |
++++ b/drivers/tty/serial/serial_core.c |
526 |
+@@ -1467,6 +1467,10 @@ static void uart_set_ldisc(struct tty_struct *tty) |
527 |
+ { |
528 |
+ struct uart_state *state = tty->driver_data; |
529 |
+ struct uart_port *uport; |
530 |
++ struct tty_port *port = &state->port; |
531 |
++ |
532 |
++ if (!tty_port_initialized(port)) |
533 |
++ return; |
534 |
+ |
535 |
+ mutex_lock(&state->port.mutex); |
536 |
+ uport = uart_port_check(state); |
537 |
+diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c |
538 |
+index 25c65accf089c..5e07a0a86d110 100644 |
539 |
+--- a/drivers/usb/chipidea/ci_hdrc_imx.c |
540 |
++++ b/drivers/usb/chipidea/ci_hdrc_imx.c |
541 |
+@@ -57,7 +57,8 @@ static const struct ci_hdrc_imx_platform_flag imx6sx_usb_data = { |
542 |
+ |
543 |
+ static const struct ci_hdrc_imx_platform_flag imx6ul_usb_data = { |
544 |
+ .flags = CI_HDRC_SUPPORTS_RUNTIME_PM | |
545 |
+- CI_HDRC_TURN_VBUS_EARLY_ON, |
546 |
++ CI_HDRC_TURN_VBUS_EARLY_ON | |
547 |
++ CI_HDRC_DISABLE_DEVICE_STREAMING, |
548 |
+ }; |
549 |
+ |
550 |
+ static const struct ci_hdrc_imx_platform_flag imx7d_usb_data = { |
551 |
+diff --git a/drivers/usb/gadget/function/f_acm.c b/drivers/usb/gadget/function/f_acm.c |
552 |
+index 46647bfac2ef8..349945e064bba 100644 |
553 |
+--- a/drivers/usb/gadget/function/f_acm.c |
554 |
++++ b/drivers/usb/gadget/function/f_acm.c |
555 |
+@@ -686,7 +686,7 @@ acm_bind(struct usb_configuration *c, struct usb_function *f) |
556 |
+ acm_ss_out_desc.bEndpointAddress = acm_fs_out_desc.bEndpointAddress; |
557 |
+ |
558 |
+ status = usb_assign_descriptors(f, acm_fs_function, acm_hs_function, |
559 |
+- acm_ss_function, NULL); |
560 |
++ acm_ss_function, acm_ss_function); |
561 |
+ if (status) |
562 |
+ goto fail; |
563 |
+ |
564 |
+diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c |
565 |
+index c727cb5de8718..f3443347874d2 100644 |
566 |
+--- a/drivers/usb/gadget/function/f_fs.c |
567 |
++++ b/drivers/usb/gadget/function/f_fs.c |
568 |
+@@ -1328,6 +1328,7 @@ static long ffs_epfile_ioctl(struct file *file, unsigned code, |
569 |
+ |
570 |
+ switch (epfile->ffs->gadget->speed) { |
571 |
+ case USB_SPEED_SUPER: |
572 |
++ case USB_SPEED_SUPER_PLUS: |
573 |
+ desc_idx = 2; |
574 |
+ break; |
575 |
+ case USB_SPEED_HIGH: |
576 |
+@@ -3174,7 +3175,8 @@ static int _ffs_func_bind(struct usb_configuration *c, |
577 |
+ } |
578 |
+ |
579 |
+ if (likely(super)) { |
580 |
+- func->function.ss_descriptors = vla_ptr(vlabuf, d, ss_descs); |
581 |
++ func->function.ss_descriptors = func->function.ssp_descriptors = |
582 |
++ vla_ptr(vlabuf, d, ss_descs); |
583 |
+ ss_len = ffs_do_descs(ffs->ss_descs_count, |
584 |
+ vla_ptr(vlabuf, d, raw_descs) + fs_len + hs_len, |
585 |
+ d_raw_descs__sz - fs_len - hs_len, |
586 |
+@@ -3584,6 +3586,7 @@ static void ffs_func_unbind(struct usb_configuration *c, |
587 |
+ func->function.fs_descriptors = NULL; |
588 |
+ func->function.hs_descriptors = NULL; |
589 |
+ func->function.ss_descriptors = NULL; |
590 |
++ func->function.ssp_descriptors = NULL; |
591 |
+ func->interfaces_nums = NULL; |
592 |
+ |
593 |
+ ffs_event_add(ffs, FUNCTIONFS_UNBIND); |
594 |
+diff --git a/drivers/usb/gadget/function/f_midi.c b/drivers/usb/gadget/function/f_midi.c |
595 |
+index 19d97940eeb93..8fff995b8dd50 100644 |
596 |
+--- a/drivers/usb/gadget/function/f_midi.c |
597 |
++++ b/drivers/usb/gadget/function/f_midi.c |
598 |
+@@ -1048,6 +1048,12 @@ static int f_midi_bind(struct usb_configuration *c, struct usb_function *f) |
599 |
+ f->ss_descriptors = usb_copy_descriptors(midi_function); |
600 |
+ if (!f->ss_descriptors) |
601 |
+ goto fail_f_midi; |
602 |
++ |
603 |
++ if (gadget_is_superspeed_plus(c->cdev->gadget)) { |
604 |
++ f->ssp_descriptors = usb_copy_descriptors(midi_function); |
605 |
++ if (!f->ssp_descriptors) |
606 |
++ goto fail_f_midi; |
607 |
++ } |
608 |
+ } |
609 |
+ |
610 |
+ kfree(midi_function); |
611 |
+diff --git a/drivers/usb/gadget/function/f_rndis.c b/drivers/usb/gadget/function/f_rndis.c |
612 |
+index 9534c8ab62a8e..0739b05a0ef7b 100644 |
613 |
+--- a/drivers/usb/gadget/function/f_rndis.c |
614 |
++++ b/drivers/usb/gadget/function/f_rndis.c |
615 |
+@@ -87,8 +87,10 @@ static inline struct f_rndis *func_to_rndis(struct usb_function *f) |
616 |
+ /* peak (theoretical) bulk transfer rate in bits-per-second */ |
617 |
+ static unsigned int bitrate(struct usb_gadget *g) |
618 |
+ { |
619 |
++ if (gadget_is_superspeed(g) && g->speed >= USB_SPEED_SUPER_PLUS) |
620 |
++ return 4250000000U; |
621 |
+ if (gadget_is_superspeed(g) && g->speed == USB_SPEED_SUPER) |
622 |
+- return 13 * 1024 * 8 * 1000 * 8; |
623 |
++ return 3750000000U; |
624 |
+ else if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH) |
625 |
+ return 13 * 512 * 8 * 1000 * 8; |
626 |
+ else |
627 |
+diff --git a/drivers/usb/mtu3/mtu3_debugfs.c b/drivers/usb/mtu3/mtu3_debugfs.c |
628 |
+index fdeade6254aec..7537bfd651af6 100644 |
629 |
+--- a/drivers/usb/mtu3/mtu3_debugfs.c |
630 |
++++ b/drivers/usb/mtu3/mtu3_debugfs.c |
631 |
+@@ -127,7 +127,7 @@ static void mtu3_debugfs_regset(struct mtu3 *mtu, void __iomem *base, |
632 |
+ struct debugfs_regset32 *regset; |
633 |
+ struct mtu3_regset *mregs; |
634 |
+ |
635 |
+- mregs = devm_kzalloc(mtu->dev, sizeof(*regset), GFP_KERNEL); |
636 |
++ mregs = devm_kzalloc(mtu->dev, sizeof(*mregs), GFP_KERNEL); |
637 |
+ if (!mregs) |
638 |
+ return; |
639 |
+ |
640 |
+diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c |
641 |
+index 56d6f6d83bd78..2c21e34235bbb 100644 |
642 |
+--- a/drivers/usb/serial/option.c |
643 |
++++ b/drivers/usb/serial/option.c |
644 |
+@@ -563,6 +563,9 @@ static void option_instat_callback(struct urb *urb); |
645 |
+ |
646 |
+ /* Device flags */ |
647 |
+ |
648 |
++/* Highest interface number which can be used with NCTRL() and RSVD() */ |
649 |
++#define FLAG_IFNUM_MAX 7 |
650 |
++ |
651 |
+ /* Interface does not support modem-control requests */ |
652 |
+ #define NCTRL(ifnum) ((BIT(ifnum) & 0xff) << 8) |
653 |
+ |
654 |
+@@ -2101,6 +2104,14 @@ static struct usb_serial_driver * const serial_drivers[] = { |
655 |
+ |
656 |
+ module_usb_serial_driver(serial_drivers, option_ids); |
657 |
+ |
658 |
++static bool iface_is_reserved(unsigned long device_flags, u8 ifnum) |
659 |
++{ |
660 |
++ if (ifnum > FLAG_IFNUM_MAX) |
661 |
++ return false; |
662 |
++ |
663 |
++ return device_flags & RSVD(ifnum); |
664 |
++} |
665 |
++ |
666 |
+ static int option_probe(struct usb_serial *serial, |
667 |
+ const struct usb_device_id *id) |
668 |
+ { |
669 |
+@@ -2117,7 +2128,7 @@ static int option_probe(struct usb_serial *serial, |
670 |
+ * the same class/subclass/protocol as the serial interfaces. Look at |
671 |
+ * the Windows driver .INF files for reserved interface numbers. |
672 |
+ */ |
673 |
+- if (device_flags & RSVD(iface_desc->bInterfaceNumber)) |
674 |
++ if (iface_is_reserved(device_flags, iface_desc->bInterfaceNumber)) |
675 |
+ return -ENODEV; |
676 |
+ |
677 |
+ /* |
678 |
+@@ -2133,6 +2144,14 @@ static int option_probe(struct usb_serial *serial, |
679 |
+ return 0; |
680 |
+ } |
681 |
+ |
682 |
++static bool iface_no_modem_control(unsigned long device_flags, u8 ifnum) |
683 |
++{ |
684 |
++ if (ifnum > FLAG_IFNUM_MAX) |
685 |
++ return false; |
686 |
++ |
687 |
++ return device_flags & NCTRL(ifnum); |
688 |
++} |
689 |
++ |
690 |
+ static int option_attach(struct usb_serial *serial) |
691 |
+ { |
692 |
+ struct usb_interface_descriptor *iface_desc; |
693 |
+@@ -2148,7 +2167,7 @@ static int option_attach(struct usb_serial *serial) |
694 |
+ |
695 |
+ iface_desc = &serial->interface->cur_altsetting->desc; |
696 |
+ |
697 |
+- if (!(device_flags & NCTRL(iface_desc->bInterfaceNumber))) |
698 |
++ if (!iface_no_modem_control(device_flags, iface_desc->bInterfaceNumber)) |
699 |
+ data->use_send_setup = 1; |
700 |
+ |
701 |
+ if (device_flags & ZLP) |
702 |
+diff --git a/fs/crypto/fscrypt_private.h b/fs/crypto/fscrypt_private.h |
703 |
+index 4f5806a3b73d7..322ecae9a7580 100644 |
704 |
+--- a/fs/crypto/fscrypt_private.h |
705 |
++++ b/fs/crypto/fscrypt_private.h |
706 |
+@@ -25,6 +25,9 @@ |
707 |
+ #define FSCRYPT_CONTEXT_V1 1 |
708 |
+ #define FSCRYPT_CONTEXT_V2 2 |
709 |
+ |
710 |
++/* Keep this in sync with include/uapi/linux/fscrypt.h */ |
711 |
++#define FSCRYPT_MODE_MAX FSCRYPT_MODE_ADIANTUM |
712 |
++ |
713 |
+ struct fscrypt_context_v1 { |
714 |
+ u8 version; /* FSCRYPT_CONTEXT_V1 */ |
715 |
+ u8 contents_encryption_mode; |
716 |
+@@ -491,9 +494,9 @@ struct fscrypt_master_key { |
717 |
+ * Per-mode encryption keys for the various types of encryption policies |
718 |
+ * that use them. Allocated and derived on-demand. |
719 |
+ */ |
720 |
+- struct fscrypt_prepared_key mk_direct_keys[__FSCRYPT_MODE_MAX + 1]; |
721 |
+- struct fscrypt_prepared_key mk_iv_ino_lblk_64_keys[__FSCRYPT_MODE_MAX + 1]; |
722 |
+- struct fscrypt_prepared_key mk_iv_ino_lblk_32_keys[__FSCRYPT_MODE_MAX + 1]; |
723 |
++ struct fscrypt_prepared_key mk_direct_keys[FSCRYPT_MODE_MAX + 1]; |
724 |
++ struct fscrypt_prepared_key mk_iv_ino_lblk_64_keys[FSCRYPT_MODE_MAX + 1]; |
725 |
++ struct fscrypt_prepared_key mk_iv_ino_lblk_32_keys[FSCRYPT_MODE_MAX + 1]; |
726 |
+ |
727 |
+ /* Hash key for inode numbers. Initialized only when needed. */ |
728 |
+ siphash_key_t mk_ino_hash_key; |
729 |
+diff --git a/fs/crypto/hooks.c b/fs/crypto/hooks.c |
730 |
+index 20b0df47fe6ab..061418be4b086 100644 |
731 |
+--- a/fs/crypto/hooks.c |
732 |
++++ b/fs/crypto/hooks.c |
733 |
+@@ -61,7 +61,7 @@ int __fscrypt_prepare_link(struct inode *inode, struct inode *dir, |
734 |
+ return err; |
735 |
+ |
736 |
+ /* ... in case we looked up no-key name before key was added */ |
737 |
+- if (dentry->d_flags & DCACHE_NOKEY_NAME) |
738 |
++ if (fscrypt_is_nokey_name(dentry)) |
739 |
+ return -ENOKEY; |
740 |
+ |
741 |
+ if (!fscrypt_has_permitted_context(dir, inode)) |
742 |
+@@ -86,7 +86,8 @@ int __fscrypt_prepare_rename(struct inode *old_dir, struct dentry *old_dentry, |
743 |
+ return err; |
744 |
+ |
745 |
+ /* ... in case we looked up no-key name(s) before key was added */ |
746 |
+- if ((old_dentry->d_flags | new_dentry->d_flags) & DCACHE_NOKEY_NAME) |
747 |
++ if (fscrypt_is_nokey_name(old_dentry) || |
748 |
++ fscrypt_is_nokey_name(new_dentry)) |
749 |
+ return -ENOKEY; |
750 |
+ |
751 |
+ if (old_dir != new_dir) { |
752 |
+diff --git a/fs/crypto/keyring.c b/fs/crypto/keyring.c |
753 |
+index 53cc552a7b8fd..d7ec52cb3d9af 100644 |
754 |
+--- a/fs/crypto/keyring.c |
755 |
++++ b/fs/crypto/keyring.c |
756 |
+@@ -44,7 +44,7 @@ static void free_master_key(struct fscrypt_master_key *mk) |
757 |
+ |
758 |
+ wipe_master_key_secret(&mk->mk_secret); |
759 |
+ |
760 |
+- for (i = 0; i <= __FSCRYPT_MODE_MAX; i++) { |
761 |
++ for (i = 0; i <= FSCRYPT_MODE_MAX; i++) { |
762 |
+ fscrypt_destroy_prepared_key(&mk->mk_direct_keys[i]); |
763 |
+ fscrypt_destroy_prepared_key(&mk->mk_iv_ino_lblk_64_keys[i]); |
764 |
+ fscrypt_destroy_prepared_key(&mk->mk_iv_ino_lblk_32_keys[i]); |
765 |
+diff --git a/fs/crypto/keysetup.c b/fs/crypto/keysetup.c |
766 |
+index d595abb8ef90d..31fb08d94f874 100644 |
767 |
+--- a/fs/crypto/keysetup.c |
768 |
++++ b/fs/crypto/keysetup.c |
769 |
+@@ -56,6 +56,8 @@ static struct fscrypt_mode * |
770 |
+ select_encryption_mode(const union fscrypt_policy *policy, |
771 |
+ const struct inode *inode) |
772 |
+ { |
773 |
++ BUILD_BUG_ON(ARRAY_SIZE(fscrypt_modes) != FSCRYPT_MODE_MAX + 1); |
774 |
++ |
775 |
+ if (S_ISREG(inode->i_mode)) |
776 |
+ return &fscrypt_modes[fscrypt_policy_contents_mode(policy)]; |
777 |
+ |
778 |
+@@ -168,7 +170,7 @@ static int setup_per_mode_enc_key(struct fscrypt_info *ci, |
779 |
+ unsigned int hkdf_infolen = 0; |
780 |
+ int err; |
781 |
+ |
782 |
+- if (WARN_ON(mode_num > __FSCRYPT_MODE_MAX)) |
783 |
++ if (WARN_ON(mode_num > FSCRYPT_MODE_MAX)) |
784 |
+ return -EINVAL; |
785 |
+ |
786 |
+ prep_key = &keys[mode_num]; |
787 |
+diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c |
788 |
+index 4441d9944b9ef..faa0f21daa684 100644 |
789 |
+--- a/fs/crypto/policy.c |
790 |
++++ b/fs/crypto/policy.c |
791 |
+@@ -175,7 +175,10 @@ static bool fscrypt_supported_v2_policy(const struct fscrypt_policy_v2 *policy, |
792 |
+ return false; |
793 |
+ } |
794 |
+ |
795 |
+- if (policy->flags & ~FSCRYPT_POLICY_FLAGS_VALID) { |
796 |
++ if (policy->flags & ~(FSCRYPT_POLICY_FLAGS_PAD_MASK | |
797 |
++ FSCRYPT_POLICY_FLAG_DIRECT_KEY | |
798 |
++ FSCRYPT_POLICY_FLAG_IV_INO_LBLK_64 | |
799 |
++ FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32)) { |
800 |
+ fscrypt_warn(inode, "Unsupported encryption flags (0x%02x)", |
801 |
+ policy->flags); |
802 |
+ return false; |
803 |
+diff --git a/fs/exfat/nls.c b/fs/exfat/nls.c |
804 |
+index 675d0e7058c5a..314d5407a1be5 100644 |
805 |
+--- a/fs/exfat/nls.c |
806 |
++++ b/fs/exfat/nls.c |
807 |
+@@ -659,7 +659,7 @@ static int exfat_load_upcase_table(struct super_block *sb, |
808 |
+ unsigned char skip = false; |
809 |
+ unsigned short *upcase_table; |
810 |
+ |
811 |
+- upcase_table = kcalloc(UTBL_COUNT, sizeof(unsigned short), GFP_KERNEL); |
812 |
++ upcase_table = kvcalloc(UTBL_COUNT, sizeof(unsigned short), GFP_KERNEL); |
813 |
+ if (!upcase_table) |
814 |
+ return -ENOMEM; |
815 |
+ |
816 |
+@@ -715,7 +715,7 @@ static int exfat_load_default_upcase_table(struct super_block *sb) |
817 |
+ unsigned short uni = 0, *upcase_table; |
818 |
+ unsigned int index = 0; |
819 |
+ |
820 |
+- upcase_table = kcalloc(UTBL_COUNT, sizeof(unsigned short), GFP_KERNEL); |
821 |
++ upcase_table = kvcalloc(UTBL_COUNT, sizeof(unsigned short), GFP_KERNEL); |
822 |
+ if (!upcase_table) |
823 |
+ return -ENOMEM; |
824 |
+ |
825 |
+@@ -803,5 +803,5 @@ load_default: |
826 |
+ |
827 |
+ void exfat_free_upcase_table(struct exfat_sb_info *sbi) |
828 |
+ { |
829 |
+- kfree(sbi->vol_utbl); |
830 |
++ kvfree(sbi->vol_utbl); |
831 |
+ } |
832 |
+diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c |
833 |
+index 33509266f5a00..793fc7db9d28f 100644 |
834 |
+--- a/fs/ext4/namei.c |
835 |
++++ b/fs/ext4/namei.c |
836 |
+@@ -2195,6 +2195,9 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry, |
837 |
+ if (!dentry->d_name.len) |
838 |
+ return -EINVAL; |
839 |
+ |
840 |
++ if (fscrypt_is_nokey_name(dentry)) |
841 |
++ return -ENOKEY; |
842 |
++ |
843 |
+ #ifdef CONFIG_UNICODE |
844 |
+ if (sb_has_strict_encoding(sb) && IS_CASEFOLDED(dir) && |
845 |
+ sb->s_encoding && utf8_validate(sb->s_encoding, &dentry->d_name)) |
846 |
+diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h |
847 |
+index cb700d7972968..9a321c52facec 100644 |
848 |
+--- a/fs/f2fs/f2fs.h |
849 |
++++ b/fs/f2fs/f2fs.h |
850 |
+@@ -3251,6 +3251,8 @@ bool f2fs_empty_dir(struct inode *dir); |
851 |
+ |
852 |
+ static inline int f2fs_add_link(struct dentry *dentry, struct inode *inode) |
853 |
+ { |
854 |
++ if (fscrypt_is_nokey_name(dentry)) |
855 |
++ return -ENOKEY; |
856 |
+ return f2fs_do_add_link(d_inode(dentry->d_parent), &dentry->d_name, |
857 |
+ inode, inode->i_ino, inode->i_mode); |
858 |
+ } |
859 |
+diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c |
860 |
+index ee861c6d9ff02..fe39e591e5b4c 100644 |
861 |
+--- a/fs/f2fs/file.c |
862 |
++++ b/fs/f2fs/file.c |
863 |
+@@ -412,9 +412,14 @@ static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence) |
864 |
+ goto fail; |
865 |
+ |
866 |
+ /* handle inline data case */ |
867 |
+- if (f2fs_has_inline_data(inode) && whence == SEEK_HOLE) { |
868 |
+- data_ofs = isize; |
869 |
+- goto found; |
870 |
++ if (f2fs_has_inline_data(inode)) { |
871 |
++ if (whence == SEEK_HOLE) { |
872 |
++ data_ofs = isize; |
873 |
++ goto found; |
874 |
++ } else if (whence == SEEK_DATA) { |
875 |
++ data_ofs = offset; |
876 |
++ goto found; |
877 |
++ } |
878 |
+ } |
879 |
+ |
880 |
+ pgofs = (pgoff_t)(offset >> PAGE_SHIFT); |
881 |
+diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c |
882 |
+index 1596502f7375c..f2a4265318f5c 100644 |
883 |
+--- a/fs/f2fs/segment.c |
884 |
++++ b/fs/f2fs/segment.c |
885 |
+@@ -4544,7 +4544,7 @@ static void init_dirty_segmap(struct f2fs_sb_info *sbi) |
886 |
+ return; |
887 |
+ |
888 |
+ mutex_lock(&dirty_i->seglist_lock); |
889 |
+- for (segno = 0; segno < MAIN_SECS(sbi); segno += blks_per_sec) { |
890 |
++ for (segno = 0; segno < MAIN_SEGS(sbi); segno += sbi->segs_per_sec) { |
891 |
+ valid_blocks = get_valid_blocks(sbi, segno, true); |
892 |
+ secno = GET_SEC_FROM_SEG(sbi, segno); |
893 |
+ |
894 |
+diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c |
895 |
+index bb02989d92b61..4f13734637660 100644 |
896 |
+--- a/fs/quota/dquot.c |
897 |
++++ b/fs/quota/dquot.c |
898 |
+@@ -2455,7 +2455,7 @@ int dquot_resume(struct super_block *sb, int type) |
899 |
+ ret = dquot_load_quota_sb(sb, cnt, dqopt->info[cnt].dqi_fmt_id, |
900 |
+ flags); |
901 |
+ if (ret < 0) |
902 |
+- vfs_cleanup_quota_inode(sb, type); |
903 |
++ vfs_cleanup_quota_inode(sb, cnt); |
904 |
+ } |
905 |
+ |
906 |
+ return ret; |
907 |
+diff --git a/fs/quota/quota_v2.c b/fs/quota/quota_v2.c |
908 |
+index e69a2bfdd81c0..c21106557a37e 100644 |
909 |
+--- a/fs/quota/quota_v2.c |
910 |
++++ b/fs/quota/quota_v2.c |
911 |
+@@ -157,6 +157,25 @@ static int v2_read_file_info(struct super_block *sb, int type) |
912 |
+ qinfo->dqi_entry_size = sizeof(struct v2r1_disk_dqblk); |
913 |
+ qinfo->dqi_ops = &v2r1_qtree_ops; |
914 |
+ } |
915 |
++ ret = -EUCLEAN; |
916 |
++ /* Some sanity checks of the read headers... */ |
917 |
++ if ((loff_t)qinfo->dqi_blocks << qinfo->dqi_blocksize_bits > |
918 |
++ i_size_read(sb_dqopt(sb)->files[type])) { |
919 |
++ quota_error(sb, "Number of blocks too big for quota file size (%llu > %llu).", |
920 |
++ (loff_t)qinfo->dqi_blocks << qinfo->dqi_blocksize_bits, |
921 |
++ i_size_read(sb_dqopt(sb)->files[type])); |
922 |
++ goto out; |
923 |
++ } |
924 |
++ if (qinfo->dqi_free_blk >= qinfo->dqi_blocks) { |
925 |
++ quota_error(sb, "Free block number too big (%u >= %u).", |
926 |
++ qinfo->dqi_free_blk, qinfo->dqi_blocks); |
927 |
++ goto out; |
928 |
++ } |
929 |
++ if (qinfo->dqi_free_entry >= qinfo->dqi_blocks) { |
930 |
++ quota_error(sb, "Block with free entry too big (%u >= %u).", |
931 |
++ qinfo->dqi_free_entry, qinfo->dqi_blocks); |
932 |
++ goto out; |
933 |
++ } |
934 |
+ ret = 0; |
935 |
+ out: |
936 |
+ up_read(&dqopt->dqio_sem); |
937 |
+diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c |
938 |
+index 155521e51ac57..08fde777c3247 100644 |
939 |
+--- a/fs/ubifs/dir.c |
940 |
++++ b/fs/ubifs/dir.c |
941 |
+@@ -270,6 +270,15 @@ done: |
942 |
+ return d_splice_alias(inode, dentry); |
943 |
+ } |
944 |
+ |
945 |
++static int ubifs_prepare_create(struct inode *dir, struct dentry *dentry, |
946 |
++ struct fscrypt_name *nm) |
947 |
++{ |
948 |
++ if (fscrypt_is_nokey_name(dentry)) |
949 |
++ return -ENOKEY; |
950 |
++ |
951 |
++ return fscrypt_setup_filename(dir, &dentry->d_name, 0, nm); |
952 |
++} |
953 |
++ |
954 |
+ static int ubifs_create(struct inode *dir, struct dentry *dentry, umode_t mode, |
955 |
+ bool excl) |
956 |
+ { |
957 |
+@@ -293,7 +302,7 @@ static int ubifs_create(struct inode *dir, struct dentry *dentry, umode_t mode, |
958 |
+ if (err) |
959 |
+ return err; |
960 |
+ |
961 |
+- err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm); |
962 |
++ err = ubifs_prepare_create(dir, dentry, &nm); |
963 |
+ if (err) |
964 |
+ goto out_budg; |
965 |
+ |
966 |
+@@ -953,7 +962,7 @@ static int ubifs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) |
967 |
+ if (err) |
968 |
+ return err; |
969 |
+ |
970 |
+- err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm); |
971 |
++ err = ubifs_prepare_create(dir, dentry, &nm); |
972 |
+ if (err) |
973 |
+ goto out_budg; |
974 |
+ |
975 |
+@@ -1038,7 +1047,7 @@ static int ubifs_mknod(struct inode *dir, struct dentry *dentry, |
976 |
+ return err; |
977 |
+ } |
978 |
+ |
979 |
+- err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm); |
980 |
++ err = ubifs_prepare_create(dir, dentry, &nm); |
981 |
+ if (err) { |
982 |
+ kfree(dev); |
983 |
+ goto out_budg; |
984 |
+@@ -1122,7 +1131,7 @@ static int ubifs_symlink(struct inode *dir, struct dentry *dentry, |
985 |
+ if (err) |
986 |
+ return err; |
987 |
+ |
988 |
+- err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm); |
989 |
++ err = ubifs_prepare_create(dir, dentry, &nm); |
990 |
+ if (err) |
991 |
+ goto out_budg; |
992 |
+ |
993 |
+diff --git a/include/linux/fscrypt.h b/include/linux/fscrypt.h |
994 |
+index a8f7a43f031bd..8e1d31c959bfa 100644 |
995 |
+--- a/include/linux/fscrypt.h |
996 |
++++ b/include/linux/fscrypt.h |
997 |
+@@ -111,6 +111,35 @@ static inline void fscrypt_handle_d_move(struct dentry *dentry) |
998 |
+ dentry->d_flags &= ~DCACHE_NOKEY_NAME; |
999 |
+ } |
1000 |
+ |
1001 |
++/** |
1002 |
++ * fscrypt_is_nokey_name() - test whether a dentry is a no-key name |
1003 |
++ * @dentry: the dentry to check |
1004 |
++ * |
1005 |
++ * This returns true if the dentry is a no-key dentry. A no-key dentry is a |
1006 |
++ * dentry that was created in an encrypted directory that hasn't had its |
1007 |
++ * encryption key added yet. Such dentries may be either positive or negative. |
1008 |
++ * |
1009 |
++ * When a filesystem is asked to create a new filename in an encrypted directory |
1010 |
++ * and the new filename's dentry is a no-key dentry, it must fail the operation |
1011 |
++ * with ENOKEY. This includes ->create(), ->mkdir(), ->mknod(), ->symlink(), |
1012 |
++ * ->rename(), and ->link(). (However, ->rename() and ->link() are already |
1013 |
++ * handled by fscrypt_prepare_rename() and fscrypt_prepare_link().) |
1014 |
++ * |
1015 |
++ * This is necessary because creating a filename requires the directory's |
1016 |
++ * encryption key, but just checking for the key on the directory inode during |
1017 |
++ * the final filesystem operation doesn't guarantee that the key was available |
1018 |
++ * during the preceding dentry lookup. And the key must have already been |
1019 |
++ * available during the dentry lookup in order for it to have been checked |
1020 |
++ * whether the filename already exists in the directory and for the new file's |
1021 |
++ * dentry not to be invalidated due to it incorrectly having the no-key flag. |
1022 |
++ * |
1023 |
++ * Return: %true if the dentry is a no-key name |
1024 |
++ */ |
1025 |
++static inline bool fscrypt_is_nokey_name(const struct dentry *dentry) |
1026 |
++{ |
1027 |
++ return dentry->d_flags & DCACHE_NOKEY_NAME; |
1028 |
++} |
1029 |
++ |
1030 |
+ /* crypto.c */ |
1031 |
+ void fscrypt_enqueue_decrypt_work(struct work_struct *); |
1032 |
+ |
1033 |
+@@ -244,6 +273,11 @@ static inline void fscrypt_handle_d_move(struct dentry *dentry) |
1034 |
+ { |
1035 |
+ } |
1036 |
+ |
1037 |
++static inline bool fscrypt_is_nokey_name(const struct dentry *dentry) |
1038 |
++{ |
1039 |
++ return false; |
1040 |
++} |
1041 |
++ |
1042 |
+ /* crypto.c */ |
1043 |
+ static inline void fscrypt_enqueue_decrypt_work(struct work_struct *work) |
1044 |
+ { |
1045 |
+diff --git a/include/uapi/linux/fscrypt.h b/include/uapi/linux/fscrypt.h |
1046 |
+index e5de603369381..9f4428be3e362 100644 |
1047 |
+--- a/include/uapi/linux/fscrypt.h |
1048 |
++++ b/include/uapi/linux/fscrypt.h |
1049 |
+@@ -20,7 +20,6 @@ |
1050 |
+ #define FSCRYPT_POLICY_FLAG_DIRECT_KEY 0x04 |
1051 |
+ #define FSCRYPT_POLICY_FLAG_IV_INO_LBLK_64 0x08 |
1052 |
+ #define FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32 0x10 |
1053 |
+-#define FSCRYPT_POLICY_FLAGS_VALID 0x1F |
1054 |
+ |
1055 |
+ /* Encryption algorithms */ |
1056 |
+ #define FSCRYPT_MODE_AES_256_XTS 1 |
1057 |
+@@ -28,7 +27,7 @@ |
1058 |
+ #define FSCRYPT_MODE_AES_128_CBC 5 |
1059 |
+ #define FSCRYPT_MODE_AES_128_CTS 6 |
1060 |
+ #define FSCRYPT_MODE_ADIANTUM 9 |
1061 |
+-#define __FSCRYPT_MODE_MAX 9 |
1062 |
++/* If adding a mode number > 9, update FSCRYPT_MODE_MAX in fscrypt_private.h */ |
1063 |
+ |
1064 |
+ /* |
1065 |
+ * Legacy policy version; ad-hoc KDF and no key verification. |
1066 |
+@@ -177,7 +176,7 @@ struct fscrypt_get_key_status_arg { |
1067 |
+ #define FS_POLICY_FLAGS_PAD_32 FSCRYPT_POLICY_FLAGS_PAD_32 |
1068 |
+ #define FS_POLICY_FLAGS_PAD_MASK FSCRYPT_POLICY_FLAGS_PAD_MASK |
1069 |
+ #define FS_POLICY_FLAG_DIRECT_KEY FSCRYPT_POLICY_FLAG_DIRECT_KEY |
1070 |
+-#define FS_POLICY_FLAGS_VALID FSCRYPT_POLICY_FLAGS_VALID |
1071 |
++#define FS_POLICY_FLAGS_VALID 0x07 /* contains old flags only */ |
1072 |
+ #define FS_ENCRYPTION_MODE_INVALID 0 /* never used */ |
1073 |
+ #define FS_ENCRYPTION_MODE_AES_256_XTS FSCRYPT_MODE_AES_256_XTS |
1074 |
+ #define FS_ENCRYPTION_MODE_AES_256_GCM 2 /* never used */ |
1075 |
+diff --git a/include/uapi/linux/if_alg.h b/include/uapi/linux/if_alg.h |
1076 |
+index 60b7c2efd921c..dc52a11ba6d15 100644 |
1077 |
+--- a/include/uapi/linux/if_alg.h |
1078 |
++++ b/include/uapi/linux/if_alg.h |
1079 |
+@@ -24,6 +24,22 @@ struct sockaddr_alg { |
1080 |
+ __u8 salg_name[64]; |
1081 |
+ }; |
1082 |
+ |
1083 |
++/* |
1084 |
++ * Linux v4.12 and later removed the 64-byte limit on salg_name[]; it's now an |
1085 |
++ * arbitrary-length field. We had to keep the original struct above for source |
1086 |
++ * compatibility with existing userspace programs, though. Use the new struct |
1087 |
++ * below if support for very long algorithm names is needed. To do this, |
1088 |
++ * allocate 'sizeof(struct sockaddr_alg_new) + strlen(algname) + 1' bytes, and |
1089 |
++ * copy algname (including the null terminator) into salg_name. |
1090 |
++ */ |
1091 |
++struct sockaddr_alg_new { |
1092 |
++ __u16 salg_family; |
1093 |
++ __u8 salg_type[14]; |
1094 |
++ __u32 salg_feat; |
1095 |
++ __u32 salg_mask; |
1096 |
++ __u8 salg_name[]; |
1097 |
++}; |
1098 |
++ |
1099 |
+ struct af_alg_iv { |
1100 |
+ __u32 ivlen; |
1101 |
+ __u8 iv[0]; |
1102 |
+diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c |
1103 |
+index f04963914366e..cbdf2a5559754 100644 |
1104 |
+--- a/net/bluetooth/hci_event.c |
1105 |
++++ b/net/bluetooth/hci_event.c |
1106 |
+@@ -5868,21 +5868,19 @@ static void hci_le_direct_adv_report_evt(struct hci_dev *hdev, |
1107 |
+ struct sk_buff *skb) |
1108 |
+ { |
1109 |
+ u8 num_reports = skb->data[0]; |
1110 |
+- void *ptr = &skb->data[1]; |
1111 |
++ struct hci_ev_le_direct_adv_info *ev = (void *)&skb->data[1]; |
1112 |
+ |
1113 |
+- hci_dev_lock(hdev); |
1114 |
++ if (!num_reports || skb->len < num_reports * sizeof(*ev) + 1) |
1115 |
++ return; |
1116 |
+ |
1117 |
+- while (num_reports--) { |
1118 |
+- struct hci_ev_le_direct_adv_info *ev = ptr; |
1119 |
++ hci_dev_lock(hdev); |
1120 |
+ |
1121 |
++ for (; num_reports; num_reports--, ev++) |
1122 |
+ process_adv_report(hdev, ev->evt_type, &ev->bdaddr, |
1123 |
+ ev->bdaddr_type, &ev->direct_addr, |
1124 |
+ ev->direct_addr_type, ev->rssi, NULL, 0, |
1125 |
+ false); |
1126 |
+ |
1127 |
+- ptr += sizeof(*ev); |
1128 |
+- } |
1129 |
+- |
1130 |
+ hci_dev_unlock(hdev); |
1131 |
+ } |
1132 |
+ |
1133 |
+diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c |
1134 |
+index 561f15b5a944e..3cd13e1bc6a70 100644 |
1135 |
+--- a/net/ipv4/ipconfig.c |
1136 |
++++ b/net/ipv4/ipconfig.c |
1137 |
+@@ -1441,7 +1441,7 @@ static int __init ip_auto_config(void) |
1138 |
+ int retries = CONF_OPEN_RETRIES; |
1139 |
+ #endif |
1140 |
+ int err; |
1141 |
+- unsigned int i; |
1142 |
++ unsigned int i, count; |
1143 |
+ |
1144 |
+ /* Initialise all name servers and NTP servers to NONE (but only if the |
1145 |
+ * "ip=" or "nfsaddrs=" kernel command line parameters weren't decoded, |
1146 |
+@@ -1575,7 +1575,7 @@ static int __init ip_auto_config(void) |
1147 |
+ if (ic_dev_mtu) |
1148 |
+ pr_cont(", mtu=%d", ic_dev_mtu); |
1149 |
+ /* Name servers (if any): */ |
1150 |
+- for (i = 0; i < CONF_NAMESERVERS_MAX; i++) { |
1151 |
++ for (i = 0, count = 0; i < CONF_NAMESERVERS_MAX; i++) { |
1152 |
+ if (ic_nameservers[i] != NONE) { |
1153 |
+ if (i == 0) |
1154 |
+ pr_info(" nameserver%u=%pI4", |
1155 |
+@@ -1583,12 +1583,14 @@ static int __init ip_auto_config(void) |
1156 |
+ else |
1157 |
+ pr_cont(", nameserver%u=%pI4", |
1158 |
+ i, &ic_nameservers[i]); |
1159 |
++ |
1160 |
++ count++; |
1161 |
+ } |
1162 |
+- if (i + 1 == CONF_NAMESERVERS_MAX) |
1163 |
++ if ((i + 1 == CONF_NAMESERVERS_MAX) && count > 0) |
1164 |
+ pr_cont("\n"); |
1165 |
+ } |
1166 |
+ /* NTP servers (if any): */ |
1167 |
+- for (i = 0; i < CONF_NTP_SERVERS_MAX; i++) { |
1168 |
++ for (i = 0, count = 0; i < CONF_NTP_SERVERS_MAX; i++) { |
1169 |
+ if (ic_ntp_servers[i] != NONE) { |
1170 |
+ if (i == 0) |
1171 |
+ pr_info(" ntpserver%u=%pI4", |
1172 |
+@@ -1596,8 +1598,10 @@ static int __init ip_auto_config(void) |
1173 |
+ else |
1174 |
+ pr_cont(", ntpserver%u=%pI4", |
1175 |
+ i, &ic_ntp_servers[i]); |
1176 |
++ |
1177 |
++ count++; |
1178 |
+ } |
1179 |
+- if (i + 1 == CONF_NTP_SERVERS_MAX) |
1180 |
++ if ((i + 1 == CONF_NTP_SERVERS_MAX) && count > 0) |
1181 |
+ pr_cont("\n"); |
1182 |
+ } |
1183 |
+ #endif /* !SILENT */ |
1184 |
+diff --git a/net/wireless/core.h b/net/wireless/core.h |
1185 |
+index e3e9686859d45..7df91f9402124 100644 |
1186 |
+--- a/net/wireless/core.h |
1187 |
++++ b/net/wireless/core.h |
1188 |
+@@ -433,6 +433,8 @@ void cfg80211_sme_abandon_assoc(struct wireless_dev *wdev); |
1189 |
+ |
1190 |
+ /* internal helpers */ |
1191 |
+ bool cfg80211_supported_cipher_suite(struct wiphy *wiphy, u32 cipher); |
1192 |
++bool cfg80211_valid_key_idx(struct cfg80211_registered_device *rdev, |
1193 |
++ int key_idx, bool pairwise); |
1194 |
+ int cfg80211_validate_key_settings(struct cfg80211_registered_device *rdev, |
1195 |
+ struct key_params *params, int key_idx, |
1196 |
+ bool pairwise, const u8 *mac_addr); |
1197 |
+diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c |
1198 |
+index f67ddf2cebcbe..535e34a84d651 100644 |
1199 |
+--- a/net/wireless/nl80211.c |
1200 |
++++ b/net/wireless/nl80211.c |
1201 |
+@@ -4260,9 +4260,6 @@ static int nl80211_del_key(struct sk_buff *skb, struct genl_info *info) |
1202 |
+ if (err) |
1203 |
+ return err; |
1204 |
+ |
1205 |
+- if (key.idx < 0) |
1206 |
+- return -EINVAL; |
1207 |
+- |
1208 |
+ if (info->attrs[NL80211_ATTR_MAC]) |
1209 |
+ mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]); |
1210 |
+ |
1211 |
+@@ -4278,6 +4275,10 @@ static int nl80211_del_key(struct sk_buff *skb, struct genl_info *info) |
1212 |
+ key.type != NL80211_KEYTYPE_GROUP) |
1213 |
+ return -EINVAL; |
1214 |
+ |
1215 |
++ if (!cfg80211_valid_key_idx(rdev, key.idx, |
1216 |
++ key.type == NL80211_KEYTYPE_PAIRWISE)) |
1217 |
++ return -EINVAL; |
1218 |
++ |
1219 |
+ if (!rdev->ops->del_key) |
1220 |
+ return -EOPNOTSUPP; |
1221 |
+ |
1222 |
+diff --git a/net/wireless/util.c b/net/wireless/util.c |
1223 |
+index f01746894a4e9..e4247c3543566 100644 |
1224 |
+--- a/net/wireless/util.c |
1225 |
++++ b/net/wireless/util.c |
1226 |
+@@ -272,18 +272,53 @@ bool cfg80211_supported_cipher_suite(struct wiphy *wiphy, u32 cipher) |
1227 |
+ return false; |
1228 |
+ } |
1229 |
+ |
1230 |
+-int cfg80211_validate_key_settings(struct cfg80211_registered_device *rdev, |
1231 |
+- struct key_params *params, int key_idx, |
1232 |
+- bool pairwise, const u8 *mac_addr) |
1233 |
++static bool |
1234 |
++cfg80211_igtk_cipher_supported(struct cfg80211_registered_device *rdev) |
1235 |
+ { |
1236 |
+- int max_key_idx = 5; |
1237 |
++ struct wiphy *wiphy = &rdev->wiphy; |
1238 |
++ int i; |
1239 |
++ |
1240 |
++ for (i = 0; i < wiphy->n_cipher_suites; i++) { |
1241 |
++ switch (wiphy->cipher_suites[i]) { |
1242 |
++ case WLAN_CIPHER_SUITE_AES_CMAC: |
1243 |
++ case WLAN_CIPHER_SUITE_BIP_CMAC_256: |
1244 |
++ case WLAN_CIPHER_SUITE_BIP_GMAC_128: |
1245 |
++ case WLAN_CIPHER_SUITE_BIP_GMAC_256: |
1246 |
++ return true; |
1247 |
++ } |
1248 |
++ } |
1249 |
++ |
1250 |
++ return false; |
1251 |
++} |
1252 |
+ |
1253 |
+- if (wiphy_ext_feature_isset(&rdev->wiphy, |
1254 |
+- NL80211_EXT_FEATURE_BEACON_PROTECTION) || |
1255 |
+- wiphy_ext_feature_isset(&rdev->wiphy, |
1256 |
+- NL80211_EXT_FEATURE_BEACON_PROTECTION_CLIENT)) |
1257 |
++bool cfg80211_valid_key_idx(struct cfg80211_registered_device *rdev, |
1258 |
++ int key_idx, bool pairwise) |
1259 |
++{ |
1260 |
++ int max_key_idx; |
1261 |
++ |
1262 |
++ if (pairwise) |
1263 |
++ max_key_idx = 3; |
1264 |
++ else if (wiphy_ext_feature_isset(&rdev->wiphy, |
1265 |
++ NL80211_EXT_FEATURE_BEACON_PROTECTION) || |
1266 |
++ wiphy_ext_feature_isset(&rdev->wiphy, |
1267 |
++ NL80211_EXT_FEATURE_BEACON_PROTECTION_CLIENT)) |
1268 |
+ max_key_idx = 7; |
1269 |
++ else if (cfg80211_igtk_cipher_supported(rdev)) |
1270 |
++ max_key_idx = 5; |
1271 |
++ else |
1272 |
++ max_key_idx = 3; |
1273 |
++ |
1274 |
+ if (key_idx < 0 || key_idx > max_key_idx) |
1275 |
++ return false; |
1276 |
++ |
1277 |
++ return true; |
1278 |
++} |
1279 |
++ |
1280 |
++int cfg80211_validate_key_settings(struct cfg80211_registered_device *rdev, |
1281 |
++ struct key_params *params, int key_idx, |
1282 |
++ bool pairwise, const u8 *mac_addr) |
1283 |
++{ |
1284 |
++ if (!cfg80211_valid_key_idx(rdev, key_idx, pairwise)) |
1285 |
+ return -EINVAL; |
1286 |
+ |
1287 |
+ if (!pairwise && mac_addr && !(rdev->wiphy.flags & WIPHY_FLAG_IBSS_RSN)) |