1 |
commit: 626f2c8ce77608ff669ec8d0e1ee7571f3f28c56 |
2 |
Author: Mike Pagano <mpagano <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Dec 1 15:04:28 2018 +0000 |
4 |
Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Dec 1 15:04:28 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=626f2c8c |
7 |
|
8 |
proj/linux-patches: Linux patch 4.9.142 |
9 |
|
10 |
Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org> |
11 |
|
12 |
0000_README | 4 + |
13 |
1141_linux-4.9.142.patch | 3926 ++++++++++++++++++++++++++++++++++++++++++++++ |
14 |
2 files changed, 3930 insertions(+) |
15 |
|
16 |
diff --git a/0000_README b/0000_README |
17 |
index 2838e5f..1aec075 100644 |
18 |
--- a/0000_README |
19 |
+++ b/0000_README |
20 |
@@ -607,6 +607,10 @@ Patch: 1140_linux-4.9.141.patch |
21 |
From: http://www.kernel.org |
22 |
Desc: Linux 4.9.141 |
23 |
|
24 |
+Patch: 1141_linux-4.9.142.patch |
25 |
+From: http://www.kernel.org |
26 |
+Desc: Linux 4.9.142 |
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/1141_linux-4.9.142.patch b/1141_linux-4.9.142.patch |
33 |
new file mode 100644 |
34 |
index 0000000..2958496 |
35 |
--- /dev/null |
36 |
+++ b/1141_linux-4.9.142.patch |
37 |
@@ -0,0 +1,3926 @@ |
38 |
+diff --git a/Documentation/sysctl/fs.txt b/Documentation/sysctl/fs.txt |
39 |
+index 35e17f748ca7..af5859b2d0f9 100644 |
40 |
+--- a/Documentation/sysctl/fs.txt |
41 |
++++ b/Documentation/sysctl/fs.txt |
42 |
+@@ -34,7 +34,9 @@ Currently, these files are in /proc/sys/fs: |
43 |
+ - overflowgid |
44 |
+ - pipe-user-pages-hard |
45 |
+ - pipe-user-pages-soft |
46 |
++- protected_fifos |
47 |
+ - protected_hardlinks |
48 |
++- protected_regular |
49 |
+ - protected_symlinks |
50 |
+ - suid_dumpable |
51 |
+ - super-max |
52 |
+@@ -182,6 +184,24 @@ applied. |
53 |
+ |
54 |
+ ============================================================== |
55 |
+ |
56 |
++protected_fifos: |
57 |
++ |
58 |
++The intent of this protection is to avoid unintentional writes to |
59 |
++an attacker-controlled FIFO, where a program expected to create a regular |
60 |
++file. |
61 |
++ |
62 |
++When set to "0", writing to FIFOs is unrestricted. |
63 |
++ |
64 |
++When set to "1" don't allow O_CREAT open on FIFOs that we don't own |
65 |
++in world writable sticky directories, unless they are owned by the |
66 |
++owner of the directory. |
67 |
++ |
68 |
++When set to "2" it also applies to group writable sticky directories. |
69 |
++ |
70 |
++This protection is based on the restrictions in Openwall. |
71 |
++ |
72 |
++============================================================== |
73 |
++ |
74 |
+ protected_hardlinks: |
75 |
+ |
76 |
+ A long-standing class of security issues is the hardlink-based |
77 |
+@@ -202,6 +222,22 @@ This protection is based on the restrictions in Openwall and grsecurity. |
78 |
+ |
79 |
+ ============================================================== |
80 |
+ |
81 |
++protected_regular: |
82 |
++ |
83 |
++This protection is similar to protected_fifos, but it |
84 |
++avoids writes to an attacker-controlled regular file, where a program |
85 |
++expected to create one. |
86 |
++ |
87 |
++When set to "0", writing to regular files is unrestricted. |
88 |
++ |
89 |
++When set to "1" don't allow O_CREAT open on regular files that we |
90 |
++don't own in world writable sticky directories, unless they are |
91 |
++owned by the owner of the directory. |
92 |
++ |
93 |
++When set to "2" it also applies to group writable sticky directories. |
94 |
++ |
95 |
++============================================================== |
96 |
++ |
97 |
+ protected_symlinks: |
98 |
+ |
99 |
+ A long-standing class of security issues is the symlink-based |
100 |
+diff --git a/MAINTAINERS b/MAINTAINERS |
101 |
+index 63cefa62324c..4f559f5b3a89 100644 |
102 |
+--- a/MAINTAINERS |
103 |
++++ b/MAINTAINERS |
104 |
+@@ -11469,6 +11469,7 @@ F: arch/alpha/kernel/srm_env.c |
105 |
+ |
106 |
+ STABLE BRANCH |
107 |
+ M: Greg Kroah-Hartman <gregkh@×××××××××××××××.org> |
108 |
++M: Sasha Levin <sashal@××××××.org> |
109 |
+ L: stable@×××××××××××.org |
110 |
+ S: Supported |
111 |
+ F: Documentation/stable_kernel_rules.txt |
112 |
+diff --git a/Makefile b/Makefile |
113 |
+index 8eba73521a7f..72ed8ff90329 100644 |
114 |
+--- a/Makefile |
115 |
++++ b/Makefile |
116 |
+@@ -1,6 +1,6 @@ |
117 |
+ VERSION = 4 |
118 |
+ PATCHLEVEL = 9 |
119 |
+-SUBLEVEL = 141 |
120 |
++SUBLEVEL = 142 |
121 |
+ EXTRAVERSION = |
122 |
+ NAME = Roaring Lionus |
123 |
+ |
124 |
+diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile |
125 |
+index 92110c2c6c59..ee94597773fa 100644 |
126 |
+--- a/arch/arm64/Makefile |
127 |
++++ b/arch/arm64/Makefile |
128 |
+@@ -10,7 +10,7 @@ |
129 |
+ # |
130 |
+ # Copyright (C) 1995-2001 by Russell King |
131 |
+ |
132 |
+-LDFLAGS_vmlinux :=-p --no-undefined -X |
133 |
++LDFLAGS_vmlinux :=--no-undefined -X |
134 |
+ CPPFLAGS_vmlinux.lds = -DTEXT_OFFSET=$(TEXT_OFFSET) |
135 |
+ GZFLAGS :=-9 |
136 |
+ |
137 |
+diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h |
138 |
+index f6fda8482f60..3b10f532c28e 100644 |
139 |
+--- a/arch/powerpc/include/asm/io.h |
140 |
++++ b/arch/powerpc/include/asm/io.h |
141 |
+@@ -333,19 +333,13 @@ extern void _memcpy_toio(volatile void __iomem *dest, const void *src, |
142 |
+ * their hooks, a bitfield is reserved for use by the platform near the |
143 |
+ * top of MMIO addresses (not PIO, those have to cope the hard way). |
144 |
+ * |
145 |
+- * This bit field is 12 bits and is at the top of the IO virtual |
146 |
+- * addresses PCI_IO_INDIRECT_TOKEN_MASK. |
147 |
++ * The highest address in the kernel virtual space are: |
148 |
+ * |
149 |
+- * The kernel virtual space is thus: |
150 |
++ * d0003fffffffffff # with Hash MMU |
151 |
++ * c00fffffffffffff # with Radix MMU |
152 |
+ * |
153 |
+- * 0xD000000000000000 : vmalloc |
154 |
+- * 0xD000080000000000 : PCI PHB IO space |
155 |
+- * 0xD000080080000000 : ioremap |
156 |
+- * 0xD0000fffffffffff : end of ioremap region |
157 |
+- * |
158 |
+- * Since the top 4 bits are reserved as the region ID, we use thus |
159 |
+- * the next 12 bits and keep 4 bits available for the future if the |
160 |
+- * virtual address space is ever to be extended. |
161 |
++ * The top 4 bits are reserved as the region ID on hash, leaving us 8 bits |
162 |
++ * that can be used for the field. |
163 |
+ * |
164 |
+ * The direct IO mapping operations will then mask off those bits |
165 |
+ * before doing the actual access, though that only happen when |
166 |
+@@ -357,8 +351,8 @@ extern void _memcpy_toio(volatile void __iomem *dest, const void *src, |
167 |
+ */ |
168 |
+ |
169 |
+ #ifdef CONFIG_PPC_INDIRECT_MMIO |
170 |
+-#define PCI_IO_IND_TOKEN_MASK 0x0fff000000000000ul |
171 |
+-#define PCI_IO_IND_TOKEN_SHIFT 48 |
172 |
++#define PCI_IO_IND_TOKEN_SHIFT 52 |
173 |
++#define PCI_IO_IND_TOKEN_MASK (0xfful << PCI_IO_IND_TOKEN_SHIFT) |
174 |
+ #define PCI_FIX_ADDR(addr) \ |
175 |
+ ((PCI_IO_ADDR)(((unsigned long)(addr)) & ~PCI_IO_IND_TOKEN_MASK)) |
176 |
+ #define PCI_GET_ADDR_TOKEN(addr) \ |
177 |
+diff --git a/arch/powerpc/kvm/trace.h b/arch/powerpc/kvm/trace.h |
178 |
+index 2e0e67ef3544..e8cedf32345a 100644 |
179 |
+--- a/arch/powerpc/kvm/trace.h |
180 |
++++ b/arch/powerpc/kvm/trace.h |
181 |
+@@ -5,8 +5,6 @@ |
182 |
+ |
183 |
+ #undef TRACE_SYSTEM |
184 |
+ #define TRACE_SYSTEM kvm |
185 |
+-#define TRACE_INCLUDE_PATH . |
186 |
+-#define TRACE_INCLUDE_FILE trace |
187 |
+ |
188 |
+ /* |
189 |
+ * Tracepoint for guest mode entry. |
190 |
+@@ -119,4 +117,10 @@ TRACE_EVENT(kvm_check_requests, |
191 |
+ #endif /* _TRACE_KVM_H */ |
192 |
+ |
193 |
+ /* This part must be outside protection */ |
194 |
++#undef TRACE_INCLUDE_PATH |
195 |
++#undef TRACE_INCLUDE_FILE |
196 |
++ |
197 |
++#define TRACE_INCLUDE_PATH . |
198 |
++#define TRACE_INCLUDE_FILE trace |
199 |
++ |
200 |
+ #include <trace/define_trace.h> |
201 |
+diff --git a/arch/powerpc/kvm/trace_booke.h b/arch/powerpc/kvm/trace_booke.h |
202 |
+index 7ec534d1db9f..7eadbf449a1f 100644 |
203 |
+--- a/arch/powerpc/kvm/trace_booke.h |
204 |
++++ b/arch/powerpc/kvm/trace_booke.h |
205 |
+@@ -5,8 +5,6 @@ |
206 |
+ |
207 |
+ #undef TRACE_SYSTEM |
208 |
+ #define TRACE_SYSTEM kvm_booke |
209 |
+-#define TRACE_INCLUDE_PATH . |
210 |
+-#define TRACE_INCLUDE_FILE trace_booke |
211 |
+ |
212 |
+ #define kvm_trace_symbol_exit \ |
213 |
+ {0, "CRITICAL"}, \ |
214 |
+@@ -217,4 +215,11 @@ TRACE_EVENT(kvm_booke_queue_irqprio, |
215 |
+ #endif |
216 |
+ |
217 |
+ /* This part must be outside protection */ |
218 |
++ |
219 |
++#undef TRACE_INCLUDE_PATH |
220 |
++#undef TRACE_INCLUDE_FILE |
221 |
++ |
222 |
++#define TRACE_INCLUDE_PATH . |
223 |
++#define TRACE_INCLUDE_FILE trace_booke |
224 |
++ |
225 |
+ #include <trace/define_trace.h> |
226 |
+diff --git a/arch/powerpc/kvm/trace_hv.h b/arch/powerpc/kvm/trace_hv.h |
227 |
+index fb21990c0fb4..d9a21a7bd5c9 100644 |
228 |
+--- a/arch/powerpc/kvm/trace_hv.h |
229 |
++++ b/arch/powerpc/kvm/trace_hv.h |
230 |
+@@ -8,8 +8,6 @@ |
231 |
+ |
232 |
+ #undef TRACE_SYSTEM |
233 |
+ #define TRACE_SYSTEM kvm_hv |
234 |
+-#define TRACE_INCLUDE_PATH . |
235 |
+-#define TRACE_INCLUDE_FILE trace_hv |
236 |
+ |
237 |
+ #define kvm_trace_symbol_hcall \ |
238 |
+ {H_REMOVE, "H_REMOVE"}, \ |
239 |
+@@ -496,4 +494,11 @@ TRACE_EVENT(kvmppc_run_vcpu_exit, |
240 |
+ #endif /* _TRACE_KVM_HV_H */ |
241 |
+ |
242 |
+ /* This part must be outside protection */ |
243 |
++ |
244 |
++#undef TRACE_INCLUDE_PATH |
245 |
++#undef TRACE_INCLUDE_FILE |
246 |
++ |
247 |
++#define TRACE_INCLUDE_PATH . |
248 |
++#define TRACE_INCLUDE_FILE trace_hv |
249 |
++ |
250 |
+ #include <trace/define_trace.h> |
251 |
+diff --git a/arch/powerpc/kvm/trace_pr.h b/arch/powerpc/kvm/trace_pr.h |
252 |
+index d44f324184fb..e8e2b9ad4ac6 100644 |
253 |
+--- a/arch/powerpc/kvm/trace_pr.h |
254 |
++++ b/arch/powerpc/kvm/trace_pr.h |
255 |
+@@ -7,8 +7,6 @@ |
256 |
+ |
257 |
+ #undef TRACE_SYSTEM |
258 |
+ #define TRACE_SYSTEM kvm_pr |
259 |
+-#define TRACE_INCLUDE_PATH . |
260 |
+-#define TRACE_INCLUDE_FILE trace_pr |
261 |
+ |
262 |
+ TRACE_EVENT(kvm_book3s_reenter, |
263 |
+ TP_PROTO(int r, struct kvm_vcpu *vcpu), |
264 |
+@@ -271,4 +269,11 @@ TRACE_EVENT(kvm_unmap_hva, |
265 |
+ #endif /* _TRACE_KVM_H */ |
266 |
+ |
267 |
+ /* This part must be outside protection */ |
268 |
++ |
269 |
++#undef TRACE_INCLUDE_PATH |
270 |
++#undef TRACE_INCLUDE_FILE |
271 |
++ |
272 |
++#define TRACE_INCLUDE_PATH . |
273 |
++#define TRACE_INCLUDE_FILE trace_pr |
274 |
++ |
275 |
+ #include <trace/define_trace.h> |
276 |
+diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c |
277 |
+index 6cff96e0d77b..0ef83c274019 100644 |
278 |
+--- a/arch/powerpc/mm/numa.c |
279 |
++++ b/arch/powerpc/mm/numa.c |
280 |
+@@ -1289,7 +1289,7 @@ static long vphn_get_associativity(unsigned long cpu, |
281 |
+ |
282 |
+ switch (rc) { |
283 |
+ case H_FUNCTION: |
284 |
+- printk(KERN_INFO |
285 |
++ printk_once(KERN_INFO |
286 |
+ "VPHN is not supported. Disabling polling...\n"); |
287 |
+ stop_topology_update(); |
288 |
+ break; |
289 |
+diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c |
290 |
+index cb2cd04e6698..b6c85b760305 100644 |
291 |
+--- a/arch/s390/mm/gmap.c |
292 |
++++ b/arch/s390/mm/gmap.c |
293 |
+@@ -686,6 +686,8 @@ void gmap_discard(struct gmap *gmap, unsigned long from, unsigned long to) |
294 |
+ vmaddr |= gaddr & ~PMD_MASK; |
295 |
+ /* Find vma in the parent mm */ |
296 |
+ vma = find_vma(gmap->mm, vmaddr); |
297 |
++ if (!vma) |
298 |
++ continue; |
299 |
+ size = min(to - gaddr, PMD_SIZE - (gaddr & ~PMD_MASK)); |
300 |
+ zap_page_range(vma, vmaddr, size, NULL); |
301 |
+ } |
302 |
+diff --git a/arch/x86/events/intel/uncore_snb.c b/arch/x86/events/intel/uncore_snb.c |
303 |
+index a3dcc12bef4a..8c700069060b 100644 |
304 |
+--- a/arch/x86/events/intel/uncore_snb.c |
305 |
++++ b/arch/x86/events/intel/uncore_snb.c |
306 |
+@@ -14,6 +14,25 @@ |
307 |
+ #define PCI_DEVICE_ID_INTEL_SKL_HQ_IMC 0x1910 |
308 |
+ #define PCI_DEVICE_ID_INTEL_SKL_SD_IMC 0x190f |
309 |
+ #define PCI_DEVICE_ID_INTEL_SKL_SQ_IMC 0x191f |
310 |
++#define PCI_DEVICE_ID_INTEL_KBL_Y_IMC 0x590c |
311 |
++#define PCI_DEVICE_ID_INTEL_KBL_U_IMC 0x5904 |
312 |
++#define PCI_DEVICE_ID_INTEL_KBL_UQ_IMC 0x5914 |
313 |
++#define PCI_DEVICE_ID_INTEL_KBL_SD_IMC 0x590f |
314 |
++#define PCI_DEVICE_ID_INTEL_KBL_SQ_IMC 0x591f |
315 |
++#define PCI_DEVICE_ID_INTEL_CFL_2U_IMC 0x3ecc |
316 |
++#define PCI_DEVICE_ID_INTEL_CFL_4U_IMC 0x3ed0 |
317 |
++#define PCI_DEVICE_ID_INTEL_CFL_4H_IMC 0x3e10 |
318 |
++#define PCI_DEVICE_ID_INTEL_CFL_6H_IMC 0x3ec4 |
319 |
++#define PCI_DEVICE_ID_INTEL_CFL_2S_D_IMC 0x3e0f |
320 |
++#define PCI_DEVICE_ID_INTEL_CFL_4S_D_IMC 0x3e1f |
321 |
++#define PCI_DEVICE_ID_INTEL_CFL_6S_D_IMC 0x3ec2 |
322 |
++#define PCI_DEVICE_ID_INTEL_CFL_8S_D_IMC 0x3e30 |
323 |
++#define PCI_DEVICE_ID_INTEL_CFL_4S_W_IMC 0x3e18 |
324 |
++#define PCI_DEVICE_ID_INTEL_CFL_6S_W_IMC 0x3ec6 |
325 |
++#define PCI_DEVICE_ID_INTEL_CFL_8S_W_IMC 0x3e31 |
326 |
++#define PCI_DEVICE_ID_INTEL_CFL_4S_S_IMC 0x3e33 |
327 |
++#define PCI_DEVICE_ID_INTEL_CFL_6S_S_IMC 0x3eca |
328 |
++#define PCI_DEVICE_ID_INTEL_CFL_8S_S_IMC 0x3e32 |
329 |
+ |
330 |
+ /* SNB event control */ |
331 |
+ #define SNB_UNC_CTL_EV_SEL_MASK 0x000000ff |
332 |
+@@ -631,7 +650,82 @@ static const struct pci_device_id skl_uncore_pci_ids[] = { |
333 |
+ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SKL_SQ_IMC), |
334 |
+ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), |
335 |
+ }, |
336 |
+- |
337 |
++ { /* IMC */ |
338 |
++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_KBL_Y_IMC), |
339 |
++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), |
340 |
++ }, |
341 |
++ { /* IMC */ |
342 |
++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_KBL_U_IMC), |
343 |
++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), |
344 |
++ }, |
345 |
++ { /* IMC */ |
346 |
++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_KBL_UQ_IMC), |
347 |
++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), |
348 |
++ }, |
349 |
++ { /* IMC */ |
350 |
++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_KBL_SD_IMC), |
351 |
++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), |
352 |
++ }, |
353 |
++ { /* IMC */ |
354 |
++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_KBL_SQ_IMC), |
355 |
++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), |
356 |
++ }, |
357 |
++ { /* IMC */ |
358 |
++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CFL_2U_IMC), |
359 |
++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), |
360 |
++ }, |
361 |
++ { /* IMC */ |
362 |
++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CFL_4U_IMC), |
363 |
++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), |
364 |
++ }, |
365 |
++ { /* IMC */ |
366 |
++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CFL_4H_IMC), |
367 |
++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), |
368 |
++ }, |
369 |
++ { /* IMC */ |
370 |
++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CFL_6H_IMC), |
371 |
++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), |
372 |
++ }, |
373 |
++ { /* IMC */ |
374 |
++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CFL_2S_D_IMC), |
375 |
++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), |
376 |
++ }, |
377 |
++ { /* IMC */ |
378 |
++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CFL_4S_D_IMC), |
379 |
++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), |
380 |
++ }, |
381 |
++ { /* IMC */ |
382 |
++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CFL_6S_D_IMC), |
383 |
++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), |
384 |
++ }, |
385 |
++ { /* IMC */ |
386 |
++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CFL_8S_D_IMC), |
387 |
++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), |
388 |
++ }, |
389 |
++ { /* IMC */ |
390 |
++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CFL_4S_W_IMC), |
391 |
++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), |
392 |
++ }, |
393 |
++ { /* IMC */ |
394 |
++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CFL_6S_W_IMC), |
395 |
++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), |
396 |
++ }, |
397 |
++ { /* IMC */ |
398 |
++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CFL_8S_W_IMC), |
399 |
++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), |
400 |
++ }, |
401 |
++ { /* IMC */ |
402 |
++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CFL_4S_S_IMC), |
403 |
++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), |
404 |
++ }, |
405 |
++ { /* IMC */ |
406 |
++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CFL_6S_S_IMC), |
407 |
++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), |
408 |
++ }, |
409 |
++ { /* IMC */ |
410 |
++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CFL_8S_S_IMC), |
411 |
++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), |
412 |
++ }, |
413 |
+ { /* end: all zeroes */ }, |
414 |
+ }; |
415 |
+ |
416 |
+@@ -680,6 +774,25 @@ static const struct imc_uncore_pci_dev desktop_imc_pci_ids[] = { |
417 |
+ IMC_DEV(SKL_HQ_IMC, &skl_uncore_pci_driver), /* 6th Gen Core H Quad Core */ |
418 |
+ IMC_DEV(SKL_SD_IMC, &skl_uncore_pci_driver), /* 6th Gen Core S Dual Core */ |
419 |
+ IMC_DEV(SKL_SQ_IMC, &skl_uncore_pci_driver), /* 6th Gen Core S Quad Core */ |
420 |
++ IMC_DEV(KBL_Y_IMC, &skl_uncore_pci_driver), /* 7th Gen Core Y */ |
421 |
++ IMC_DEV(KBL_U_IMC, &skl_uncore_pci_driver), /* 7th Gen Core U */ |
422 |
++ IMC_DEV(KBL_UQ_IMC, &skl_uncore_pci_driver), /* 7th Gen Core U Quad Core */ |
423 |
++ IMC_DEV(KBL_SD_IMC, &skl_uncore_pci_driver), /* 7th Gen Core S Dual Core */ |
424 |
++ IMC_DEV(KBL_SQ_IMC, &skl_uncore_pci_driver), /* 7th Gen Core S Quad Core */ |
425 |
++ IMC_DEV(CFL_2U_IMC, &skl_uncore_pci_driver), /* 8th Gen Core U 2 Cores */ |
426 |
++ IMC_DEV(CFL_4U_IMC, &skl_uncore_pci_driver), /* 8th Gen Core U 4 Cores */ |
427 |
++ IMC_DEV(CFL_4H_IMC, &skl_uncore_pci_driver), /* 8th Gen Core H 4 Cores */ |
428 |
++ IMC_DEV(CFL_6H_IMC, &skl_uncore_pci_driver), /* 8th Gen Core H 6 Cores */ |
429 |
++ IMC_DEV(CFL_2S_D_IMC, &skl_uncore_pci_driver), /* 8th Gen Core S 2 Cores Desktop */ |
430 |
++ IMC_DEV(CFL_4S_D_IMC, &skl_uncore_pci_driver), /* 8th Gen Core S 4 Cores Desktop */ |
431 |
++ IMC_DEV(CFL_6S_D_IMC, &skl_uncore_pci_driver), /* 8th Gen Core S 6 Cores Desktop */ |
432 |
++ IMC_DEV(CFL_8S_D_IMC, &skl_uncore_pci_driver), /* 8th Gen Core S 8 Cores Desktop */ |
433 |
++ IMC_DEV(CFL_4S_W_IMC, &skl_uncore_pci_driver), /* 8th Gen Core S 4 Cores Work Station */ |
434 |
++ IMC_DEV(CFL_6S_W_IMC, &skl_uncore_pci_driver), /* 8th Gen Core S 6 Cores Work Station */ |
435 |
++ IMC_DEV(CFL_8S_W_IMC, &skl_uncore_pci_driver), /* 8th Gen Core S 8 Cores Work Station */ |
436 |
++ IMC_DEV(CFL_4S_S_IMC, &skl_uncore_pci_driver), /* 8th Gen Core S 4 Cores Server */ |
437 |
++ IMC_DEV(CFL_6S_S_IMC, &skl_uncore_pci_driver), /* 8th Gen Core S 6 Cores Server */ |
438 |
++ IMC_DEV(CFL_8S_S_IMC, &skl_uncore_pci_driver), /* 8th Gen Core S 8 Cores Server */ |
439 |
+ { /* end marker */ } |
440 |
+ }; |
441 |
+ |
442 |
+diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c |
443 |
+index a321d7d849c6..326b9ba4518e 100644 |
444 |
+--- a/drivers/block/floppy.c |
445 |
++++ b/drivers/block/floppy.c |
446 |
+@@ -3823,10 +3823,11 @@ static int __floppy_read_block_0(struct block_device *bdev, int drive) |
447 |
+ bio.bi_end_io = floppy_rb0_cb; |
448 |
+ bio_set_op_attrs(&bio, REQ_OP_READ, 0); |
449 |
+ |
450 |
++ init_completion(&cbdata.complete); |
451 |
++ |
452 |
+ submit_bio(&bio); |
453 |
+ process_fd_request(); |
454 |
+ |
455 |
+- init_completion(&cbdata.complete); |
456 |
+ wait_for_completion(&cbdata.complete); |
457 |
+ |
458 |
+ __free_page(page); |
459 |
+diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c |
460 |
+index ef1fa8145419..fa86946d12aa 100644 |
461 |
+--- a/drivers/cpufreq/imx6q-cpufreq.c |
462 |
++++ b/drivers/cpufreq/imx6q-cpufreq.c |
463 |
+@@ -130,8 +130,13 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index) |
464 |
+ /* Ensure the arm clock divider is what we expect */ |
465 |
+ ret = clk_set_rate(arm_clk, new_freq * 1000); |
466 |
+ if (ret) { |
467 |
++ int ret1; |
468 |
++ |
469 |
+ dev_err(cpu_dev, "failed to set clock rate: %d\n", ret); |
470 |
+- regulator_set_voltage_tol(arm_reg, volt_old, 0); |
471 |
++ ret1 = regulator_set_voltage_tol(arm_reg, volt_old, 0); |
472 |
++ if (ret1) |
473 |
++ dev_warn(cpu_dev, |
474 |
++ "failed to restore vddarm voltage: %d\n", ret1); |
475 |
+ return ret; |
476 |
+ } |
477 |
+ |
478 |
+diff --git a/drivers/firmware/efi/arm-init.c b/drivers/firmware/efi/arm-init.c |
479 |
+index 1d1c9693ebfb..8ee91777abce 100644 |
480 |
+--- a/drivers/firmware/efi/arm-init.c |
481 |
++++ b/drivers/firmware/efi/arm-init.c |
482 |
+@@ -256,6 +256,10 @@ void __init efi_init(void) |
483 |
+ (params.mmap & ~PAGE_MASK))); |
484 |
+ |
485 |
+ init_screen_info(); |
486 |
++ |
487 |
++ /* ARM does not permit early mappings to persist across paging_init() */ |
488 |
++ if (IS_ENABLED(CONFIG_ARM)) |
489 |
++ efi_memmap_unmap(); |
490 |
+ } |
491 |
+ |
492 |
+ static int __init register_gop_device(void) |
493 |
+diff --git a/drivers/firmware/efi/arm-runtime.c b/drivers/firmware/efi/arm-runtime.c |
494 |
+index 4d788e0debfe..069c5a4479e6 100644 |
495 |
+--- a/drivers/firmware/efi/arm-runtime.c |
496 |
++++ b/drivers/firmware/efi/arm-runtime.c |
497 |
+@@ -118,7 +118,7 @@ static int __init arm_enable_runtime_services(void) |
498 |
+ { |
499 |
+ u64 mapsize; |
500 |
+ |
501 |
+- if (!efi_enabled(EFI_BOOT) || !efi_enabled(EFI_MEMMAP)) { |
502 |
++ if (!efi_enabled(EFI_BOOT)) { |
503 |
+ pr_info("EFI services will not be available.\n"); |
504 |
+ return 0; |
505 |
+ } |
506 |
+diff --git a/drivers/firmware/efi/memmap.c b/drivers/firmware/efi/memmap.c |
507 |
+index 78686443cb37..3fd2b450c649 100644 |
508 |
+--- a/drivers/firmware/efi/memmap.c |
509 |
++++ b/drivers/firmware/efi/memmap.c |
510 |
+@@ -117,6 +117,9 @@ int __init efi_memmap_init_early(struct efi_memory_map_data *data) |
511 |
+ |
512 |
+ void __init efi_memmap_unmap(void) |
513 |
+ { |
514 |
++ if (!efi_enabled(EFI_MEMMAP)) |
515 |
++ return; |
516 |
++ |
517 |
+ if (!efi.memmap.late) { |
518 |
+ unsigned long size; |
519 |
+ |
520 |
+diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c |
521 |
+index 2ec402ae14de..9e2fe12c2858 100644 |
522 |
+--- a/drivers/gpio/gpiolib.c |
523 |
++++ b/drivers/gpio/gpiolib.c |
524 |
+@@ -1153,7 +1153,7 @@ int gpiochip_add_data(struct gpio_chip *chip, void *data) |
525 |
+ gdev->descs = kcalloc(chip->ngpio, sizeof(gdev->descs[0]), GFP_KERNEL); |
526 |
+ if (!gdev->descs) { |
527 |
+ status = -ENOMEM; |
528 |
+- goto err_free_gdev; |
529 |
++ goto err_free_ida; |
530 |
+ } |
531 |
+ |
532 |
+ if (chip->ngpio == 0) { |
533 |
+@@ -1285,8 +1285,9 @@ err_free_label: |
534 |
+ kfree(gdev->label); |
535 |
+ err_free_descs: |
536 |
+ kfree(gdev->descs); |
537 |
+-err_free_gdev: |
538 |
++err_free_ida: |
539 |
+ ida_simple_remove(&gpio_ida, gdev->id); |
540 |
++err_free_gdev: |
541 |
+ /* failures here can mean systems won't boot... */ |
542 |
+ pr_err("%s: GPIOs %d..%d (%s) failed to register\n", __func__, |
543 |
+ gdev->base, gdev->base + gdev->ngpio - 1, |
544 |
+diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c |
545 |
+index f54afd2113a9..736133f5c5a9 100644 |
546 |
+--- a/drivers/gpu/drm/ast/ast_drv.c |
547 |
++++ b/drivers/gpu/drm/ast/ast_drv.c |
548 |
+@@ -60,8 +60,29 @@ static const struct pci_device_id pciidlist[] = { |
549 |
+ |
550 |
+ MODULE_DEVICE_TABLE(pci, pciidlist); |
551 |
+ |
552 |
++static void ast_kick_out_firmware_fb(struct pci_dev *pdev) |
553 |
++{ |
554 |
++ struct apertures_struct *ap; |
555 |
++ bool primary = false; |
556 |
++ |
557 |
++ ap = alloc_apertures(1); |
558 |
++ if (!ap) |
559 |
++ return; |
560 |
++ |
561 |
++ ap->ranges[0].base = pci_resource_start(pdev, 0); |
562 |
++ ap->ranges[0].size = pci_resource_len(pdev, 0); |
563 |
++ |
564 |
++#ifdef CONFIG_X86 |
565 |
++ primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW; |
566 |
++#endif |
567 |
++ drm_fb_helper_remove_conflicting_framebuffers(ap, "astdrmfb", primary); |
568 |
++ kfree(ap); |
569 |
++} |
570 |
++ |
571 |
+ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) |
572 |
+ { |
573 |
++ ast_kick_out_firmware_fb(pdev); |
574 |
++ |
575 |
+ return drm_get_pci_dev(pdev, ent, &driver); |
576 |
+ } |
577 |
+ |
578 |
+diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c |
579 |
+index 5957c3e659fe..57205016b04a 100644 |
580 |
+--- a/drivers/gpu/drm/ast/ast_mode.c |
581 |
++++ b/drivers/gpu/drm/ast/ast_mode.c |
582 |
+@@ -545,6 +545,7 @@ static int ast_crtc_do_set_base(struct drm_crtc *crtc, |
583 |
+ } |
584 |
+ ast_bo_unreserve(bo); |
585 |
+ |
586 |
++ ast_set_offset_reg(crtc); |
587 |
+ ast_set_start_address_crt1(crtc, (u32)gpu_addr); |
588 |
+ |
589 |
+ return 0; |
590 |
+@@ -1235,7 +1236,7 @@ static int ast_cursor_move(struct drm_crtc *crtc, |
591 |
+ ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xc7, ((y >> 8) & 0x07)); |
592 |
+ |
593 |
+ /* dummy write to fire HWC */ |
594 |
+- ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xCB, 0xFF, 0x00); |
595 |
++ ast_show_cursor(crtc); |
596 |
+ |
597 |
+ return 0; |
598 |
+ } |
599 |
+diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c |
600 |
+index d28c4cf7c1ee..dc92dc41ef93 100644 |
601 |
+--- a/drivers/infiniband/core/verbs.c |
602 |
++++ b/drivers/infiniband/core/verbs.c |
603 |
+@@ -1522,7 +1522,7 @@ static bool is_valid_mcast_lid(struct ib_qp *qp, u16 lid) |
604 |
+ */ |
605 |
+ if (!ib_query_qp(qp, &attr, IB_QP_STATE | IB_QP_PORT, &init_attr)) { |
606 |
+ if (attr.qp_state >= IB_QPS_INIT) { |
607 |
+- if (qp->device->get_link_layer(qp->device, attr.port_num) != |
608 |
++ if (rdma_port_get_link_layer(qp->device, attr.port_num) != |
609 |
+ IB_LINK_LAYER_INFINIBAND) |
610 |
+ return true; |
611 |
+ goto lid_check; |
612 |
+@@ -1531,7 +1531,7 @@ static bool is_valid_mcast_lid(struct ib_qp *qp, u16 lid) |
613 |
+ |
614 |
+ /* Can't get a quick answer, iterate over all ports */ |
615 |
+ for (port = 0; port < qp->device->phys_port_cnt; port++) |
616 |
+- if (qp->device->get_link_layer(qp->device, port) != |
617 |
++ if (rdma_port_get_link_layer(qp->device, port) != |
618 |
+ IB_LINK_LAYER_INFINIBAND) |
619 |
+ num_eth_ports++; |
620 |
+ |
621 |
+diff --git a/drivers/infiniband/hw/hfi1/user_sdma.c b/drivers/infiniband/hw/hfi1/user_sdma.c |
622 |
+index 018a41562704..619475c7d761 100644 |
623 |
+--- a/drivers/infiniband/hw/hfi1/user_sdma.c |
624 |
++++ b/drivers/infiniband/hw/hfi1/user_sdma.c |
625 |
+@@ -148,11 +148,8 @@ MODULE_PARM_DESC(sdma_comp_size, "Size of User SDMA completion ring. Default: 12 |
626 |
+ #define TXREQ_FLAGS_REQ_LAST_PKT BIT(0) |
627 |
+ |
628 |
+ /* SDMA request flag bits */ |
629 |
+-#define SDMA_REQ_FOR_THREAD 1 |
630 |
+-#define SDMA_REQ_SEND_DONE 2 |
631 |
+-#define SDMA_REQ_HAVE_AHG 3 |
632 |
+-#define SDMA_REQ_HAS_ERROR 4 |
633 |
+-#define SDMA_REQ_DONE_ERROR 5 |
634 |
++#define SDMA_REQ_HAVE_AHG 1 |
635 |
++#define SDMA_REQ_HAS_ERROR 2 |
636 |
+ |
637 |
+ #define SDMA_PKT_Q_INACTIVE BIT(0) |
638 |
+ #define SDMA_PKT_Q_ACTIVE BIT(1) |
639 |
+@@ -252,8 +249,6 @@ struct user_sdma_request { |
640 |
+ u64 seqsubmitted; |
641 |
+ struct list_head txps; |
642 |
+ unsigned long flags; |
643 |
+- /* status of the last txreq completed */ |
644 |
+- int status; |
645 |
+ }; |
646 |
+ |
647 |
+ /* |
648 |
+@@ -546,7 +541,6 @@ int hfi1_user_sdma_process_request(struct file *fp, struct iovec *iovec, |
649 |
+ struct sdma_req_info info; |
650 |
+ struct user_sdma_request *req; |
651 |
+ u8 opcode, sc, vl; |
652 |
+- int req_queued = 0; |
653 |
+ u16 dlid; |
654 |
+ u32 selector; |
655 |
+ |
656 |
+@@ -611,11 +605,13 @@ int hfi1_user_sdma_process_request(struct file *fp, struct iovec *iovec, |
657 |
+ req->data_iovs = req_iovcnt(info.ctrl) - 1; /* subtract header vector */ |
658 |
+ req->pq = pq; |
659 |
+ req->cq = cq; |
660 |
+- req->status = -1; |
661 |
+ INIT_LIST_HEAD(&req->txps); |
662 |
+ |
663 |
+ memcpy(&req->info, &info, sizeof(info)); |
664 |
+ |
665 |
++ /* The request is initialized, count it */ |
666 |
++ atomic_inc(&pq->n_reqs); |
667 |
++ |
668 |
+ if (req_opcode(info.ctrl) == EXPECTED) { |
669 |
+ /* expected must have a TID info and at least one data vector */ |
670 |
+ if (req->data_iovs < 2) { |
671 |
+@@ -704,7 +700,7 @@ int hfi1_user_sdma_process_request(struct file *fp, struct iovec *iovec, |
672 |
+ memcpy(&req->iovs[i].iov, iovec + idx++, sizeof(struct iovec)); |
673 |
+ ret = pin_vector_pages(req, &req->iovs[i]); |
674 |
+ if (ret) { |
675 |
+- req->status = ret; |
676 |
++ req->data_iovs = i; |
677 |
+ goto free_req; |
678 |
+ } |
679 |
+ req->data_len += req->iovs[i].iov.iov_len; |
680 |
+@@ -772,14 +768,10 @@ int hfi1_user_sdma_process_request(struct file *fp, struct iovec *iovec, |
681 |
+ } |
682 |
+ |
683 |
+ set_comp_state(pq, cq, info.comp_idx, QUEUED, 0); |
684 |
+- atomic_inc(&pq->n_reqs); |
685 |
+- req_queued = 1; |
686 |
+ /* Send the first N packets in the request to buy us some time */ |
687 |
+ ret = user_sdma_send_pkts(req, pcount); |
688 |
+- if (unlikely(ret < 0 && ret != -EBUSY)) { |
689 |
+- req->status = ret; |
690 |
++ if (unlikely(ret < 0 && ret != -EBUSY)) |
691 |
+ goto free_req; |
692 |
+- } |
693 |
+ |
694 |
+ /* |
695 |
+ * It is possible that the SDMA engine would have processed all the |
696 |
+@@ -796,17 +788,11 @@ int hfi1_user_sdma_process_request(struct file *fp, struct iovec *iovec, |
697 |
+ * request have been submitted to the SDMA engine. However, it |
698 |
+ * will not wait for send completions. |
699 |
+ */ |
700 |
+- while (!test_bit(SDMA_REQ_SEND_DONE, &req->flags)) { |
701 |
++ while (req->seqsubmitted != req->info.npkts) { |
702 |
+ ret = user_sdma_send_pkts(req, pcount); |
703 |
+ if (ret < 0) { |
704 |
+- if (ret != -EBUSY) { |
705 |
+- req->status = ret; |
706 |
+- set_bit(SDMA_REQ_DONE_ERROR, &req->flags); |
707 |
+- if (ACCESS_ONCE(req->seqcomp) == |
708 |
+- req->seqsubmitted - 1) |
709 |
+- goto free_req; |
710 |
+- return ret; |
711 |
+- } |
712 |
++ if (ret != -EBUSY) |
713 |
++ goto free_req; |
714 |
+ wait_event_interruptible_timeout( |
715 |
+ pq->busy.wait_dma, |
716 |
+ (pq->state == SDMA_PKT_Q_ACTIVE), |
717 |
+@@ -817,10 +803,19 @@ int hfi1_user_sdma_process_request(struct file *fp, struct iovec *iovec, |
718 |
+ *count += idx; |
719 |
+ return 0; |
720 |
+ free_req: |
721 |
+- user_sdma_free_request(req, true); |
722 |
+- if (req_queued) |
723 |
++ /* |
724 |
++ * If the submitted seqsubmitted == npkts, the completion routine |
725 |
++ * controls the final state. If sequbmitted < npkts, wait for any |
726 |
++ * outstanding packets to finish before cleaning up. |
727 |
++ */ |
728 |
++ if (req->seqsubmitted < req->info.npkts) { |
729 |
++ if (req->seqsubmitted) |
730 |
++ wait_event(pq->busy.wait_dma, |
731 |
++ (req->seqcomp == req->seqsubmitted - 1)); |
732 |
++ user_sdma_free_request(req, true); |
733 |
+ pq_update(pq); |
734 |
+- set_comp_state(pq, cq, info.comp_idx, ERROR, req->status); |
735 |
++ set_comp_state(pq, cq, info.comp_idx, ERROR, ret); |
736 |
++ } |
737 |
+ return ret; |
738 |
+ } |
739 |
+ |
740 |
+@@ -903,10 +898,8 @@ static int user_sdma_send_pkts(struct user_sdma_request *req, unsigned maxpkts) |
741 |
+ pq = req->pq; |
742 |
+ |
743 |
+ /* If tx completion has reported an error, we are done. */ |
744 |
+- if (test_bit(SDMA_REQ_HAS_ERROR, &req->flags)) { |
745 |
+- set_bit(SDMA_REQ_DONE_ERROR, &req->flags); |
746 |
++ if (test_bit(SDMA_REQ_HAS_ERROR, &req->flags)) |
747 |
+ return -EFAULT; |
748 |
+- } |
749 |
+ |
750 |
+ /* |
751 |
+ * Check if we might have sent the entire request already |
752 |
+@@ -929,10 +922,8 @@ static int user_sdma_send_pkts(struct user_sdma_request *req, unsigned maxpkts) |
753 |
+ * with errors. If so, we are not going to process any |
754 |
+ * more packets from this request. |
755 |
+ */ |
756 |
+- if (test_bit(SDMA_REQ_HAS_ERROR, &req->flags)) { |
757 |
+- set_bit(SDMA_REQ_DONE_ERROR, &req->flags); |
758 |
++ if (test_bit(SDMA_REQ_HAS_ERROR, &req->flags)) |
759 |
+ return -EFAULT; |
760 |
+- } |
761 |
+ |
762 |
+ tx = kmem_cache_alloc(pq->txreq_cache, GFP_KERNEL); |
763 |
+ if (!tx) |
764 |
+@@ -1090,7 +1081,6 @@ dosend: |
765 |
+ ret = sdma_send_txlist(req->sde, &pq->busy, &req->txps, &count); |
766 |
+ req->seqsubmitted += count; |
767 |
+ if (req->seqsubmitted == req->info.npkts) { |
768 |
+- set_bit(SDMA_REQ_SEND_DONE, &req->flags); |
769 |
+ /* |
770 |
+ * The txreq has already been submitted to the HW queue |
771 |
+ * so we can free the AHG entry now. Corruption will not |
772 |
+@@ -1489,11 +1479,15 @@ static int set_txreq_header_ahg(struct user_sdma_request *req, |
773 |
+ return diff; |
774 |
+ } |
775 |
+ |
776 |
+-/* |
777 |
+- * SDMA tx request completion callback. Called when the SDMA progress |
778 |
+- * state machine gets notification that the SDMA descriptors for this |
779 |
+- * tx request have been processed by the DMA engine. Called in |
780 |
+- * interrupt context. |
781 |
++/** |
782 |
++ * user_sdma_txreq_cb() - SDMA tx request completion callback. |
783 |
++ * @txreq: valid sdma tx request |
784 |
++ * @status: success/failure of request |
785 |
++ * |
786 |
++ * Called when the SDMA progress state machine gets notification that |
787 |
++ * the SDMA descriptors for this tx request have been processed by the |
788 |
++ * DMA engine. Called in interrupt context. |
789 |
++ * Only do work on completed sequences. |
790 |
+ */ |
791 |
+ static void user_sdma_txreq_cb(struct sdma_txreq *txreq, int status) |
792 |
+ { |
793 |
+@@ -1502,7 +1496,7 @@ static void user_sdma_txreq_cb(struct sdma_txreq *txreq, int status) |
794 |
+ struct user_sdma_request *req; |
795 |
+ struct hfi1_user_sdma_pkt_q *pq; |
796 |
+ struct hfi1_user_sdma_comp_q *cq; |
797 |
+- u16 idx; |
798 |
++ enum hfi1_sdma_comp_state state = COMPLETE; |
799 |
+ |
800 |
+ if (!tx->req) |
801 |
+ return; |
802 |
+@@ -1515,31 +1509,19 @@ static void user_sdma_txreq_cb(struct sdma_txreq *txreq, int status) |
803 |
+ SDMA_DBG(req, "SDMA completion with error %d", |
804 |
+ status); |
805 |
+ set_bit(SDMA_REQ_HAS_ERROR, &req->flags); |
806 |
++ state = ERROR; |
807 |
+ } |
808 |
+ |
809 |
+ req->seqcomp = tx->seqnum; |
810 |
+ kmem_cache_free(pq->txreq_cache, tx); |
811 |
+- tx = NULL; |
812 |
+- |
813 |
+- idx = req->info.comp_idx; |
814 |
+- if (req->status == -1 && status == SDMA_TXREQ_S_OK) { |
815 |
+- if (req->seqcomp == req->info.npkts - 1) { |
816 |
+- req->status = 0; |
817 |
+- user_sdma_free_request(req, false); |
818 |
+- pq_update(pq); |
819 |
+- set_comp_state(pq, cq, idx, COMPLETE, 0); |
820 |
+- } |
821 |
+- } else { |
822 |
+- if (status != SDMA_TXREQ_S_OK) |
823 |
+- req->status = status; |
824 |
+- if (req->seqcomp == (ACCESS_ONCE(req->seqsubmitted) - 1) && |
825 |
+- (test_bit(SDMA_REQ_SEND_DONE, &req->flags) || |
826 |
+- test_bit(SDMA_REQ_DONE_ERROR, &req->flags))) { |
827 |
+- user_sdma_free_request(req, false); |
828 |
+- pq_update(pq); |
829 |
+- set_comp_state(pq, cq, idx, ERROR, req->status); |
830 |
+- } |
831 |
+- } |
832 |
++ |
833 |
++ /* sequence isn't complete? We are done */ |
834 |
++ if (req->seqcomp != req->info.npkts - 1) |
835 |
++ return; |
836 |
++ |
837 |
++ user_sdma_free_request(req, false); |
838 |
++ set_comp_state(pq, cq, req->info.comp_idx, state, status); |
839 |
++ pq_update(pq); |
840 |
+ } |
841 |
+ |
842 |
+ static inline void pq_update(struct hfi1_user_sdma_pkt_q *pq) |
843 |
+@@ -1572,6 +1554,8 @@ static void user_sdma_free_request(struct user_sdma_request *req, bool unpin) |
844 |
+ if (!node) |
845 |
+ continue; |
846 |
+ |
847 |
++ req->iovs[i].node = NULL; |
848 |
++ |
849 |
+ if (unpin) |
850 |
+ hfi1_mmu_rb_remove(req->pq->handler, |
851 |
+ &node->rb); |
852 |
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c |
853 |
+index f397a5b6910f..2e52015634f9 100644 |
854 |
+--- a/drivers/input/joystick/xpad.c |
855 |
++++ b/drivers/input/joystick/xpad.c |
856 |
+@@ -89,8 +89,10 @@ |
857 |
+ |
858 |
+ #define XPAD_PKT_LEN 64 |
859 |
+ |
860 |
+-/* xbox d-pads should map to buttons, as is required for DDR pads |
861 |
+- but we map them to axes when possible to simplify things */ |
862 |
++/* |
863 |
++ * xbox d-pads should map to buttons, as is required for DDR pads |
864 |
++ * but we map them to axes when possible to simplify things |
865 |
++ */ |
866 |
+ #define MAP_DPAD_TO_BUTTONS (1 << 0) |
867 |
+ #define MAP_TRIGGERS_TO_BUTTONS (1 << 1) |
868 |
+ #define MAP_STICKS_TO_NULL (1 << 2) |
869 |
+@@ -126,45 +128,77 @@ static const struct xpad_device { |
870 |
+ u8 mapping; |
871 |
+ u8 xtype; |
872 |
+ } xpad_device[] = { |
873 |
++ { 0x0079, 0x18d4, "GPD Win 2 X-Box Controller", 0, XTYPE_XBOX360 }, |
874 |
++ { 0x044f, 0x0f00, "Thrustmaster Wheel", 0, XTYPE_XBOX }, |
875 |
++ { 0x044f, 0x0f03, "Thrustmaster Wheel", 0, XTYPE_XBOX }, |
876 |
++ { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX }, |
877 |
++ { 0x044f, 0x0f10, "Thrustmaster Modena GT Wheel", 0, XTYPE_XBOX }, |
878 |
++ { 0x044f, 0xb326, "Thrustmaster Gamepad GP XID", 0, XTYPE_XBOX360 }, |
879 |
+ { 0x045e, 0x0202, "Microsoft X-Box pad v1 (US)", 0, XTYPE_XBOX }, |
880 |
+ { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)", 0, XTYPE_XBOX }, |
881 |
+ { 0x045e, 0x0287, "Microsoft Xbox Controller S", 0, XTYPE_XBOX }, |
882 |
++ { 0x045e, 0x0288, "Microsoft Xbox Controller S v2", 0, XTYPE_XBOX }, |
883 |
+ { 0x045e, 0x0289, "Microsoft X-Box pad v2 (US)", 0, XTYPE_XBOX }, |
884 |
+ { 0x045e, 0x028e, "Microsoft X-Box 360 pad", 0, XTYPE_XBOX360 }, |
885 |
++ { 0x045e, 0x028f, "Microsoft X-Box 360 pad v2", 0, XTYPE_XBOX360 }, |
886 |
++ { 0x045e, 0x0291, "Xbox 360 Wireless Receiver (XBOX)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W }, |
887 |
+ { 0x045e, 0x02d1, "Microsoft X-Box One pad", 0, XTYPE_XBOXONE }, |
888 |
+ { 0x045e, 0x02dd, "Microsoft X-Box One pad (Firmware 2015)", 0, XTYPE_XBOXONE }, |
889 |
+ { 0x045e, 0x02e3, "Microsoft X-Box One Elite pad", 0, XTYPE_XBOXONE }, |
890 |
+- { 0x045e, 0x0291, "Xbox 360 Wireless Receiver (XBOX)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W }, |
891 |
++ { 0x045e, 0x02ea, "Microsoft X-Box One S pad", 0, XTYPE_XBOXONE }, |
892 |
+ { 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W }, |
893 |
+- { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX }, |
894 |
+- { 0x044f, 0xb326, "Thrustmaster Gamepad GP XID", 0, XTYPE_XBOX360 }, |
895 |
+ { 0x046d, 0xc21d, "Logitech Gamepad F310", 0, XTYPE_XBOX360 }, |
896 |
+ { 0x046d, 0xc21e, "Logitech Gamepad F510", 0, XTYPE_XBOX360 }, |
897 |
+ { 0x046d, 0xc21f, "Logitech Gamepad F710", 0, XTYPE_XBOX360 }, |
898 |
+ { 0x046d, 0xc242, "Logitech Chillstream Controller", 0, XTYPE_XBOX360 }, |
899 |
+ { 0x046d, 0xca84, "Logitech Xbox Cordless Controller", 0, XTYPE_XBOX }, |
900 |
+ { 0x046d, 0xca88, "Logitech Compact Controller for Xbox", 0, XTYPE_XBOX }, |
901 |
++ { 0x046d, 0xca8a, "Logitech Precision Vibration Feedback Wheel", 0, XTYPE_XBOX }, |
902 |
++ { 0x046d, 0xcaa3, "Logitech DriveFx Racing Wheel", 0, XTYPE_XBOX360 }, |
903 |
++ { 0x056e, 0x2004, "Elecom JC-U3613M", 0, XTYPE_XBOX360 }, |
904 |
+ { 0x05fd, 0x1007, "Mad Catz Controller (unverified)", 0, XTYPE_XBOX }, |
905 |
+ { 0x05fd, 0x107a, "InterAct 'PowerPad Pro' X-Box pad (Germany)", 0, XTYPE_XBOX }, |
906 |
++ { 0x05fe, 0x3030, "Chic Controller", 0, XTYPE_XBOX }, |
907 |
++ { 0x05fe, 0x3031, "Chic Controller", 0, XTYPE_XBOX }, |
908 |
++ { 0x062a, 0x0020, "Logic3 Xbox GamePad", 0, XTYPE_XBOX }, |
909 |
++ { 0x062a, 0x0033, "Competition Pro Steering Wheel", 0, XTYPE_XBOX }, |
910 |
++ { 0x06a3, 0x0200, "Saitek Racing Wheel", 0, XTYPE_XBOX }, |
911 |
++ { 0x06a3, 0x0201, "Saitek Adrenalin", 0, XTYPE_XBOX }, |
912 |
++ { 0x06a3, 0xf51a, "Saitek P3600", 0, XTYPE_XBOX360 }, |
913 |
++ { 0x0738, 0x4506, "Mad Catz 4506 Wireless Controller", 0, XTYPE_XBOX }, |
914 |
+ { 0x0738, 0x4516, "Mad Catz Control Pad", 0, XTYPE_XBOX }, |
915 |
++ { 0x0738, 0x4520, "Mad Catz Control Pad Pro", 0, XTYPE_XBOX }, |
916 |
+ { 0x0738, 0x4522, "Mad Catz LumiCON", 0, XTYPE_XBOX }, |
917 |
+ { 0x0738, 0x4526, "Mad Catz Control Pad Pro", 0, XTYPE_XBOX }, |
918 |
++ { 0x0738, 0x4530, "Mad Catz Universal MC2 Racing Wheel and Pedals", 0, XTYPE_XBOX }, |
919 |
+ { 0x0738, 0x4536, "Mad Catz MicroCON", 0, XTYPE_XBOX }, |
920 |
+ { 0x0738, 0x4540, "Mad Catz Beat Pad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, |
921 |
+ { 0x0738, 0x4556, "Mad Catz Lynx Wireless Controller", 0, XTYPE_XBOX }, |
922 |
++ { 0x0738, 0x4586, "Mad Catz MicroCon Wireless Controller", 0, XTYPE_XBOX }, |
923 |
++ { 0x0738, 0x4588, "Mad Catz Blaster", 0, XTYPE_XBOX }, |
924 |
++ { 0x0738, 0x45ff, "Mad Catz Beat Pad (w/ Handle)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, |
925 |
+ { 0x0738, 0x4716, "Mad Catz Wired Xbox 360 Controller", 0, XTYPE_XBOX360 }, |
926 |
+ { 0x0738, 0x4718, "Mad Catz Street Fighter IV FightStick SE", 0, XTYPE_XBOX360 }, |
927 |
+ { 0x0738, 0x4726, "Mad Catz Xbox 360 Controller", 0, XTYPE_XBOX360 }, |
928 |
+ { 0x0738, 0x4728, "Mad Catz Street Fighter IV FightPad", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, |
929 |
++ { 0x0738, 0x4736, "Mad Catz MicroCon Gamepad", 0, XTYPE_XBOX360 }, |
930 |
+ { 0x0738, 0x4738, "Mad Catz Wired Xbox 360 Controller (SFIV)", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, |
931 |
+ { 0x0738, 0x4740, "Mad Catz Beat Pad", 0, XTYPE_XBOX360 }, |
932 |
++ { 0x0738, 0x4743, "Mad Catz Beat Pad Pro", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, |
933 |
++ { 0x0738, 0x4758, "Mad Catz Arcade Game Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, |
934 |
+ { 0x0738, 0x4a01, "Mad Catz FightStick TE 2", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE }, |
935 |
+ { 0x0738, 0x6040, "Mad Catz Beat Pad Pro", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, |
936 |
++ { 0x0738, 0x9871, "Mad Catz Portable Drum", 0, XTYPE_XBOX360 }, |
937 |
+ { 0x0738, 0xb726, "Mad Catz Xbox controller - MW2", 0, XTYPE_XBOX360 }, |
938 |
++ { 0x0738, 0xb738, "Mad Catz MVC2TE Stick 2", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, |
939 |
+ { 0x0738, 0xbeef, "Mad Catz JOYTECH NEO SE Advanced GamePad", XTYPE_XBOX360 }, |
940 |
+ { 0x0738, 0xcb02, "Saitek Cyborg Rumble Pad - PC/Xbox 360", 0, XTYPE_XBOX360 }, |
941 |
+ { 0x0738, 0xcb03, "Saitek P3200 Rumble Pad - PC/Xbox 360", 0, XTYPE_XBOX360 }, |
942 |
++ { 0x0738, 0xcb29, "Saitek Aviator Stick AV8R02", 0, XTYPE_XBOX360 }, |
943 |
+ { 0x0738, 0xf738, "Super SFIV FightStick TE S", 0, XTYPE_XBOX360 }, |
944 |
++ { 0x07ff, 0xffff, "Mad Catz GamePad", 0, XTYPE_XBOX360 }, |
945 |
++ { 0x0c12, 0x0005, "Intec wireless", 0, XTYPE_XBOX }, |
946 |
++ { 0x0c12, 0x8801, "Nyko Xbox Controller", 0, XTYPE_XBOX }, |
947 |
+ { 0x0c12, 0x8802, "Zeroplus Xbox Controller", 0, XTYPE_XBOX }, |
948 |
+ { 0x0c12, 0x8809, "RedOctane Xbox Dance Pad", DANCEPAD_MAP_CONFIG, XTYPE_XBOX }, |
949 |
+ { 0x0c12, 0x880a, "Pelican Eclipse PL-2023", 0, XTYPE_XBOX }, |
950 |
+@@ -172,35 +206,66 @@ static const struct xpad_device { |
951 |
+ { 0x0c12, 0x9902, "HAMA VibraX - *FAULTY HARDWARE*", 0, XTYPE_XBOX }, |
952 |
+ { 0x0d2f, 0x0002, "Andamiro Pump It Up pad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, |
953 |
+ { 0x0e4c, 0x1097, "Radica Gamester Controller", 0, XTYPE_XBOX }, |
954 |
++ { 0x0e4c, 0x1103, "Radica Gamester Reflex", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX }, |
955 |
+ { 0x0e4c, 0x2390, "Radica Games Jtech Controller", 0, XTYPE_XBOX }, |
956 |
++ { 0x0e4c, 0x3510, "Radica Gamester", 0, XTYPE_XBOX }, |
957 |
+ { 0x0e6f, 0x0003, "Logic3 Freebird wireless Controller", 0, XTYPE_XBOX }, |
958 |
+ { 0x0e6f, 0x0005, "Eclipse wireless Controller", 0, XTYPE_XBOX }, |
959 |
+ { 0x0e6f, 0x0006, "Edge wireless Controller", 0, XTYPE_XBOX }, |
960 |
++ { 0x0e6f, 0x0008, "After Glow Pro Controller", 0, XTYPE_XBOX }, |
961 |
+ { 0x0e6f, 0x0105, "HSM3 Xbox360 dancepad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 }, |
962 |
+ { 0x0e6f, 0x0113, "Afterglow AX.1 Gamepad for Xbox 360", 0, XTYPE_XBOX360 }, |
963 |
++ { 0x0e6f, 0x011f, "Rock Candy Gamepad Wired Controller", 0, XTYPE_XBOX360 }, |
964 |
++ { 0x0e6f, 0x0131, "PDP EA Sports Controller", 0, XTYPE_XBOX360 }, |
965 |
++ { 0x0e6f, 0x0133, "Xbox 360 Wired Controller", 0, XTYPE_XBOX360 }, |
966 |
+ { 0x0e6f, 0x0139, "Afterglow Prismatic Wired Controller", 0, XTYPE_XBOXONE }, |
967 |
++ { 0x0e6f, 0x013a, "PDP Xbox One Controller", 0, XTYPE_XBOXONE }, |
968 |
++ { 0x0e6f, 0x0146, "Rock Candy Wired Controller for Xbox One", 0, XTYPE_XBOXONE }, |
969 |
++ { 0x0e6f, 0x0147, "PDP Marvel Xbox One Controller", 0, XTYPE_XBOXONE }, |
970 |
++ { 0x0e6f, 0x015c, "PDP Xbox One Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE }, |
971 |
++ { 0x0e6f, 0x0161, "PDP Xbox One Controller", 0, XTYPE_XBOXONE }, |
972 |
++ { 0x0e6f, 0x0162, "PDP Xbox One Controller", 0, XTYPE_XBOXONE }, |
973 |
++ { 0x0e6f, 0x0163, "PDP Xbox One Controller", 0, XTYPE_XBOXONE }, |
974 |
++ { 0x0e6f, 0x0164, "PDP Battlefield One", 0, XTYPE_XBOXONE }, |
975 |
++ { 0x0e6f, 0x0165, "PDP Titanfall 2", 0, XTYPE_XBOXONE }, |
976 |
+ { 0x0e6f, 0x0201, "Pelican PL-3601 'TSZ' Wired Xbox 360 Controller", 0, XTYPE_XBOX360 }, |
977 |
+ { 0x0e6f, 0x0213, "Afterglow Gamepad for Xbox 360", 0, XTYPE_XBOX360 }, |
978 |
+ { 0x0e6f, 0x021f, "Rock Candy Gamepad for Xbox 360", 0, XTYPE_XBOX360 }, |
979 |
+- { 0x0e6f, 0x0146, "Rock Candy Wired Controller for Xbox One", 0, XTYPE_XBOXONE }, |
980 |
++ { 0x0e6f, 0x0246, "Rock Candy Gamepad for Xbox One 2015", 0, XTYPE_XBOXONE }, |
981 |
++ { 0x0e6f, 0x02ab, "PDP Controller for Xbox One", 0, XTYPE_XBOXONE }, |
982 |
++ { 0x0e6f, 0x02a4, "PDP Wired Controller for Xbox One - Stealth Series", 0, XTYPE_XBOXONE }, |
983 |
++ { 0x0e6f, 0x02a6, "PDP Wired Controller for Xbox One - Camo Series", 0, XTYPE_XBOXONE }, |
984 |
+ { 0x0e6f, 0x0301, "Logic3 Controller", 0, XTYPE_XBOX360 }, |
985 |
++ { 0x0e6f, 0x0346, "Rock Candy Gamepad for Xbox One 2016", 0, XTYPE_XBOXONE }, |
986 |
+ { 0x0e6f, 0x0401, "Logic3 Controller", 0, XTYPE_XBOX360 }, |
987 |
++ { 0x0e6f, 0x0413, "Afterglow AX.1 Gamepad for Xbox 360", 0, XTYPE_XBOX360 }, |
988 |
++ { 0x0e6f, 0x0501, "PDP Xbox 360 Controller", 0, XTYPE_XBOX360 }, |
989 |
++ { 0x0e6f, 0xf900, "PDP Afterglow AX.1", 0, XTYPE_XBOX360 }, |
990 |
+ { 0x0e8f, 0x0201, "SmartJoy Frag Xpad/PS2 adaptor", 0, XTYPE_XBOX }, |
991 |
+ { 0x0e8f, 0x3008, "Generic xbox control (dealextreme)", 0, XTYPE_XBOX }, |
992 |
+ { 0x0f0d, 0x000a, "Hori Co. DOA4 FightStick", 0, XTYPE_XBOX360 }, |
993 |
++ { 0x0f0d, 0x000c, "Hori PadEX Turbo", 0, XTYPE_XBOX360 }, |
994 |
+ { 0x0f0d, 0x000d, "Hori Fighting Stick EX2", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, |
995 |
+ { 0x0f0d, 0x0016, "Hori Real Arcade Pro.EX", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, |
996 |
++ { 0x0f0d, 0x001b, "Hori Real Arcade Pro VX", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, |
997 |
++ { 0x0f0d, 0x0063, "Hori Real Arcade Pro Hayabusa (USA) Xbox One", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE }, |
998 |
+ { 0x0f0d, 0x0067, "HORIPAD ONE", 0, XTYPE_XBOXONE }, |
999 |
++ { 0x0f0d, 0x0078, "Hori Real Arcade Pro V Kai Xbox One", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE }, |
1000 |
++ { 0x0f30, 0x010b, "Philips Recoil", 0, XTYPE_XBOX }, |
1001 |
+ { 0x0f30, 0x0202, "Joytech Advanced Controller", 0, XTYPE_XBOX }, |
1002 |
+ { 0x0f30, 0x8888, "BigBen XBMiniPad Controller", 0, XTYPE_XBOX }, |
1003 |
+ { 0x102c, 0xff0c, "Joytech Wireless Advanced Controller", 0, XTYPE_XBOX }, |
1004 |
++ { 0x11c9, 0x55f0, "Nacon GC-100XF", 0, XTYPE_XBOX360 }, |
1005 |
+ { 0x12ab, 0x0004, "Honey Bee Xbox360 dancepad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 }, |
1006 |
+ { 0x12ab, 0x0301, "PDP AFTERGLOW AX.1", 0, XTYPE_XBOX360 }, |
1007 |
++ { 0x12ab, 0x0303, "Mortal Kombat Klassic FightStick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, |
1008 |
+ { 0x12ab, 0x8809, "Xbox DDR dancepad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, |
1009 |
+ { 0x1430, 0x4748, "RedOctane Guitar Hero X-plorer", 0, XTYPE_XBOX360 }, |
1010 |
+ { 0x1430, 0x8888, "TX6500+ Dance Pad (first generation)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, |
1011 |
++ { 0x1430, 0xf801, "RedOctane Controller", 0, XTYPE_XBOX360 }, |
1012 |
+ { 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller", 0, XTYPE_XBOX360 }, |
1013 |
+ { 0x1532, 0x0037, "Razer Sabertooth", 0, XTYPE_XBOX360 }, |
1014 |
++ { 0x1532, 0x0a00, "Razer Atrox Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE }, |
1015 |
+ { 0x1532, 0x0a03, "Razer Wildcat", 0, XTYPE_XBOXONE }, |
1016 |
+ { 0x15e4, 0x3f00, "Power A Mini Pro Elite", 0, XTYPE_XBOX360 }, |
1017 |
+ { 0x15e4, 0x3f0a, "Xbox Airflo wired controller", 0, XTYPE_XBOX360 }, |
1018 |
+@@ -208,27 +273,67 @@ static const struct xpad_device { |
1019 |
+ { 0x162e, 0xbeef, "Joytech Neo-Se Take2", 0, XTYPE_XBOX360 }, |
1020 |
+ { 0x1689, 0xfd00, "Razer Onza Tournament Edition", 0, XTYPE_XBOX360 }, |
1021 |
+ { 0x1689, 0xfd01, "Razer Onza Classic Edition", 0, XTYPE_XBOX360 }, |
1022 |
+- { 0x24c6, 0x542a, "Xbox ONE spectra", 0, XTYPE_XBOXONE }, |
1023 |
+- { 0x24c6, 0x5d04, "Razer Sabertooth", 0, XTYPE_XBOX360 }, |
1024 |
++ { 0x1689, 0xfe00, "Razer Sabertooth", 0, XTYPE_XBOX360 }, |
1025 |
+ { 0x1bad, 0x0002, "Harmonix Rock Band Guitar", 0, XTYPE_XBOX360 }, |
1026 |
+ { 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 }, |
1027 |
++ { 0x1bad, 0x0130, "Ion Drum Rocker", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 }, |
1028 |
+ { 0x1bad, 0xf016, "Mad Catz Xbox 360 Controller", 0, XTYPE_XBOX360 }, |
1029 |
++ { 0x1bad, 0xf018, "Mad Catz Street Fighter IV SE Fighting Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, |
1030 |
++ { 0x1bad, 0xf019, "Mad Catz Brawlstick for Xbox 360", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, |
1031 |
++ { 0x1bad, 0xf021, "Mad Cats Ghost Recon FS GamePad", 0, XTYPE_XBOX360 }, |
1032 |
+ { 0x1bad, 0xf023, "MLG Pro Circuit Controller (Xbox)", 0, XTYPE_XBOX360 }, |
1033 |
++ { 0x1bad, 0xf025, "Mad Catz Call Of Duty", 0, XTYPE_XBOX360 }, |
1034 |
++ { 0x1bad, 0xf027, "Mad Catz FPS Pro", 0, XTYPE_XBOX360 }, |
1035 |
+ { 0x1bad, 0xf028, "Street Fighter IV FightPad", 0, XTYPE_XBOX360 }, |
1036 |
++ { 0x1bad, 0xf02e, "Mad Catz Fightpad", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, |
1037 |
++ { 0x1bad, 0xf030, "Mad Catz Xbox 360 MC2 MicroCon Racing Wheel", 0, XTYPE_XBOX360 }, |
1038 |
++ { 0x1bad, 0xf036, "Mad Catz MicroCon GamePad Pro", 0, XTYPE_XBOX360 }, |
1039 |
+ { 0x1bad, 0xf038, "Street Fighter IV FightStick TE", 0, XTYPE_XBOX360 }, |
1040 |
++ { 0x1bad, 0xf039, "Mad Catz MvC2 TE", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, |
1041 |
++ { 0x1bad, 0xf03a, "Mad Catz SFxT Fightstick Pro", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, |
1042 |
++ { 0x1bad, 0xf03d, "Street Fighter IV Arcade Stick TE - Chun Li", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, |
1043 |
++ { 0x1bad, 0xf03e, "Mad Catz MLG FightStick TE", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, |
1044 |
++ { 0x1bad, 0xf03f, "Mad Catz FightStick SoulCaliber", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, |
1045 |
++ { 0x1bad, 0xf042, "Mad Catz FightStick TES+", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, |
1046 |
++ { 0x1bad, 0xf080, "Mad Catz FightStick TE2", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, |
1047 |
++ { 0x1bad, 0xf501, "HoriPad EX2 Turbo", 0, XTYPE_XBOX360 }, |
1048 |
++ { 0x1bad, 0xf502, "Hori Real Arcade Pro.VX SA", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, |
1049 |
++ { 0x1bad, 0xf503, "Hori Fighting Stick VX", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, |
1050 |
++ { 0x1bad, 0xf504, "Hori Real Arcade Pro. EX", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, |
1051 |
++ { 0x1bad, 0xf505, "Hori Fighting Stick EX2B", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, |
1052 |
++ { 0x1bad, 0xf506, "Hori Real Arcade Pro.EX Premium VLX", 0, XTYPE_XBOX360 }, |
1053 |
+ { 0x1bad, 0xf900, "Harmonix Xbox 360 Controller", 0, XTYPE_XBOX360 }, |
1054 |
+ { 0x1bad, 0xf901, "Gamestop Xbox 360 Controller", 0, XTYPE_XBOX360 }, |
1055 |
+ { 0x1bad, 0xf903, "Tron Xbox 360 controller", 0, XTYPE_XBOX360 }, |
1056 |
++ { 0x1bad, 0xf904, "PDP Versus Fighting Pad", 0, XTYPE_XBOX360 }, |
1057 |
++ { 0x1bad, 0xf906, "MortalKombat FightStick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, |
1058 |
++ { 0x1bad, 0xfa01, "MadCatz GamePad", 0, XTYPE_XBOX360 }, |
1059 |
++ { 0x1bad, 0xfd00, "Razer Onza TE", 0, XTYPE_XBOX360 }, |
1060 |
++ { 0x1bad, 0xfd01, "Razer Onza", 0, XTYPE_XBOX360 }, |
1061 |
+ { 0x24c6, 0x5000, "Razer Atrox Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, |
1062 |
+ { 0x24c6, 0x5300, "PowerA MINI PROEX Controller", 0, XTYPE_XBOX360 }, |
1063 |
+ { 0x24c6, 0x5303, "Xbox Airflo wired controller", 0, XTYPE_XBOX360 }, |
1064 |
++ { 0x24c6, 0x530a, "Xbox 360 Pro EX Controller", 0, XTYPE_XBOX360 }, |
1065 |
++ { 0x24c6, 0x531a, "PowerA Pro Ex", 0, XTYPE_XBOX360 }, |
1066 |
++ { 0x24c6, 0x5397, "FUS1ON Tournament Controller", 0, XTYPE_XBOX360 }, |
1067 |
+ { 0x24c6, 0x541a, "PowerA Xbox One Mini Wired Controller", 0, XTYPE_XBOXONE }, |
1068 |
++ { 0x24c6, 0x542a, "Xbox ONE spectra", 0, XTYPE_XBOXONE }, |
1069 |
+ { 0x24c6, 0x543a, "PowerA Xbox One wired controller", 0, XTYPE_XBOXONE }, |
1070 |
+ { 0x24c6, 0x5500, "Hori XBOX 360 EX 2 with Turbo", 0, XTYPE_XBOX360 }, |
1071 |
+ { 0x24c6, 0x5501, "Hori Real Arcade Pro VX-SA", 0, XTYPE_XBOX360 }, |
1072 |
++ { 0x24c6, 0x5502, "Hori Fighting Stick VX Alt", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, |
1073 |
++ { 0x24c6, 0x5503, "Hori Fighting Edge", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, |
1074 |
+ { 0x24c6, 0x5506, "Hori SOULCALIBUR V Stick", 0, XTYPE_XBOX360 }, |
1075 |
++ { 0x24c6, 0x550d, "Hori GEM Xbox controller", 0, XTYPE_XBOX360 }, |
1076 |
++ { 0x24c6, 0x550e, "Hori Real Arcade Pro V Kai 360", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, |
1077 |
++ { 0x24c6, 0x551a, "PowerA FUSION Pro Controller", 0, XTYPE_XBOXONE }, |
1078 |
++ { 0x24c6, 0x561a, "PowerA FUSION Controller", 0, XTYPE_XBOXONE }, |
1079 |
++ { 0x24c6, 0x5b00, "ThrustMaster Ferrari 458 Racing Wheel", 0, XTYPE_XBOX360 }, |
1080 |
+ { 0x24c6, 0x5b02, "Thrustmaster, Inc. GPX Controller", 0, XTYPE_XBOX360 }, |
1081 |
+ { 0x24c6, 0x5b03, "Thrustmaster Ferrari 458 Racing Wheel", 0, XTYPE_XBOX360 }, |
1082 |
++ { 0x24c6, 0x5d04, "Razer Sabertooth", 0, XTYPE_XBOX360 }, |
1083 |
++ { 0x24c6, 0xfafe, "Rock Candy Gamepad for Xbox 360", 0, XTYPE_XBOX360 }, |
1084 |
++ { 0x3767, 0x0101, "Fanatec Speedster 3 Forceshock Wheel", 0, XTYPE_XBOX }, |
1085 |
+ { 0xffff, 0xffff, "Chinese-made Xbox Controller", 0, XTYPE_XBOX }, |
1086 |
+ { 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN } |
1087 |
+ }; |
1088 |
+@@ -289,15 +394,15 @@ static const signed short xpad_abs_triggers[] = { |
1089 |
+ * match against vendor id as well. Wired Xbox 360 devices have protocol 1, |
1090 |
+ * wireless controllers have protocol 129. |
1091 |
+ */ |
1092 |
+-#define XPAD_XBOX360_VENDOR_PROTOCOL(vend,pr) \ |
1093 |
++#define XPAD_XBOX360_VENDOR_PROTOCOL(vend, pr) \ |
1094 |
+ .match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_INT_INFO, \ |
1095 |
+ .idVendor = (vend), \ |
1096 |
+ .bInterfaceClass = USB_CLASS_VENDOR_SPEC, \ |
1097 |
+ .bInterfaceSubClass = 93, \ |
1098 |
+ .bInterfaceProtocol = (pr) |
1099 |
+ #define XPAD_XBOX360_VENDOR(vend) \ |
1100 |
+- { XPAD_XBOX360_VENDOR_PROTOCOL(vend,1) }, \ |
1101 |
+- { XPAD_XBOX360_VENDOR_PROTOCOL(vend,129) } |
1102 |
++ { XPAD_XBOX360_VENDOR_PROTOCOL((vend), 1) }, \ |
1103 |
++ { XPAD_XBOX360_VENDOR_PROTOCOL((vend), 129) } |
1104 |
+ |
1105 |
+ /* The Xbox One controller uses subclass 71 and protocol 208. */ |
1106 |
+ #define XPAD_XBOXONE_VENDOR_PROTOCOL(vend, pr) \ |
1107 |
+@@ -307,37 +412,138 @@ static const signed short xpad_abs_triggers[] = { |
1108 |
+ .bInterfaceSubClass = 71, \ |
1109 |
+ .bInterfaceProtocol = (pr) |
1110 |
+ #define XPAD_XBOXONE_VENDOR(vend) \ |
1111 |
+- { XPAD_XBOXONE_VENDOR_PROTOCOL(vend, 208) } |
1112 |
++ { XPAD_XBOXONE_VENDOR_PROTOCOL((vend), 208) } |
1113 |
+ |
1114 |
+-static struct usb_device_id xpad_table[] = { |
1115 |
++static const struct usb_device_id xpad_table[] = { |
1116 |
+ { USB_INTERFACE_INFO('X', 'B', 0) }, /* X-Box USB-IF not approved class */ |
1117 |
++ XPAD_XBOX360_VENDOR(0x0079), /* GPD Win 2 Controller */ |
1118 |
+ XPAD_XBOX360_VENDOR(0x044f), /* Thrustmaster X-Box 360 controllers */ |
1119 |
+ XPAD_XBOX360_VENDOR(0x045e), /* Microsoft X-Box 360 controllers */ |
1120 |
+ XPAD_XBOXONE_VENDOR(0x045e), /* Microsoft X-Box One controllers */ |
1121 |
+ XPAD_XBOX360_VENDOR(0x046d), /* Logitech X-Box 360 style controllers */ |
1122 |
++ XPAD_XBOX360_VENDOR(0x056e), /* Elecom JC-U3613M */ |
1123 |
++ XPAD_XBOX360_VENDOR(0x06a3), /* Saitek P3600 */ |
1124 |
+ XPAD_XBOX360_VENDOR(0x0738), /* Mad Catz X-Box 360 controllers */ |
1125 |
+ { USB_DEVICE(0x0738, 0x4540) }, /* Mad Catz Beat Pad */ |
1126 |
+ XPAD_XBOXONE_VENDOR(0x0738), /* Mad Catz FightStick TE 2 */ |
1127 |
++ XPAD_XBOX360_VENDOR(0x07ff), /* Mad Catz GamePad */ |
1128 |
+ XPAD_XBOX360_VENDOR(0x0e6f), /* 0x0e6f X-Box 360 controllers */ |
1129 |
+ XPAD_XBOXONE_VENDOR(0x0e6f), /* 0x0e6f X-Box One controllers */ |
1130 |
++ XPAD_XBOX360_VENDOR(0x0f0d), /* Hori Controllers */ |
1131 |
++ XPAD_XBOXONE_VENDOR(0x0f0d), /* Hori Controllers */ |
1132 |
++ XPAD_XBOX360_VENDOR(0x11c9), /* Nacon GC100XF */ |
1133 |
+ XPAD_XBOX360_VENDOR(0x12ab), /* X-Box 360 dance pads */ |
1134 |
+ XPAD_XBOX360_VENDOR(0x1430), /* RedOctane X-Box 360 controllers */ |
1135 |
+ XPAD_XBOX360_VENDOR(0x146b), /* BigBen Interactive Controllers */ |
1136 |
+- XPAD_XBOX360_VENDOR(0x1bad), /* Harminix Rock Band Guitar and Drums */ |
1137 |
+- XPAD_XBOX360_VENDOR(0x0f0d), /* Hori Controllers */ |
1138 |
+- XPAD_XBOXONE_VENDOR(0x0f0d), /* Hori Controllers */ |
1139 |
+- XPAD_XBOX360_VENDOR(0x1689), /* Razer Onza */ |
1140 |
+- XPAD_XBOX360_VENDOR(0x24c6), /* PowerA Controllers */ |
1141 |
+- XPAD_XBOXONE_VENDOR(0x24c6), /* PowerA Controllers */ |
1142 |
+ XPAD_XBOX360_VENDOR(0x1532), /* Razer Sabertooth */ |
1143 |
+ XPAD_XBOXONE_VENDOR(0x1532), /* Razer Wildcat */ |
1144 |
+ XPAD_XBOX360_VENDOR(0x15e4), /* Numark X-Box 360 controllers */ |
1145 |
+ XPAD_XBOX360_VENDOR(0x162e), /* Joytech X-Box 360 controllers */ |
1146 |
++ XPAD_XBOX360_VENDOR(0x1689), /* Razer Onza */ |
1147 |
++ XPAD_XBOX360_VENDOR(0x1bad), /* Harminix Rock Band Guitar and Drums */ |
1148 |
++ XPAD_XBOX360_VENDOR(0x24c6), /* PowerA Controllers */ |
1149 |
++ XPAD_XBOXONE_VENDOR(0x24c6), /* PowerA Controllers */ |
1150 |
+ { } |
1151 |
+ }; |
1152 |
+ |
1153 |
+ MODULE_DEVICE_TABLE(usb, xpad_table); |
1154 |
+ |
1155 |
++struct xboxone_init_packet { |
1156 |
++ u16 idVendor; |
1157 |
++ u16 idProduct; |
1158 |
++ const u8 *data; |
1159 |
++ u8 len; |
1160 |
++}; |
1161 |
++ |
1162 |
++#define XBOXONE_INIT_PKT(_vid, _pid, _data) \ |
1163 |
++ { \ |
1164 |
++ .idVendor = (_vid), \ |
1165 |
++ .idProduct = (_pid), \ |
1166 |
++ .data = (_data), \ |
1167 |
++ .len = ARRAY_SIZE(_data), \ |
1168 |
++ } |
1169 |
++ |
1170 |
++ |
1171 |
++/* |
1172 |
++ * This packet is required for all Xbox One pads with 2015 |
1173 |
++ * or later firmware installed (or present from the factory). |
1174 |
++ */ |
1175 |
++static const u8 xboxone_fw2015_init[] = { |
1176 |
++ 0x05, 0x20, 0x00, 0x01, 0x00 |
1177 |
++}; |
1178 |
++ |
1179 |
++/* |
1180 |
++ * This packet is required for the Titanfall 2 Xbox One pads |
1181 |
++ * (0x0e6f:0x0165) to finish initialization and for Hori pads |
1182 |
++ * (0x0f0d:0x0067) to make the analog sticks work. |
1183 |
++ */ |
1184 |
++static const u8 xboxone_hori_init[] = { |
1185 |
++ 0x01, 0x20, 0x00, 0x09, 0x00, 0x04, 0x20, 0x3a, |
1186 |
++ 0x00, 0x00, 0x00, 0x80, 0x00 |
1187 |
++}; |
1188 |
++ |
1189 |
++/* |
1190 |
++ * This packet is required for some of the PDP pads to start |
1191 |
++ * sending input reports. These pads include: (0x0e6f:0x02ab), |
1192 |
++ * (0x0e6f:0x02a4). |
1193 |
++ */ |
1194 |
++static const u8 xboxone_pdp_init1[] = { |
1195 |
++ 0x0a, 0x20, 0x00, 0x03, 0x00, 0x01, 0x14 |
1196 |
++}; |
1197 |
++ |
1198 |
++/* |
1199 |
++ * This packet is required for some of the PDP pads to start |
1200 |
++ * sending input reports. These pads include: (0x0e6f:0x02ab), |
1201 |
++ * (0x0e6f:0x02a4). |
1202 |
++ */ |
1203 |
++static const u8 xboxone_pdp_init2[] = { |
1204 |
++ 0x06, 0x20, 0x00, 0x02, 0x01, 0x00 |
1205 |
++}; |
1206 |
++ |
1207 |
++/* |
1208 |
++ * A specific rumble packet is required for some PowerA pads to start |
1209 |
++ * sending input reports. One of those pads is (0x24c6:0x543a). |
1210 |
++ */ |
1211 |
++static const u8 xboxone_rumblebegin_init[] = { |
1212 |
++ 0x09, 0x00, 0x00, 0x09, 0x00, 0x0F, 0x00, 0x00, |
1213 |
++ 0x1D, 0x1D, 0xFF, 0x00, 0x00 |
1214 |
++}; |
1215 |
++ |
1216 |
++/* |
1217 |
++ * A rumble packet with zero FF intensity will immediately |
1218 |
++ * terminate the rumbling required to init PowerA pads. |
1219 |
++ * This should happen fast enough that the motors don't |
1220 |
++ * spin up to enough speed to actually vibrate the gamepad. |
1221 |
++ */ |
1222 |
++static const u8 xboxone_rumbleend_init[] = { |
1223 |
++ 0x09, 0x00, 0x00, 0x09, 0x00, 0x0F, 0x00, 0x00, |
1224 |
++ 0x00, 0x00, 0x00, 0x00, 0x00 |
1225 |
++}; |
1226 |
++ |
1227 |
++/* |
1228 |
++ * This specifies the selection of init packets that a gamepad |
1229 |
++ * will be sent on init *and* the order in which they will be |
1230 |
++ * sent. The correct sequence number will be added when the |
1231 |
++ * packet is going to be sent. |
1232 |
++ */ |
1233 |
++static const struct xboxone_init_packet xboxone_init_packets[] = { |
1234 |
++ XBOXONE_INIT_PKT(0x0e6f, 0x0165, xboxone_hori_init), |
1235 |
++ XBOXONE_INIT_PKT(0x0f0d, 0x0067, xboxone_hori_init), |
1236 |
++ XBOXONE_INIT_PKT(0x0000, 0x0000, xboxone_fw2015_init), |
1237 |
++ XBOXONE_INIT_PKT(0x0e6f, 0x02ab, xboxone_pdp_init1), |
1238 |
++ XBOXONE_INIT_PKT(0x0e6f, 0x02ab, xboxone_pdp_init2), |
1239 |
++ XBOXONE_INIT_PKT(0x0e6f, 0x02a4, xboxone_pdp_init1), |
1240 |
++ XBOXONE_INIT_PKT(0x0e6f, 0x02a4, xboxone_pdp_init2), |
1241 |
++ XBOXONE_INIT_PKT(0x0e6f, 0x02a6, xboxone_pdp_init1), |
1242 |
++ XBOXONE_INIT_PKT(0x0e6f, 0x02a6, xboxone_pdp_init2), |
1243 |
++ XBOXONE_INIT_PKT(0x24c6, 0x541a, xboxone_rumblebegin_init), |
1244 |
++ XBOXONE_INIT_PKT(0x24c6, 0x542a, xboxone_rumblebegin_init), |
1245 |
++ XBOXONE_INIT_PKT(0x24c6, 0x543a, xboxone_rumblebegin_init), |
1246 |
++ XBOXONE_INIT_PKT(0x24c6, 0x541a, xboxone_rumbleend_init), |
1247 |
++ XBOXONE_INIT_PKT(0x24c6, 0x542a, xboxone_rumbleend_init), |
1248 |
++ XBOXONE_INIT_PKT(0x24c6, 0x543a, xboxone_rumbleend_init), |
1249 |
++}; |
1250 |
++ |
1251 |
+ struct xpad_output_packet { |
1252 |
+ u8 data[XPAD_PKT_LEN]; |
1253 |
+ u8 len; |
1254 |
+@@ -374,6 +580,7 @@ struct usb_xpad { |
1255 |
+ |
1256 |
+ struct xpad_output_packet out_packets[XPAD_NUM_OUT_PACKETS]; |
1257 |
+ int last_out_packet; |
1258 |
++ int init_seq; |
1259 |
+ |
1260 |
+ #if defined(CONFIG_JOYSTICK_XPAD_LEDS) |
1261 |
+ struct xpad_led *led; |
1262 |
+@@ -390,6 +597,7 @@ struct usb_xpad { |
1263 |
+ |
1264 |
+ static int xpad_init_input(struct usb_xpad *xpad); |
1265 |
+ static void xpad_deinit_input(struct usb_xpad *xpad); |
1266 |
++static void xpadone_ack_mode_report(struct usb_xpad *xpad, u8 seq_num); |
1267 |
+ |
1268 |
+ /* |
1269 |
+ * xpad_process_packet |
1270 |
+@@ -609,14 +817,36 @@ static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned cha |
1271 |
+ } |
1272 |
+ |
1273 |
+ /* |
1274 |
+- * xpadone_process_buttons |
1275 |
++ * xpadone_process_packet |
1276 |
++ * |
1277 |
++ * Completes a request by converting the data into events for the |
1278 |
++ * input subsystem. This version is for the Xbox One controller. |
1279 |
+ * |
1280 |
+- * Process a button update packet from an Xbox one controller. |
1281 |
++ * The report format was gleaned from |
1282 |
++ * https://github.com/kylelemons/xbox/blob/master/xbox.go |
1283 |
+ */ |
1284 |
+-static void xpadone_process_buttons(struct usb_xpad *xpad, |
1285 |
+- struct input_dev *dev, |
1286 |
+- unsigned char *data) |
1287 |
++static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data) |
1288 |
+ { |
1289 |
++ struct input_dev *dev = xpad->dev; |
1290 |
++ |
1291 |
++ /* the xbox button has its own special report */ |
1292 |
++ if (data[0] == 0X07) { |
1293 |
++ /* |
1294 |
++ * The Xbox One S controller requires these reports to be |
1295 |
++ * acked otherwise it continues sending them forever and |
1296 |
++ * won't report further mode button events. |
1297 |
++ */ |
1298 |
++ if (data[1] == 0x30) |
1299 |
++ xpadone_ack_mode_report(xpad, data[2]); |
1300 |
++ |
1301 |
++ input_report_key(dev, BTN_MODE, data[4] & 0x01); |
1302 |
++ input_sync(dev); |
1303 |
++ return; |
1304 |
++ } |
1305 |
++ /* check invalid packet */ |
1306 |
++ else if (data[0] != 0X20) |
1307 |
++ return; |
1308 |
++ |
1309 |
+ /* menu/view buttons */ |
1310 |
+ input_report_key(dev, BTN_START, data[4] & 0x04); |
1311 |
+ input_report_key(dev, BTN_SELECT, data[4] & 0x08); |
1312 |
+@@ -679,34 +909,6 @@ static void xpadone_process_buttons(struct usb_xpad *xpad, |
1313 |
+ input_sync(dev); |
1314 |
+ } |
1315 |
+ |
1316 |
+-/* |
1317 |
+- * xpadone_process_packet |
1318 |
+- * |
1319 |
+- * Completes a request by converting the data into events for the |
1320 |
+- * input subsystem. This version is for the Xbox One controller. |
1321 |
+- * |
1322 |
+- * The report format was gleaned from |
1323 |
+- * https://github.com/kylelemons/xbox/blob/master/xbox.go |
1324 |
+- */ |
1325 |
+- |
1326 |
+-static void xpadone_process_packet(struct usb_xpad *xpad, |
1327 |
+- u16 cmd, unsigned char *data) |
1328 |
+-{ |
1329 |
+- struct input_dev *dev = xpad->dev; |
1330 |
+- |
1331 |
+- switch (data[0]) { |
1332 |
+- case 0x20: |
1333 |
+- xpadone_process_buttons(xpad, dev, data); |
1334 |
+- break; |
1335 |
+- |
1336 |
+- case 0x07: |
1337 |
+- /* the xbox button has its own special report */ |
1338 |
+- input_report_key(dev, BTN_MODE, data[4] & 0x01); |
1339 |
+- input_sync(dev); |
1340 |
+- break; |
1341 |
+- } |
1342 |
+-} |
1343 |
+- |
1344 |
+ static void xpad_irq_in(struct urb *urb) |
1345 |
+ { |
1346 |
+ struct usb_xpad *xpad = urb->context; |
1347 |
+@@ -753,12 +955,48 @@ exit: |
1348 |
+ __func__, retval); |
1349 |
+ } |
1350 |
+ |
1351 |
++/* Callers must hold xpad->odata_lock spinlock */ |
1352 |
++static bool xpad_prepare_next_init_packet(struct usb_xpad *xpad) |
1353 |
++{ |
1354 |
++ const struct xboxone_init_packet *init_packet; |
1355 |
++ |
1356 |
++ if (xpad->xtype != XTYPE_XBOXONE) |
1357 |
++ return false; |
1358 |
++ |
1359 |
++ /* Perform initialization sequence for Xbox One pads that require it */ |
1360 |
++ while (xpad->init_seq < ARRAY_SIZE(xboxone_init_packets)) { |
1361 |
++ init_packet = &xboxone_init_packets[xpad->init_seq++]; |
1362 |
++ |
1363 |
++ if (init_packet->idVendor != 0 && |
1364 |
++ init_packet->idVendor != xpad->dev->id.vendor) |
1365 |
++ continue; |
1366 |
++ |
1367 |
++ if (init_packet->idProduct != 0 && |
1368 |
++ init_packet->idProduct != xpad->dev->id.product) |
1369 |
++ continue; |
1370 |
++ |
1371 |
++ /* This packet applies to our device, so prepare to send it */ |
1372 |
++ memcpy(xpad->odata, init_packet->data, init_packet->len); |
1373 |
++ xpad->irq_out->transfer_buffer_length = init_packet->len; |
1374 |
++ |
1375 |
++ /* Update packet with current sequence number */ |
1376 |
++ xpad->odata[2] = xpad->odata_serial++; |
1377 |
++ return true; |
1378 |
++ } |
1379 |
++ |
1380 |
++ return false; |
1381 |
++} |
1382 |
++ |
1383 |
+ /* Callers must hold xpad->odata_lock spinlock */ |
1384 |
+ static bool xpad_prepare_next_out_packet(struct usb_xpad *xpad) |
1385 |
+ { |
1386 |
+ struct xpad_output_packet *pkt, *packet = NULL; |
1387 |
+ int i; |
1388 |
+ |
1389 |
++ /* We may have init packets to send before we can send user commands */ |
1390 |
++ if (xpad_prepare_next_init_packet(xpad)) |
1391 |
++ return true; |
1392 |
++ |
1393 |
+ for (i = 0; i < XPAD_NUM_OUT_PACKETS; i++) { |
1394 |
+ if (++xpad->last_out_packet >= XPAD_NUM_OUT_PACKETS) |
1395 |
+ xpad->last_out_packet = 0; |
1396 |
+@@ -851,10 +1089,9 @@ static void xpad_irq_out(struct urb *urb) |
1397 |
+ spin_unlock_irqrestore(&xpad->odata_lock, flags); |
1398 |
+ } |
1399 |
+ |
1400 |
+-static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad) |
1401 |
++static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad, |
1402 |
++ struct usb_endpoint_descriptor *ep_irq_out) |
1403 |
+ { |
1404 |
+- struct usb_endpoint_descriptor *ep_irq_out; |
1405 |
+- int ep_irq_out_idx; |
1406 |
+ int error; |
1407 |
+ |
1408 |
+ if (xpad->xtype == XTYPE_UNKNOWN) |
1409 |
+@@ -864,23 +1101,17 @@ static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad) |
1410 |
+ |
1411 |
+ xpad->odata = usb_alloc_coherent(xpad->udev, XPAD_PKT_LEN, |
1412 |
+ GFP_KERNEL, &xpad->odata_dma); |
1413 |
+- if (!xpad->odata) { |
1414 |
+- error = -ENOMEM; |
1415 |
+- goto fail1; |
1416 |
+- } |
1417 |
++ if (!xpad->odata) |
1418 |
++ return -ENOMEM; |
1419 |
+ |
1420 |
+ spin_lock_init(&xpad->odata_lock); |
1421 |
+ |
1422 |
+ xpad->irq_out = usb_alloc_urb(0, GFP_KERNEL); |
1423 |
+ if (!xpad->irq_out) { |
1424 |
+ error = -ENOMEM; |
1425 |
+- goto fail2; |
1426 |
++ goto err_free_coherent; |
1427 |
+ } |
1428 |
+ |
1429 |
+- /* Xbox One controller has in/out endpoints swapped. */ |
1430 |
+- ep_irq_out_idx = xpad->xtype == XTYPE_XBOXONE ? 0 : 1; |
1431 |
+- ep_irq_out = &intf->cur_altsetting->endpoint[ep_irq_out_idx].desc; |
1432 |
+- |
1433 |
+ usb_fill_int_urb(xpad->irq_out, xpad->udev, |
1434 |
+ usb_sndintpipe(xpad->udev, ep_irq_out->bEndpointAddress), |
1435 |
+ xpad->odata, XPAD_PKT_LEN, |
1436 |
+@@ -890,8 +1121,9 @@ static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad) |
1437 |
+ |
1438 |
+ return 0; |
1439 |
+ |
1440 |
+- fail2: usb_free_coherent(xpad->udev, XPAD_PKT_LEN, xpad->odata, xpad->odata_dma); |
1441 |
+- fail1: return error; |
1442 |
++err_free_coherent: |
1443 |
++ usb_free_coherent(xpad->udev, XPAD_PKT_LEN, xpad->odata, xpad->odata_dma); |
1444 |
++ return error; |
1445 |
+ } |
1446 |
+ |
1447 |
+ static void xpad_stop_output(struct usb_xpad *xpad) |
1448 |
+@@ -950,24 +1182,17 @@ static int xpad_inquiry_pad_presence(struct usb_xpad *xpad) |
1449 |
+ |
1450 |
+ static int xpad_start_xbox_one(struct usb_xpad *xpad) |
1451 |
+ { |
1452 |
+- struct xpad_output_packet *packet = |
1453 |
+- &xpad->out_packets[XPAD_OUT_CMD_IDX]; |
1454 |
+ unsigned long flags; |
1455 |
+ int retval; |
1456 |
+ |
1457 |
+ spin_lock_irqsave(&xpad->odata_lock, flags); |
1458 |
+ |
1459 |
+- /* Xbox one controller needs to be initialized. */ |
1460 |
+- packet->data[0] = 0x05; |
1461 |
+- packet->data[1] = 0x20; |
1462 |
+- packet->data[2] = xpad->odata_serial++; /* packet serial */ |
1463 |
+- packet->data[3] = 0x01; /* rumble bit enable? */ |
1464 |
+- packet->data[4] = 0x00; |
1465 |
+- packet->len = 5; |
1466 |
+- packet->pending = true; |
1467 |
+- |
1468 |
+- /* Reset the sequence so we send out start packet first */ |
1469 |
+- xpad->last_out_packet = -1; |
1470 |
++ /* |
1471 |
++ * Begin the init sequence by attempting to send a packet. |
1472 |
++ * We will cycle through the init packet sequence before |
1473 |
++ * sending any packets from the output ring. |
1474 |
++ */ |
1475 |
++ xpad->init_seq = 0; |
1476 |
+ retval = xpad_try_sending_next_out_packet(xpad); |
1477 |
+ |
1478 |
+ spin_unlock_irqrestore(&xpad->odata_lock, flags); |
1479 |
+@@ -975,6 +1200,30 @@ static int xpad_start_xbox_one(struct usb_xpad *xpad) |
1480 |
+ return retval; |
1481 |
+ } |
1482 |
+ |
1483 |
++static void xpadone_ack_mode_report(struct usb_xpad *xpad, u8 seq_num) |
1484 |
++{ |
1485 |
++ unsigned long flags; |
1486 |
++ struct xpad_output_packet *packet = |
1487 |
++ &xpad->out_packets[XPAD_OUT_CMD_IDX]; |
1488 |
++ static const u8 mode_report_ack[] = { |
1489 |
++ 0x01, 0x20, 0x00, 0x09, 0x00, 0x07, 0x20, 0x02, |
1490 |
++ 0x00, 0x00, 0x00, 0x00, 0x00 |
1491 |
++ }; |
1492 |
++ |
1493 |
++ spin_lock_irqsave(&xpad->odata_lock, flags); |
1494 |
++ |
1495 |
++ packet->len = sizeof(mode_report_ack); |
1496 |
++ memcpy(packet->data, mode_report_ack, packet->len); |
1497 |
++ packet->data[2] = seq_num; |
1498 |
++ packet->pending = true; |
1499 |
++ |
1500 |
++ /* Reset the sequence so we send out the ack now */ |
1501 |
++ xpad->last_out_packet = -1; |
1502 |
++ xpad_try_sending_next_out_packet(xpad); |
1503 |
++ |
1504 |
++ spin_unlock_irqrestore(&xpad->odata_lock, flags); |
1505 |
++} |
1506 |
++ |
1507 |
+ #ifdef CONFIG_JOYSTICK_XPAD_FF |
1508 |
+ static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect *effect) |
1509 |
+ { |
1510 |
+@@ -1046,9 +1295,9 @@ static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect |
1511 |
+ packet->data[7] = 0x00; |
1512 |
+ packet->data[8] = strong / 512; /* left actuator */ |
1513 |
+ packet->data[9] = weak / 512; /* right actuator */ |
1514 |
+- packet->data[10] = 0xFF; |
1515 |
+- packet->data[11] = 0x00; |
1516 |
+- packet->data[12] = 0x00; |
1517 |
++ packet->data[10] = 0xFF; /* on period */ |
1518 |
++ packet->data[11] = 0x00; /* off period */ |
1519 |
++ packet->data[12] = 0xFF; /* repeat count */ |
1520 |
+ packet->len = 13; |
1521 |
+ packet->pending = true; |
1522 |
+ break; |
1523 |
+@@ -1199,6 +1448,7 @@ static int xpad_led_probe(struct usb_xpad *xpad) |
1524 |
+ led_cdev = &led->led_cdev; |
1525 |
+ led_cdev->name = led->name; |
1526 |
+ led_cdev->brightness_set = xpad_led_set; |
1527 |
++ led_cdev->flags = LED_CORE_SUSPENDRESUME; |
1528 |
+ |
1529 |
+ error = led_classdev_register(&xpad->udev->dev, led_cdev); |
1530 |
+ if (error) |
1531 |
+@@ -1333,7 +1583,6 @@ static void xpad_close(struct input_dev *dev) |
1532 |
+ static void xpad_set_up_abs(struct input_dev *input_dev, signed short abs) |
1533 |
+ { |
1534 |
+ struct usb_xpad *xpad = input_get_drvdata(input_dev); |
1535 |
+- set_bit(abs, input_dev->absbit); |
1536 |
+ |
1537 |
+ switch (abs) { |
1538 |
+ case ABS_X: |
1539 |
+@@ -1353,6 +1602,9 @@ static void xpad_set_up_abs(struct input_dev *input_dev, signed short abs) |
1540 |
+ case ABS_HAT0Y: /* the d-pad (only if dpad is mapped to axes */ |
1541 |
+ input_set_abs_params(input_dev, abs, -1, 1, 0, 0); |
1542 |
+ break; |
1543 |
++ default: |
1544 |
++ input_set_abs_params(input_dev, abs, 0, 0, 0, 0); |
1545 |
++ break; |
1546 |
+ } |
1547 |
+ } |
1548 |
+ |
1549 |
+@@ -1393,10 +1645,7 @@ static int xpad_init_input(struct usb_xpad *xpad) |
1550 |
+ input_dev->close = xpad_close; |
1551 |
+ } |
1552 |
+ |
1553 |
+- __set_bit(EV_KEY, input_dev->evbit); |
1554 |
+- |
1555 |
+ if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { |
1556 |
+- __set_bit(EV_ABS, input_dev->evbit); |
1557 |
+ /* set up axes */ |
1558 |
+ for (i = 0; xpad_abs[i] >= 0; i++) |
1559 |
+ xpad_set_up_abs(input_dev, xpad_abs[i]); |
1560 |
+@@ -1404,21 +1653,22 @@ static int xpad_init_input(struct usb_xpad *xpad) |
1561 |
+ |
1562 |
+ /* set up standard buttons */ |
1563 |
+ for (i = 0; xpad_common_btn[i] >= 0; i++) |
1564 |
+- __set_bit(xpad_common_btn[i], input_dev->keybit); |
1565 |
++ input_set_capability(input_dev, EV_KEY, xpad_common_btn[i]); |
1566 |
+ |
1567 |
+ /* set up model-specific ones */ |
1568 |
+ if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W || |
1569 |
+ xpad->xtype == XTYPE_XBOXONE) { |
1570 |
+ for (i = 0; xpad360_btn[i] >= 0; i++) |
1571 |
+- __set_bit(xpad360_btn[i], input_dev->keybit); |
1572 |
++ input_set_capability(input_dev, EV_KEY, xpad360_btn[i]); |
1573 |
+ } else { |
1574 |
+ for (i = 0; xpad_btn[i] >= 0; i++) |
1575 |
+- __set_bit(xpad_btn[i], input_dev->keybit); |
1576 |
++ input_set_capability(input_dev, EV_KEY, xpad_btn[i]); |
1577 |
+ } |
1578 |
+ |
1579 |
+ if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { |
1580 |
+ for (i = 0; xpad_btn_pad[i] >= 0; i++) |
1581 |
+- __set_bit(xpad_btn_pad[i], input_dev->keybit); |
1582 |
++ input_set_capability(input_dev, EV_KEY, |
1583 |
++ xpad_btn_pad[i]); |
1584 |
+ } |
1585 |
+ |
1586 |
+ /* |
1587 |
+@@ -1435,7 +1685,8 @@ static int xpad_init_input(struct usb_xpad *xpad) |
1588 |
+ |
1589 |
+ if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { |
1590 |
+ for (i = 0; xpad_btn_triggers[i] >= 0; i++) |
1591 |
+- __set_bit(xpad_btn_triggers[i], input_dev->keybit); |
1592 |
++ input_set_capability(input_dev, EV_KEY, |
1593 |
++ xpad_btn_triggers[i]); |
1594 |
+ } else { |
1595 |
+ for (i = 0; xpad_abs_triggers[i] >= 0; i++) |
1596 |
+ xpad_set_up_abs(input_dev, xpad_abs_triggers[i]); |
1597 |
+@@ -1469,8 +1720,7 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id |
1598 |
+ { |
1599 |
+ struct usb_device *udev = interface_to_usbdev(intf); |
1600 |
+ struct usb_xpad *xpad; |
1601 |
+- struct usb_endpoint_descriptor *ep_irq_in; |
1602 |
+- int ep_irq_in_idx; |
1603 |
++ struct usb_endpoint_descriptor *ep_irq_in, *ep_irq_out; |
1604 |
+ int i, error; |
1605 |
+ |
1606 |
+ if (intf->cur_altsetting->desc.bNumEndpoints != 2) |
1607 |
+@@ -1540,13 +1790,28 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id |
1608 |
+ goto err_free_in_urb; |
1609 |
+ } |
1610 |
+ |
1611 |
+- error = xpad_init_output(intf, xpad); |
1612 |
+- if (error) |
1613 |
++ ep_irq_in = ep_irq_out = NULL; |
1614 |
++ |
1615 |
++ for (i = 0; i < 2; i++) { |
1616 |
++ struct usb_endpoint_descriptor *ep = |
1617 |
++ &intf->cur_altsetting->endpoint[i].desc; |
1618 |
++ |
1619 |
++ if (usb_endpoint_xfer_int(ep)) { |
1620 |
++ if (usb_endpoint_dir_in(ep)) |
1621 |
++ ep_irq_in = ep; |
1622 |
++ else |
1623 |
++ ep_irq_out = ep; |
1624 |
++ } |
1625 |
++ } |
1626 |
++ |
1627 |
++ if (!ep_irq_in || !ep_irq_out) { |
1628 |
++ error = -ENODEV; |
1629 |
+ goto err_free_in_urb; |
1630 |
++ } |
1631 |
+ |
1632 |
+- /* Xbox One controller has in/out endpoints swapped. */ |
1633 |
+- ep_irq_in_idx = xpad->xtype == XTYPE_XBOXONE ? 1 : 0; |
1634 |
+- ep_irq_in = &intf->cur_altsetting->endpoint[ep_irq_in_idx].desc; |
1635 |
++ error = xpad_init_output(intf, xpad, ep_irq_out); |
1636 |
++ if (error) |
1637 |
++ goto err_free_in_urb; |
1638 |
+ |
1639 |
+ usb_fill_int_urb(xpad->irq_in, udev, |
1640 |
+ usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), |
1641 |
+@@ -1663,8 +1928,16 @@ static int xpad_resume(struct usb_interface *intf) |
1642 |
+ retval = xpad360w_start_input(xpad); |
1643 |
+ } else { |
1644 |
+ mutex_lock(&input->mutex); |
1645 |
+- if (input->users) |
1646 |
++ if (input->users) { |
1647 |
+ retval = xpad_start_input(xpad); |
1648 |
++ } else if (xpad->xtype == XTYPE_XBOXONE) { |
1649 |
++ /* |
1650 |
++ * Even if there are no users, we'll send Xbox One pads |
1651 |
++ * the startup sequence so they don't sit there and |
1652 |
++ * blink until somebody opens the input device again. |
1653 |
++ */ |
1654 |
++ retval = xpad_start_xbox_one(xpad); |
1655 |
++ } |
1656 |
+ mutex_unlock(&input->mutex); |
1657 |
+ } |
1658 |
+ |
1659 |
+diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c |
1660 |
+index 8d6208c0b400..ff3d9fc0f1b3 100644 |
1661 |
+--- a/drivers/net/can/dev.c |
1662 |
++++ b/drivers/net/can/dev.c |
1663 |
+@@ -453,6 +453,34 @@ void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, |
1664 |
+ } |
1665 |
+ EXPORT_SYMBOL_GPL(can_put_echo_skb); |
1666 |
+ |
1667 |
++struct sk_buff *__can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr) |
1668 |
++{ |
1669 |
++ struct can_priv *priv = netdev_priv(dev); |
1670 |
++ struct sk_buff *skb = priv->echo_skb[idx]; |
1671 |
++ struct canfd_frame *cf; |
1672 |
++ |
1673 |
++ if (idx >= priv->echo_skb_max) { |
1674 |
++ netdev_err(dev, "%s: BUG! Trying to access can_priv::echo_skb out of bounds (%u/max %u)\n", |
1675 |
++ __func__, idx, priv->echo_skb_max); |
1676 |
++ return NULL; |
1677 |
++ } |
1678 |
++ |
1679 |
++ if (!skb) { |
1680 |
++ netdev_err(dev, "%s: BUG! Trying to echo non existing skb: can_priv::echo_skb[%u]\n", |
1681 |
++ __func__, idx); |
1682 |
++ return NULL; |
1683 |
++ } |
1684 |
++ |
1685 |
++ /* Using "struct canfd_frame::len" for the frame |
1686 |
++ * length is supported on both CAN and CANFD frames. |
1687 |
++ */ |
1688 |
++ cf = (struct canfd_frame *)skb->data; |
1689 |
++ *len_ptr = cf->len; |
1690 |
++ priv->echo_skb[idx] = NULL; |
1691 |
++ |
1692 |
++ return skb; |
1693 |
++} |
1694 |
++ |
1695 |
+ /* |
1696 |
+ * Get the skb from the stack and loop it back locally |
1697 |
+ * |
1698 |
+@@ -462,22 +490,16 @@ EXPORT_SYMBOL_GPL(can_put_echo_skb); |
1699 |
+ */ |
1700 |
+ unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx) |
1701 |
+ { |
1702 |
+- struct can_priv *priv = netdev_priv(dev); |
1703 |
+- |
1704 |
+- BUG_ON(idx >= priv->echo_skb_max); |
1705 |
+- |
1706 |
+- if (priv->echo_skb[idx]) { |
1707 |
+- struct sk_buff *skb = priv->echo_skb[idx]; |
1708 |
+- struct can_frame *cf = (struct can_frame *)skb->data; |
1709 |
+- u8 dlc = cf->can_dlc; |
1710 |
++ struct sk_buff *skb; |
1711 |
++ u8 len; |
1712 |
+ |
1713 |
+- netif_rx(priv->echo_skb[idx]); |
1714 |
+- priv->echo_skb[idx] = NULL; |
1715 |
++ skb = __can_get_echo_skb(dev, idx, &len); |
1716 |
++ if (!skb) |
1717 |
++ return 0; |
1718 |
+ |
1719 |
+- return dlc; |
1720 |
+- } |
1721 |
++ netif_rx(skb); |
1722 |
+ |
1723 |
+- return 0; |
1724 |
++ return len; |
1725 |
+ } |
1726 |
+ EXPORT_SYMBOL_GPL(can_get_echo_skb); |
1727 |
+ |
1728 |
+diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c |
1729 |
+index 3b9e1a5dce82..9bd90a7c4d40 100644 |
1730 |
+--- a/drivers/net/ethernet/broadcom/genet/bcmmii.c |
1731 |
++++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c |
1732 |
+@@ -483,7 +483,7 @@ static int bcmgenet_mii_of_init(struct bcmgenet_priv *priv) |
1733 |
+ if (!compat) |
1734 |
+ return -ENOMEM; |
1735 |
+ |
1736 |
+- priv->mdio_dn = of_find_compatible_node(dn, NULL, compat); |
1737 |
++ priv->mdio_dn = of_get_compatible_child(dn, compat); |
1738 |
+ kfree(compat); |
1739 |
+ if (!priv->mdio_dn) { |
1740 |
+ dev_err(kdev, "unable to find MDIO bus node\n"); |
1741 |
+diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c |
1742 |
+index 0cbcd3f77341..6b4e38105b72 100644 |
1743 |
+--- a/drivers/net/usb/lan78xx.c |
1744 |
++++ b/drivers/net/usb/lan78xx.c |
1745 |
+@@ -31,6 +31,7 @@ |
1746 |
+ #include <linux/mdio.h> |
1747 |
+ #include <net/ip6_checksum.h> |
1748 |
+ #include <linux/microchipphy.h> |
1749 |
++#include <linux/of_net.h> |
1750 |
+ #include "lan78xx.h" |
1751 |
+ |
1752 |
+ #define DRIVER_AUTHOR "WOOJUNG HUH <woojung.huh@×××××××××.com>" |
1753 |
+@@ -1644,34 +1645,31 @@ static void lan78xx_init_mac_address(struct lan78xx_net *dev) |
1754 |
+ addr[5] = (addr_hi >> 8) & 0xFF; |
1755 |
+ |
1756 |
+ if (!is_valid_ether_addr(addr)) { |
1757 |
+- /* reading mac address from EEPROM or OTP */ |
1758 |
+- if ((lan78xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN, |
1759 |
+- addr) == 0) || |
1760 |
+- (lan78xx_read_otp(dev, EEPROM_MAC_OFFSET, ETH_ALEN, |
1761 |
+- addr) == 0)) { |
1762 |
+- if (is_valid_ether_addr(addr)) { |
1763 |
+- /* eeprom values are valid so use them */ |
1764 |
+- netif_dbg(dev, ifup, dev->net, |
1765 |
+- "MAC address read from EEPROM"); |
1766 |
+- } else { |
1767 |
+- /* generate random MAC */ |
1768 |
+- random_ether_addr(addr); |
1769 |
+- netif_dbg(dev, ifup, dev->net, |
1770 |
+- "MAC address set to random addr"); |
1771 |
+- } |
1772 |
+- |
1773 |
+- addr_lo = addr[0] | (addr[1] << 8) | |
1774 |
+- (addr[2] << 16) | (addr[3] << 24); |
1775 |
+- addr_hi = addr[4] | (addr[5] << 8); |
1776 |
+- |
1777 |
+- ret = lan78xx_write_reg(dev, RX_ADDRL, addr_lo); |
1778 |
+- ret = lan78xx_write_reg(dev, RX_ADDRH, addr_hi); |
1779 |
++ if (!eth_platform_get_mac_address(&dev->udev->dev, addr)) { |
1780 |
++ /* valid address present in Device Tree */ |
1781 |
++ netif_dbg(dev, ifup, dev->net, |
1782 |
++ "MAC address read from Device Tree"); |
1783 |
++ } else if (((lan78xx_read_eeprom(dev, EEPROM_MAC_OFFSET, |
1784 |
++ ETH_ALEN, addr) == 0) || |
1785 |
++ (lan78xx_read_otp(dev, EEPROM_MAC_OFFSET, |
1786 |
++ ETH_ALEN, addr) == 0)) && |
1787 |
++ is_valid_ether_addr(addr)) { |
1788 |
++ /* eeprom values are valid so use them */ |
1789 |
++ netif_dbg(dev, ifup, dev->net, |
1790 |
++ "MAC address read from EEPROM"); |
1791 |
+ } else { |
1792 |
+ /* generate random MAC */ |
1793 |
+ random_ether_addr(addr); |
1794 |
+ netif_dbg(dev, ifup, dev->net, |
1795 |
+ "MAC address set to random addr"); |
1796 |
+ } |
1797 |
++ |
1798 |
++ addr_lo = addr[0] | (addr[1] << 8) | |
1799 |
++ (addr[2] << 16) | (addr[3] << 24); |
1800 |
++ addr_hi = addr[4] | (addr[5] << 8); |
1801 |
++ |
1802 |
++ ret = lan78xx_write_reg(dev, RX_ADDRL, addr_lo); |
1803 |
++ ret = lan78xx_write_reg(dev, RX_ADDRH, addr_hi); |
1804 |
+ } |
1805 |
+ |
1806 |
+ ret = lan78xx_write_reg(dev, MAF_LO(0), addr_lo); |
1807 |
+diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c |
1808 |
+index 5fe6841b8889..fb632a454fc2 100644 |
1809 |
+--- a/drivers/net/wireless/ath/ath10k/mac.c |
1810 |
++++ b/drivers/net/wireless/ath/ath10k/mac.c |
1811 |
+@@ -4967,7 +4967,9 @@ static int ath10k_add_interface(struct ieee80211_hw *hw, |
1812 |
+ } |
1813 |
+ |
1814 |
+ ar->free_vdev_map &= ~(1LL << arvif->vdev_id); |
1815 |
++ spin_lock_bh(&ar->data_lock); |
1816 |
+ list_add(&arvif->list, &ar->arvifs); |
1817 |
++ spin_unlock_bh(&ar->data_lock); |
1818 |
+ |
1819 |
+ /* It makes no sense to have firmware do keepalives. mac80211 already |
1820 |
+ * takes care of this with idle connection polling. |
1821 |
+@@ -5118,7 +5120,9 @@ err_peer_delete: |
1822 |
+ err_vdev_delete: |
1823 |
+ ath10k_wmi_vdev_delete(ar, arvif->vdev_id); |
1824 |
+ ar->free_vdev_map |= 1LL << arvif->vdev_id; |
1825 |
++ spin_lock_bh(&ar->data_lock); |
1826 |
+ list_del(&arvif->list); |
1827 |
++ spin_unlock_bh(&ar->data_lock); |
1828 |
+ |
1829 |
+ err: |
1830 |
+ if (arvif->beacon_buf) { |
1831 |
+@@ -5164,7 +5168,9 @@ static void ath10k_remove_interface(struct ieee80211_hw *hw, |
1832 |
+ arvif->vdev_id, ret); |
1833 |
+ |
1834 |
+ ar->free_vdev_map |= 1LL << arvif->vdev_id; |
1835 |
++ spin_lock_bh(&ar->data_lock); |
1836 |
+ list_del(&arvif->list); |
1837 |
++ spin_unlock_bh(&ar->data_lock); |
1838 |
+ |
1839 |
+ if (arvif->vdev_type == WMI_VDEV_TYPE_AP || |
1840 |
+ arvif->vdev_type == WMI_VDEV_TYPE_IBSS) { |
1841 |
+diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c |
1842 |
+index c221597e2519..530f52120972 100644 |
1843 |
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c |
1844 |
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c |
1845 |
+@@ -5990,7 +5990,8 @@ static int brcmf_construct_chaninfo(struct brcmf_cfg80211_info *cfg, |
1846 |
+ * for subsequent chanspecs. |
1847 |
+ */ |
1848 |
+ channel->flags = IEEE80211_CHAN_NO_HT40 | |
1849 |
+- IEEE80211_CHAN_NO_80MHZ; |
1850 |
++ IEEE80211_CHAN_NO_80MHZ | |
1851 |
++ IEEE80211_CHAN_NO_160MHZ; |
1852 |
+ ch.bw = BRCMU_CHAN_BW_20; |
1853 |
+ cfg->d11inf.encchspec(&ch); |
1854 |
+ chaninfo = ch.chspec; |
1855 |
+diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c |
1856 |
+index 0bffade1ea5b..92557cd31a39 100644 |
1857 |
+--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c |
1858 |
++++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c |
1859 |
+@@ -327,8 +327,12 @@ struct ieee80211_regdomain *iwl_mvm_get_regdomain(struct wiphy *wiphy, |
1860 |
+ goto out; |
1861 |
+ } |
1862 |
+ |
1863 |
+- if (changed) |
1864 |
+- *changed = (resp->status == MCC_RESP_NEW_CHAN_PROFILE); |
1865 |
++ if (changed) { |
1866 |
++ u32 status = le32_to_cpu(resp->status); |
1867 |
++ |
1868 |
++ *changed = (status == MCC_RESP_NEW_CHAN_PROFILE || |
1869 |
++ status == MCC_RESP_ILLEGAL); |
1870 |
++ } |
1871 |
+ |
1872 |
+ regd = iwl_parse_nvm_mcc_info(mvm->trans->dev, mvm->cfg, |
1873 |
+ __le32_to_cpu(resp->n_channels), |
1874 |
+@@ -3976,10 +3980,6 @@ static void iwl_mvm_mac_sta_statistics(struct ieee80211_hw *hw, |
1875 |
+ sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL_AVG); |
1876 |
+ } |
1877 |
+ |
1878 |
+- if (!fw_has_capa(&mvm->fw->ucode_capa, |
1879 |
+- IWL_UCODE_TLV_CAPA_RADIO_BEACON_STATS)) |
1880 |
+- return; |
1881 |
+- |
1882 |
+ /* if beacon filtering isn't on mac80211 does it anyway */ |
1883 |
+ if (!(vif->driver_flags & IEEE80211_VIF_BEACON_FILTER)) |
1884 |
+ return; |
1885 |
+diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c b/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c |
1886 |
+index eade099b6dbf..e51aca87b4b0 100644 |
1887 |
+--- a/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c |
1888 |
++++ b/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c |
1889 |
+@@ -739,9 +739,8 @@ iwl_mvm_update_mcc(struct iwl_mvm *mvm, const char *alpha2, |
1890 |
+ } |
1891 |
+ |
1892 |
+ IWL_DEBUG_LAR(mvm, |
1893 |
+- "MCC response status: 0x%x. new MCC: 0x%x ('%c%c') change: %d n_chans: %d\n", |
1894 |
+- status, mcc, mcc >> 8, mcc & 0xff, |
1895 |
+- !!(status == MCC_RESP_NEW_CHAN_PROFILE), n_channels); |
1896 |
++ "MCC response status: 0x%x. new MCC: 0x%x ('%c%c') n_chans: %d\n", |
1897 |
++ status, mcc, mcc >> 8, mcc & 0xff, n_channels); |
1898 |
+ |
1899 |
+ exit: |
1900 |
+ iwl_free_resp(&cmd); |
1901 |
+diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c |
1902 |
+index 48d51be11f9b..4da3541471e6 100644 |
1903 |
+--- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c |
1904 |
++++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c |
1905 |
+@@ -1209,6 +1209,12 @@ mwifiex_cfg80211_change_virtual_intf(struct wiphy *wiphy, |
1906 |
+ priv->adapter->curr_iface_comb.p2p_intf--; |
1907 |
+ priv->adapter->curr_iface_comb.sta_intf++; |
1908 |
+ dev->ieee80211_ptr->iftype = type; |
1909 |
++ if (mwifiex_deinit_priv_params(priv)) |
1910 |
++ return -1; |
1911 |
++ if (mwifiex_init_new_priv_params(priv, dev, type)) |
1912 |
++ return -1; |
1913 |
++ if (mwifiex_sta_init_cmd(priv, false, false)) |
1914 |
++ return -1; |
1915 |
+ break; |
1916 |
+ case NL80211_IFTYPE_ADHOC: |
1917 |
+ if (mwifiex_cfg80211_deinit_p2p(priv)) |
1918 |
+@@ -3079,8 +3085,10 @@ int mwifiex_del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev) |
1919 |
+ |
1920 |
+ mwifiex_stop_net_dev_queue(priv->netdev, adapter); |
1921 |
+ |
1922 |
+- skb_queue_walk_safe(&priv->bypass_txq, skb, tmp) |
1923 |
++ skb_queue_walk_safe(&priv->bypass_txq, skb, tmp) { |
1924 |
++ skb_unlink(skb, &priv->bypass_txq); |
1925 |
+ mwifiex_write_data_complete(priv->adapter, skb, 0, -1); |
1926 |
++ } |
1927 |
+ |
1928 |
+ if (netif_carrier_ok(priv->netdev)) |
1929 |
+ netif_carrier_off(priv->netdev); |
1930 |
+diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c |
1931 |
+index 1fdb86cd4734..cb681b265b10 100644 |
1932 |
+--- a/drivers/net/wireless/marvell/mwifiex/pcie.c |
1933 |
++++ b/drivers/net/wireless/marvell/mwifiex/pcie.c |
1934 |
+@@ -101,7 +101,6 @@ static int mwifiex_pcie_suspend(struct device *dev) |
1935 |
+ { |
1936 |
+ struct mwifiex_adapter *adapter; |
1937 |
+ struct pcie_service_card *card; |
1938 |
+- int hs_actived; |
1939 |
+ struct pci_dev *pdev = to_pci_dev(dev); |
1940 |
+ |
1941 |
+ if (pdev) { |
1942 |
+@@ -117,7 +116,15 @@ static int mwifiex_pcie_suspend(struct device *dev) |
1943 |
+ |
1944 |
+ adapter = card->adapter; |
1945 |
+ |
1946 |
+- hs_actived = mwifiex_enable_hs(adapter); |
1947 |
++ /* Enable the Host Sleep */ |
1948 |
++ if (!mwifiex_enable_hs(adapter)) { |
1949 |
++ mwifiex_dbg(adapter, ERROR, |
1950 |
++ "cmd: failed to suspend\n"); |
1951 |
++ adapter->hs_enabling = false; |
1952 |
++ return -EFAULT; |
1953 |
++ } |
1954 |
++ |
1955 |
++ flush_workqueue(adapter->workqueue); |
1956 |
+ |
1957 |
+ /* Indicate device suspended */ |
1958 |
+ adapter->is_suspended = true; |
1959 |
+@@ -1676,9 +1683,6 @@ static int mwifiex_pcie_process_cmd_complete(struct mwifiex_adapter *adapter) |
1960 |
+ |
1961 |
+ if (!adapter->curr_cmd) { |
1962 |
+ if (adapter->ps_state == PS_STATE_SLEEP_CFM) { |
1963 |
+- mwifiex_process_sleep_confirm_resp(adapter, skb->data, |
1964 |
+- skb->len); |
1965 |
+- mwifiex_pcie_enable_host_int(adapter); |
1966 |
+ if (mwifiex_write_reg(adapter, |
1967 |
+ PCIE_CPU_INT_EVENT, |
1968 |
+ CPU_INTR_SLEEP_CFM_DONE)) { |
1969 |
+@@ -1691,6 +1695,9 @@ static int mwifiex_pcie_process_cmd_complete(struct mwifiex_adapter *adapter) |
1970 |
+ while (reg->sleep_cookie && (count++ < 10) && |
1971 |
+ mwifiex_pcie_ok_to_access_hw(adapter)) |
1972 |
+ usleep_range(50, 60); |
1973 |
++ mwifiex_pcie_enable_host_int(adapter); |
1974 |
++ mwifiex_process_sleep_confirm_resp(adapter, skb->data, |
1975 |
++ skb->len); |
1976 |
+ } else { |
1977 |
+ mwifiex_dbg(adapter, ERROR, |
1978 |
+ "There is no command but got cmdrsp\n"); |
1979 |
+@@ -2329,6 +2336,8 @@ static int mwifiex_process_pcie_int(struct mwifiex_adapter *adapter) |
1980 |
+ ret = mwifiex_pcie_process_cmd_complete(adapter); |
1981 |
+ if (ret) |
1982 |
+ return ret; |
1983 |
++ if (adapter->hs_activated) |
1984 |
++ return ret; |
1985 |
+ } |
1986 |
+ |
1987 |
+ if (card->msi_enable) { |
1988 |
+diff --git a/drivers/net/wireless/marvell/mwifiex/wmm.c b/drivers/net/wireless/marvell/mwifiex/wmm.c |
1989 |
+index 0eb246502e1d..dea2fe671dfe 100644 |
1990 |
+--- a/drivers/net/wireless/marvell/mwifiex/wmm.c |
1991 |
++++ b/drivers/net/wireless/marvell/mwifiex/wmm.c |
1992 |
+@@ -503,8 +503,10 @@ mwifiex_wmm_del_pkts_in_ralist_node(struct mwifiex_private *priv, |
1993 |
+ struct mwifiex_adapter *adapter = priv->adapter; |
1994 |
+ struct sk_buff *skb, *tmp; |
1995 |
+ |
1996 |
+- skb_queue_walk_safe(&ra_list->skb_head, skb, tmp) |
1997 |
++ skb_queue_walk_safe(&ra_list->skb_head, skb, tmp) { |
1998 |
++ skb_unlink(skb, &ra_list->skb_head); |
1999 |
+ mwifiex_write_data_complete(adapter, skb, 0, -1); |
2000 |
++ } |
2001 |
+ } |
2002 |
+ |
2003 |
+ /* |
2004 |
+@@ -600,11 +602,15 @@ mwifiex_clean_txrx(struct mwifiex_private *priv) |
2005 |
+ priv->adapter->if_ops.clean_pcie_ring(priv->adapter); |
2006 |
+ spin_unlock_irqrestore(&priv->wmm.ra_list_spinlock, flags); |
2007 |
+ |
2008 |
+- skb_queue_walk_safe(&priv->tdls_txq, skb, tmp) |
2009 |
++ skb_queue_walk_safe(&priv->tdls_txq, skb, tmp) { |
2010 |
++ skb_unlink(skb, &priv->tdls_txq); |
2011 |
+ mwifiex_write_data_complete(priv->adapter, skb, 0, -1); |
2012 |
++ } |
2013 |
+ |
2014 |
+- skb_queue_walk_safe(&priv->bypass_txq, skb, tmp) |
2015 |
++ skb_queue_walk_safe(&priv->bypass_txq, skb, tmp) { |
2016 |
++ skb_unlink(skb, &priv->bypass_txq); |
2017 |
+ mwifiex_write_data_complete(priv->adapter, skb, 0, -1); |
2018 |
++ } |
2019 |
+ atomic_set(&priv->adapter->bypass_tx_pending, 0); |
2020 |
+ |
2021 |
+ idr_for_each(&priv->ack_status_frames, mwifiex_free_ack_frame, NULL); |
2022 |
+diff --git a/drivers/net/wireless/st/cw1200/wsm.c b/drivers/net/wireless/st/cw1200/wsm.c |
2023 |
+index ed93bf3474ec..be4c22e0d902 100644 |
2024 |
+--- a/drivers/net/wireless/st/cw1200/wsm.c |
2025 |
++++ b/drivers/net/wireless/st/cw1200/wsm.c |
2026 |
+@@ -1805,16 +1805,18 @@ static int wsm_buf_reserve(struct wsm_buf *buf, size_t extra_size) |
2027 |
+ { |
2028 |
+ size_t pos = buf->data - buf->begin; |
2029 |
+ size_t size = pos + extra_size; |
2030 |
++ u8 *tmp; |
2031 |
+ |
2032 |
+ size = round_up(size, FWLOAD_BLOCK_SIZE); |
2033 |
+ |
2034 |
+- buf->begin = krealloc(buf->begin, size, GFP_KERNEL | GFP_DMA); |
2035 |
+- if (buf->begin) { |
2036 |
+- buf->data = &buf->begin[pos]; |
2037 |
+- buf->end = &buf->begin[size]; |
2038 |
+- return 0; |
2039 |
+- } else { |
2040 |
+- buf->end = buf->data = buf->begin; |
2041 |
++ tmp = krealloc(buf->begin, size, GFP_KERNEL | GFP_DMA); |
2042 |
++ if (!tmp) { |
2043 |
++ wsm_buf_deinit(buf); |
2044 |
+ return -ENOMEM; |
2045 |
+ } |
2046 |
++ |
2047 |
++ buf->begin = tmp; |
2048 |
++ buf->data = &buf->begin[pos]; |
2049 |
++ buf->end = &buf->begin[size]; |
2050 |
++ return 0; |
2051 |
+ } |
2052 |
+diff --git a/drivers/nfc/nfcmrvl/uart.c b/drivers/nfc/nfcmrvl/uart.c |
2053 |
+index 6c0c301611c4..1b11ded79c4f 100644 |
2054 |
+--- a/drivers/nfc/nfcmrvl/uart.c |
2055 |
++++ b/drivers/nfc/nfcmrvl/uart.c |
2056 |
+@@ -73,10 +73,9 @@ static int nfcmrvl_uart_parse_dt(struct device_node *node, |
2057 |
+ struct device_node *matched_node; |
2058 |
+ int ret; |
2059 |
+ |
2060 |
+- matched_node = of_find_compatible_node(node, NULL, "marvell,nfc-uart"); |
2061 |
++ matched_node = of_get_compatible_child(node, "marvell,nfc-uart"); |
2062 |
+ if (!matched_node) { |
2063 |
+- matched_node = of_find_compatible_node(node, NULL, |
2064 |
+- "mrvl,nfc-uart"); |
2065 |
++ matched_node = of_get_compatible_child(node, "mrvl,nfc-uart"); |
2066 |
+ if (!matched_node) |
2067 |
+ return -ENODEV; |
2068 |
+ } |
2069 |
+diff --git a/drivers/of/base.c b/drivers/of/base.c |
2070 |
+index 466b285cef3e..f366af135d5b 100644 |
2071 |
+--- a/drivers/of/base.c |
2072 |
++++ b/drivers/of/base.c |
2073 |
+@@ -738,6 +738,31 @@ struct device_node *of_get_next_available_child(const struct device_node *node, |
2074 |
+ } |
2075 |
+ EXPORT_SYMBOL(of_get_next_available_child); |
2076 |
+ |
2077 |
++/** |
2078 |
++ * of_get_compatible_child - Find compatible child node |
2079 |
++ * @parent: parent node |
2080 |
++ * @compatible: compatible string |
2081 |
++ * |
2082 |
++ * Lookup child node whose compatible property contains the given compatible |
2083 |
++ * string. |
2084 |
++ * |
2085 |
++ * Returns a node pointer with refcount incremented, use of_node_put() on it |
2086 |
++ * when done; or NULL if not found. |
2087 |
++ */ |
2088 |
++struct device_node *of_get_compatible_child(const struct device_node *parent, |
2089 |
++ const char *compatible) |
2090 |
++{ |
2091 |
++ struct device_node *child; |
2092 |
++ |
2093 |
++ for_each_child_of_node(parent, child) { |
2094 |
++ if (of_device_is_compatible(child, compatible)) |
2095 |
++ break; |
2096 |
++ } |
2097 |
++ |
2098 |
++ return child; |
2099 |
++} |
2100 |
++EXPORT_SYMBOL(of_get_compatible_child); |
2101 |
++ |
2102 |
+ /** |
2103 |
+ * of_get_child_by_name - Find the child node by name for a given parent |
2104 |
+ * @node: parent node |
2105 |
+diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c |
2106 |
+index 9443c9d408c6..df61a71420b1 100644 |
2107 |
+--- a/drivers/pinctrl/meson/pinctrl-meson.c |
2108 |
++++ b/drivers/pinctrl/meson/pinctrl-meson.c |
2109 |
+@@ -275,7 +275,7 @@ static int meson_pinconf_set(struct pinctrl_dev *pcdev, unsigned int pin, |
2110 |
+ dev_dbg(pc->dev, "pin %u: disable bias\n", pin); |
2111 |
+ |
2112 |
+ meson_calc_reg_and_bit(bank, pin, REG_PULL, ®, &bit); |
2113 |
+- ret = regmap_update_bits(pc->reg_pull, reg, |
2114 |
++ ret = regmap_update_bits(pc->reg_pullen, reg, |
2115 |
+ BIT(bit), 0); |
2116 |
+ if (ret) |
2117 |
+ return ret; |
2118 |
+diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c |
2119 |
+index 2bfdf638b673..8a3667e761dd 100644 |
2120 |
+--- a/drivers/rtc/rtc-pcf2127.c |
2121 |
++++ b/drivers/rtc/rtc-pcf2127.c |
2122 |
+@@ -237,6 +237,9 @@ static int pcf2127_i2c_gather_write(void *context, |
2123 |
+ memcpy(buf + 1, val, val_size); |
2124 |
+ |
2125 |
+ ret = i2c_master_send(client, buf, val_size + 1); |
2126 |
++ |
2127 |
++ kfree(buf); |
2128 |
++ |
2129 |
+ if (ret != val_size + 1) |
2130 |
+ return ret < 0 ? ret : -EIO; |
2131 |
+ |
2132 |
+diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h |
2133 |
+index 5bb2316f60bf..54deeb754db5 100644 |
2134 |
+--- a/drivers/scsi/ufs/ufs.h |
2135 |
++++ b/drivers/scsi/ufs/ufs.h |
2136 |
+@@ -46,6 +46,7 @@ |
2137 |
+ #define QUERY_DESC_HDR_SIZE 2 |
2138 |
+ #define QUERY_OSF_SIZE (GENERAL_UPIU_REQUEST_SIZE - \ |
2139 |
+ (sizeof(struct utp_upiu_header))) |
2140 |
++#define RESPONSE_UPIU_SENSE_DATA_LENGTH 18 |
2141 |
+ |
2142 |
+ #define UPIU_HEADER_DWORD(byte3, byte2, byte1, byte0)\ |
2143 |
+ cpu_to_be32((byte3 << 24) | (byte2 << 16) |\ |
2144 |
+@@ -410,7 +411,7 @@ struct utp_cmd_rsp { |
2145 |
+ __be32 residual_transfer_count; |
2146 |
+ __be32 reserved[4]; |
2147 |
+ __be16 sense_data_len; |
2148 |
+- u8 sense_data[18]; |
2149 |
++ u8 sense_data[RESPONSE_UPIU_SENSE_DATA_LENGTH]; |
2150 |
+ }; |
2151 |
+ |
2152 |
+ /** |
2153 |
+diff --git a/drivers/scsi/ufs/ufshcd-pci.c b/drivers/scsi/ufs/ufshcd-pci.c |
2154 |
+index d15eaa466c59..52b546fb509b 100644 |
2155 |
+--- a/drivers/scsi/ufs/ufshcd-pci.c |
2156 |
++++ b/drivers/scsi/ufs/ufshcd-pci.c |
2157 |
+@@ -104,6 +104,7 @@ static void ufshcd_pci_remove(struct pci_dev *pdev) |
2158 |
+ pm_runtime_forbid(&pdev->dev); |
2159 |
+ pm_runtime_get_noresume(&pdev->dev); |
2160 |
+ ufshcd_remove(hba); |
2161 |
++ ufshcd_dealloc_host(hba); |
2162 |
+ } |
2163 |
+ |
2164 |
+ /** |
2165 |
+@@ -147,6 +148,7 @@ ufshcd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) |
2166 |
+ err = ufshcd_init(hba, mmio_base, pdev->irq); |
2167 |
+ if (err) { |
2168 |
+ dev_err(&pdev->dev, "Initialization failed\n"); |
2169 |
++ ufshcd_dealloc_host(hba); |
2170 |
+ return err; |
2171 |
+ } |
2172 |
+ |
2173 |
+diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c |
2174 |
+index db53f38da864..a72a4ba78125 100644 |
2175 |
+--- a/drivers/scsi/ufs/ufshcd-pltfrm.c |
2176 |
++++ b/drivers/scsi/ufs/ufshcd-pltfrm.c |
2177 |
+@@ -163,7 +163,7 @@ static int ufshcd_populate_vreg(struct device *dev, const char *name, |
2178 |
+ if (ret) { |
2179 |
+ dev_err(dev, "%s: unable to find %s err %d\n", |
2180 |
+ __func__, prop_name, ret); |
2181 |
+- goto out_free; |
2182 |
++ goto out; |
2183 |
+ } |
2184 |
+ |
2185 |
+ vreg->min_uA = 0; |
2186 |
+@@ -185,9 +185,6 @@ static int ufshcd_populate_vreg(struct device *dev, const char *name, |
2187 |
+ |
2188 |
+ goto out; |
2189 |
+ |
2190 |
+-out_free: |
2191 |
+- devm_kfree(dev, vreg); |
2192 |
+- vreg = NULL; |
2193 |
+ out: |
2194 |
+ if (!ret) |
2195 |
+ *out_vreg = vreg; |
2196 |
+diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c |
2197 |
+index f857086ce2fa..5cfd56f08ffb 100644 |
2198 |
+--- a/drivers/scsi/ufs/ufshcd.c |
2199 |
++++ b/drivers/scsi/ufs/ufshcd.c |
2200 |
+@@ -672,6 +672,21 @@ int ufshcd_hold(struct ufs_hba *hba, bool async) |
2201 |
+ start: |
2202 |
+ switch (hba->clk_gating.state) { |
2203 |
+ case CLKS_ON: |
2204 |
++ /* |
2205 |
++ * Wait for the ungate work to complete if in progress. |
2206 |
++ * Though the clocks may be in ON state, the link could |
2207 |
++ * still be in hibner8 state if hibern8 is allowed |
2208 |
++ * during clock gating. |
2209 |
++ * Make sure we exit hibern8 state also in addition to |
2210 |
++ * clocks being ON. |
2211 |
++ */ |
2212 |
++ if (ufshcd_can_hibern8_during_gating(hba) && |
2213 |
++ ufshcd_is_link_hibern8(hba)) { |
2214 |
++ spin_unlock_irqrestore(hba->host->host_lock, flags); |
2215 |
++ flush_work(&hba->clk_gating.ungate_work); |
2216 |
++ spin_lock_irqsave(hba->host->host_lock, flags); |
2217 |
++ goto start; |
2218 |
++ } |
2219 |
+ break; |
2220 |
+ case REQ_CLKS_OFF: |
2221 |
+ if (cancel_delayed_work(&hba->clk_gating.gate_work)) { |
2222 |
+@@ -901,10 +916,14 @@ static inline void ufshcd_copy_sense_data(struct ufshcd_lrb *lrbp) |
2223 |
+ int len; |
2224 |
+ if (lrbp->sense_buffer && |
2225 |
+ ufshcd_get_rsp_upiu_data_seg_len(lrbp->ucd_rsp_ptr)) { |
2226 |
++ int len_to_copy; |
2227 |
++ |
2228 |
+ len = be16_to_cpu(lrbp->ucd_rsp_ptr->sr.sense_data_len); |
2229 |
++ len_to_copy = min_t(int, RESPONSE_UPIU_SENSE_DATA_LENGTH, len); |
2230 |
++ |
2231 |
+ memcpy(lrbp->sense_buffer, |
2232 |
+ lrbp->ucd_rsp_ptr->sr.sense_data, |
2233 |
+- min_t(int, len, SCSI_SENSE_BUFFERSIZE)); |
2234 |
++ min_t(int, len_to_copy, SCSI_SENSE_BUFFERSIZE)); |
2235 |
+ } |
2236 |
+ } |
2237 |
+ |
2238 |
+@@ -6373,7 +6392,10 @@ EXPORT_SYMBOL(ufshcd_system_suspend); |
2239 |
+ |
2240 |
+ int ufshcd_system_resume(struct ufs_hba *hba) |
2241 |
+ { |
2242 |
+- if (!hba || !hba->is_powered || pm_runtime_suspended(hba->dev)) |
2243 |
++ if (!hba) |
2244 |
++ return -EINVAL; |
2245 |
++ |
2246 |
++ if (!hba->is_powered || pm_runtime_suspended(hba->dev)) |
2247 |
+ /* |
2248 |
+ * Let the runtime resume take care of resuming |
2249 |
+ * if runtime suspended. |
2250 |
+@@ -6394,7 +6416,10 @@ EXPORT_SYMBOL(ufshcd_system_resume); |
2251 |
+ */ |
2252 |
+ int ufshcd_runtime_suspend(struct ufs_hba *hba) |
2253 |
+ { |
2254 |
+- if (!hba || !hba->is_powered) |
2255 |
++ if (!hba) |
2256 |
++ return -EINVAL; |
2257 |
++ |
2258 |
++ if (!hba->is_powered) |
2259 |
+ return 0; |
2260 |
+ |
2261 |
+ return ufshcd_suspend(hba, UFS_RUNTIME_PM); |
2262 |
+@@ -6424,10 +6449,13 @@ EXPORT_SYMBOL(ufshcd_runtime_suspend); |
2263 |
+ */ |
2264 |
+ int ufshcd_runtime_resume(struct ufs_hba *hba) |
2265 |
+ { |
2266 |
+- if (!hba || !hba->is_powered) |
2267 |
++ if (!hba) |
2268 |
++ return -EINVAL; |
2269 |
++ |
2270 |
++ if (!hba->is_powered) |
2271 |
+ return 0; |
2272 |
+- else |
2273 |
+- return ufshcd_resume(hba, UFS_RUNTIME_PM); |
2274 |
++ |
2275 |
++ return ufshcd_resume(hba, UFS_RUNTIME_PM); |
2276 |
+ } |
2277 |
+ EXPORT_SYMBOL(ufshcd_runtime_resume); |
2278 |
+ |
2279 |
+@@ -6479,8 +6507,6 @@ void ufshcd_remove(struct ufs_hba *hba) |
2280 |
+ ufshcd_disable_intr(hba, hba->intr_mask); |
2281 |
+ ufshcd_hba_stop(hba, true); |
2282 |
+ |
2283 |
+- scsi_host_put(hba->host); |
2284 |
+- |
2285 |
+ ufshcd_exit_clk_gating(hba); |
2286 |
+ if (ufshcd_is_clkscaling_enabled(hba)) |
2287 |
+ devfreq_remove_device(hba->devfreq); |
2288 |
+@@ -6605,15 +6631,47 @@ static int ufshcd_devfreq_target(struct device *dev, |
2289 |
+ { |
2290 |
+ int err = 0; |
2291 |
+ struct ufs_hba *hba = dev_get_drvdata(dev); |
2292 |
++ bool release_clk_hold = false; |
2293 |
++ unsigned long irq_flags; |
2294 |
+ |
2295 |
+ if (!ufshcd_is_clkscaling_enabled(hba)) |
2296 |
+ return -EINVAL; |
2297 |
+ |
2298 |
++ spin_lock_irqsave(hba->host->host_lock, irq_flags); |
2299 |
++ if (ufshcd_eh_in_progress(hba)) { |
2300 |
++ spin_unlock_irqrestore(hba->host->host_lock, irq_flags); |
2301 |
++ return 0; |
2302 |
++ } |
2303 |
++ |
2304 |
++ if (ufshcd_is_clkgating_allowed(hba) && |
2305 |
++ (hba->clk_gating.state != CLKS_ON)) { |
2306 |
++ if (cancel_delayed_work(&hba->clk_gating.gate_work)) { |
2307 |
++ /* hold the vote until the scaling work is completed */ |
2308 |
++ hba->clk_gating.active_reqs++; |
2309 |
++ release_clk_hold = true; |
2310 |
++ hba->clk_gating.state = CLKS_ON; |
2311 |
++ } else { |
2312 |
++ /* |
2313 |
++ * Clock gating work seems to be running in parallel |
2314 |
++ * hence skip scaling work to avoid deadlock between |
2315 |
++ * current scaling work and gating work. |
2316 |
++ */ |
2317 |
++ spin_unlock_irqrestore(hba->host->host_lock, irq_flags); |
2318 |
++ return 0; |
2319 |
++ } |
2320 |
++ } |
2321 |
++ spin_unlock_irqrestore(hba->host->host_lock, irq_flags); |
2322 |
++ |
2323 |
+ if (*freq == UINT_MAX) |
2324 |
+ err = ufshcd_scale_clks(hba, true); |
2325 |
+ else if (*freq == 0) |
2326 |
+ err = ufshcd_scale_clks(hba, false); |
2327 |
+ |
2328 |
++ spin_lock_irqsave(hba->host->host_lock, irq_flags); |
2329 |
++ if (release_clk_hold) |
2330 |
++ __ufshcd_release(hba); |
2331 |
++ spin_unlock_irqrestore(hba->host->host_lock, irq_flags); |
2332 |
++ |
2333 |
+ return err; |
2334 |
+ } |
2335 |
+ |
2336 |
+@@ -6816,7 +6874,6 @@ exit_gating: |
2337 |
+ ufshcd_exit_clk_gating(hba); |
2338 |
+ out_disable: |
2339 |
+ hba->is_irq_enabled = false; |
2340 |
+- scsi_host_put(host); |
2341 |
+ ufshcd_hba_exit(hba); |
2342 |
+ out_error: |
2343 |
+ return err; |
2344 |
+diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c |
2345 |
+index 0475f9685a41..904fc9c37fde 100644 |
2346 |
+--- a/drivers/tty/n_tty.c |
2347 |
++++ b/drivers/tty/n_tty.c |
2348 |
+@@ -154,17 +154,28 @@ static inline unsigned char *echo_buf_addr(struct n_tty_data *ldata, size_t i) |
2349 |
+ return &ldata->echo_buf[i & (N_TTY_BUF_SIZE - 1)]; |
2350 |
+ } |
2351 |
+ |
2352 |
++/* If we are not echoing the data, perhaps this is a secret so erase it */ |
2353 |
++static void zero_buffer(struct tty_struct *tty, u8 *buffer, int size) |
2354 |
++{ |
2355 |
++ bool icanon = !!L_ICANON(tty); |
2356 |
++ bool no_echo = !L_ECHO(tty); |
2357 |
++ |
2358 |
++ if (icanon && no_echo) |
2359 |
++ memset(buffer, 0x00, size); |
2360 |
++} |
2361 |
++ |
2362 |
+ static int tty_copy_to_user(struct tty_struct *tty, void __user *to, |
2363 |
+ size_t tail, size_t n) |
2364 |
+ { |
2365 |
+ struct n_tty_data *ldata = tty->disc_data; |
2366 |
+ size_t size = N_TTY_BUF_SIZE - tail; |
2367 |
+- const void *from = read_buf_addr(ldata, tail); |
2368 |
++ void *from = read_buf_addr(ldata, tail); |
2369 |
+ int uncopied; |
2370 |
+ |
2371 |
+ if (n > size) { |
2372 |
+ tty_audit_add_data(tty, from, size); |
2373 |
+ uncopied = copy_to_user(to, from, size); |
2374 |
++ zero_buffer(tty, from, size - uncopied); |
2375 |
+ if (uncopied) |
2376 |
+ return uncopied; |
2377 |
+ to += size; |
2378 |
+@@ -173,7 +184,9 @@ static int tty_copy_to_user(struct tty_struct *tty, void __user *to, |
2379 |
+ } |
2380 |
+ |
2381 |
+ tty_audit_add_data(tty, from, n); |
2382 |
+- return copy_to_user(to, from, n); |
2383 |
++ uncopied = copy_to_user(to, from, n); |
2384 |
++ zero_buffer(tty, from, n - uncopied); |
2385 |
++ return uncopied; |
2386 |
+ } |
2387 |
+ |
2388 |
+ /** |
2389 |
+@@ -1962,11 +1975,12 @@ static int copy_from_read_buf(struct tty_struct *tty, |
2390 |
+ n = min(head - ldata->read_tail, N_TTY_BUF_SIZE - tail); |
2391 |
+ n = min(*nr, n); |
2392 |
+ if (n) { |
2393 |
+- const unsigned char *from = read_buf_addr(ldata, tail); |
2394 |
++ unsigned char *from = read_buf_addr(ldata, tail); |
2395 |
+ retval = copy_to_user(*b, from, n); |
2396 |
+ n -= retval; |
2397 |
+ is_eof = n == 1 && *from == EOF_CHAR(tty); |
2398 |
+ tty_audit_add_data(tty, from, n); |
2399 |
++ zero_buffer(tty, from, n); |
2400 |
+ smp_store_release(&ldata->read_tail, ldata->read_tail + n); |
2401 |
+ /* Turn single EOF into zero-length read */ |
2402 |
+ if (L_EXTPROC(tty) && ldata->icanon && is_eof && |
2403 |
+diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c |
2404 |
+index e99f1c5b1df6..41b9a7ccce08 100644 |
2405 |
+--- a/drivers/tty/tty_buffer.c |
2406 |
++++ b/drivers/tty/tty_buffer.c |
2407 |
+@@ -458,6 +458,8 @@ int tty_ldisc_receive_buf(struct tty_ldisc *ld, unsigned char *p, |
2408 |
+ if (count && ld->ops->receive_buf) |
2409 |
+ ld->ops->receive_buf(ld->tty, p, f, count); |
2410 |
+ } |
2411 |
++ if (count > 0) |
2412 |
++ memset(p, 0, count); |
2413 |
+ return count; |
2414 |
+ } |
2415 |
+ EXPORT_SYMBOL_GPL(tty_ldisc_receive_buf); |
2416 |
+diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c |
2417 |
+index 7aee55244b4a..851f5a553de2 100644 |
2418 |
+--- a/drivers/usb/core/hub.c |
2419 |
++++ b/drivers/usb/core/hub.c |
2420 |
+@@ -2809,7 +2809,9 @@ static int hub_port_reset(struct usb_hub *hub, int port1, |
2421 |
+ USB_PORT_FEAT_C_BH_PORT_RESET); |
2422 |
+ usb_clear_port_feature(hub->hdev, port1, |
2423 |
+ USB_PORT_FEAT_C_PORT_LINK_STATE); |
2424 |
+- usb_clear_port_feature(hub->hdev, port1, |
2425 |
++ |
2426 |
++ if (udev) |
2427 |
++ usb_clear_port_feature(hub->hdev, port1, |
2428 |
+ USB_PORT_FEAT_C_CONNECTION); |
2429 |
+ |
2430 |
+ /* |
2431 |
+diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c |
2432 |
+index 53b26e978d90..1e91b803ee4e 100644 |
2433 |
+--- a/drivers/usb/dwc3/core.c |
2434 |
++++ b/drivers/usb/dwc3/core.c |
2435 |
+@@ -1145,6 +1145,7 @@ static int dwc3_probe(struct platform_device *pdev) |
2436 |
+ |
2437 |
+ err5: |
2438 |
+ dwc3_event_buffers_cleanup(dwc); |
2439 |
++ dwc3_ulpi_exit(dwc); |
2440 |
+ |
2441 |
+ err4: |
2442 |
+ dwc3_free_scratch_buffers(dwc); |
2443 |
+diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c |
2444 |
+index 0f09ab5399f4..00d10660ff14 100644 |
2445 |
+--- a/drivers/usb/host/xhci-hub.c |
2446 |
++++ b/drivers/usb/host/xhci-hub.c |
2447 |
+@@ -768,7 +768,7 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd, |
2448 |
+ status |= USB_PORT_STAT_SUSPEND; |
2449 |
+ } |
2450 |
+ if ((raw_port_status & PORT_PLS_MASK) == XDEV_RESUME && |
2451 |
+- !DEV_SUPERSPEED_ANY(raw_port_status)) { |
2452 |
++ !DEV_SUPERSPEED_ANY(raw_port_status) && hcd->speed < HCD_USB3) { |
2453 |
+ if ((raw_port_status & PORT_RESET) || |
2454 |
+ !(raw_port_status & PORT_PE)) |
2455 |
+ return 0xffffffff; |
2456 |
+@@ -814,7 +814,7 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd, |
2457 |
+ time_left = wait_for_completion_timeout( |
2458 |
+ &bus_state->rexit_done[wIndex], |
2459 |
+ msecs_to_jiffies( |
2460 |
+- XHCI_MAX_REXIT_TIMEOUT)); |
2461 |
++ XHCI_MAX_REXIT_TIMEOUT_MS)); |
2462 |
+ spin_lock_irqsave(&xhci->lock, flags); |
2463 |
+ |
2464 |
+ if (time_left) { |
2465 |
+@@ -828,7 +828,7 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd, |
2466 |
+ } else { |
2467 |
+ int port_status = readl(port_array[wIndex]); |
2468 |
+ xhci_warn(xhci, "Port resume took longer than %i msec, port status = 0x%x\n", |
2469 |
+- XHCI_MAX_REXIT_TIMEOUT, |
2470 |
++ XHCI_MAX_REXIT_TIMEOUT_MS, |
2471 |
+ port_status); |
2472 |
+ status |= USB_PORT_STAT_SUSPEND; |
2473 |
+ clear_bit(wIndex, &bus_state->rexit_ports); |
2474 |
+@@ -1322,13 +1322,16 @@ int xhci_bus_suspend(struct usb_hcd *hcd) |
2475 |
+ __le32 __iomem **port_array; |
2476 |
+ struct xhci_bus_state *bus_state; |
2477 |
+ unsigned long flags; |
2478 |
++ u32 portsc_buf[USB_MAXCHILDREN]; |
2479 |
++ bool wake_enabled; |
2480 |
+ |
2481 |
+ max_ports = xhci_get_ports(hcd, &port_array); |
2482 |
+ bus_state = &xhci->bus_state[hcd_index(hcd)]; |
2483 |
++ wake_enabled = hcd->self.root_hub->do_remote_wakeup; |
2484 |
+ |
2485 |
+ spin_lock_irqsave(&xhci->lock, flags); |
2486 |
+ |
2487 |
+- if (hcd->self.root_hub->do_remote_wakeup) { |
2488 |
++ if (wake_enabled) { |
2489 |
+ if (bus_state->resuming_ports || /* USB2 */ |
2490 |
+ bus_state->port_remote_wakeup) { /* USB3 */ |
2491 |
+ spin_unlock_irqrestore(&xhci->lock, flags); |
2492 |
+@@ -1336,26 +1339,36 @@ int xhci_bus_suspend(struct usb_hcd *hcd) |
2493 |
+ return -EBUSY; |
2494 |
+ } |
2495 |
+ } |
2496 |
+- |
2497 |
+- port_index = max_ports; |
2498 |
++ /* |
2499 |
++ * Prepare ports for suspend, but don't write anything before all ports |
2500 |
++ * are checked and we know bus suspend can proceed |
2501 |
++ */ |
2502 |
+ bus_state->bus_suspended = 0; |
2503 |
++ port_index = max_ports; |
2504 |
+ while (port_index--) { |
2505 |
+- /* suspend the port if the port is not suspended */ |
2506 |
+ u32 t1, t2; |
2507 |
+- int slot_id; |
2508 |
+ |
2509 |
+ t1 = readl(port_array[port_index]); |
2510 |
+ t2 = xhci_port_state_to_neutral(t1); |
2511 |
++ portsc_buf[port_index] = 0; |
2512 |
+ |
2513 |
+- if ((t1 & PORT_PE) && !(t1 & PORT_PLS_MASK)) { |
2514 |
+- xhci_dbg(xhci, "port %d not suspended\n", port_index); |
2515 |
+- slot_id = xhci_find_slot_id_by_port(hcd, xhci, |
2516 |
+- port_index + 1); |
2517 |
+- if (slot_id) { |
2518 |
++ /* Bail out if a USB3 port has a new device in link training */ |
2519 |
++ if ((t1 & PORT_PLS_MASK) == XDEV_POLLING) { |
2520 |
++ bus_state->bus_suspended = 0; |
2521 |
++ spin_unlock_irqrestore(&xhci->lock, flags); |
2522 |
++ xhci_dbg(xhci, "Bus suspend bailout, port in polling\n"); |
2523 |
++ return -EBUSY; |
2524 |
++ } |
2525 |
++ |
2526 |
++ /* suspend ports in U0, or bail out for new connect changes */ |
2527 |
++ if ((t1 & PORT_PE) && (t1 & PORT_PLS_MASK) == XDEV_U0) { |
2528 |
++ if ((t1 & PORT_CSC) && wake_enabled) { |
2529 |
++ bus_state->bus_suspended = 0; |
2530 |
+ spin_unlock_irqrestore(&xhci->lock, flags); |
2531 |
+- xhci_stop_device(xhci, slot_id, 1); |
2532 |
+- spin_lock_irqsave(&xhci->lock, flags); |
2533 |
++ xhci_dbg(xhci, "Bus suspend bailout, port connect change\n"); |
2534 |
++ return -EBUSY; |
2535 |
+ } |
2536 |
++ xhci_dbg(xhci, "port %d not suspended\n", port_index); |
2537 |
+ t2 &= ~PORT_PLS_MASK; |
2538 |
+ t2 |= PORT_LINK_STROBE | XDEV_U3; |
2539 |
+ set_bit(port_index, &bus_state->bus_suspended); |
2540 |
+@@ -1364,7 +1377,7 @@ int xhci_bus_suspend(struct usb_hcd *hcd) |
2541 |
+ * including the USB 3.0 roothub, but only if CONFIG_PM |
2542 |
+ * is enabled, so also enable remote wake here. |
2543 |
+ */ |
2544 |
+- if (hcd->self.root_hub->do_remote_wakeup) { |
2545 |
++ if (wake_enabled) { |
2546 |
+ if (t1 & PORT_CONNECT) { |
2547 |
+ t2 |= PORT_WKOC_E | PORT_WKDISC_E; |
2548 |
+ t2 &= ~PORT_WKCONN_E; |
2549 |
+@@ -1377,7 +1390,26 @@ int xhci_bus_suspend(struct usb_hcd *hcd) |
2550 |
+ |
2551 |
+ t1 = xhci_port_state_to_neutral(t1); |
2552 |
+ if (t1 != t2) |
2553 |
+- writel(t2, port_array[port_index]); |
2554 |
++ portsc_buf[port_index] = t2; |
2555 |
++ } |
2556 |
++ |
2557 |
++ /* write port settings, stopping and suspending ports if needed */ |
2558 |
++ port_index = max_ports; |
2559 |
++ while (port_index--) { |
2560 |
++ if (!portsc_buf[port_index]) |
2561 |
++ continue; |
2562 |
++ if (test_bit(port_index, &bus_state->bus_suspended)) { |
2563 |
++ int slot_id; |
2564 |
++ |
2565 |
++ slot_id = xhci_find_slot_id_by_port(hcd, xhci, |
2566 |
++ port_index + 1); |
2567 |
++ if (slot_id) { |
2568 |
++ spin_unlock_irqrestore(&xhci->lock, flags); |
2569 |
++ xhci_stop_device(xhci, slot_id, 1); |
2570 |
++ spin_lock_irqsave(&xhci->lock, flags); |
2571 |
++ } |
2572 |
++ } |
2573 |
++ writel(portsc_buf[port_index], port_array[port_index]); |
2574 |
+ } |
2575 |
+ hcd->state = HC_STATE_SUSPENDED; |
2576 |
+ bus_state->next_statechange = jiffies + msecs_to_jiffies(10); |
2577 |
+diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c |
2578 |
+index 89a14d5f6ad8..f4e34a75d413 100644 |
2579 |
+--- a/drivers/usb/host/xhci-ring.c |
2580 |
++++ b/drivers/usb/host/xhci-ring.c |
2581 |
+@@ -1676,7 +1676,7 @@ static void handle_port_status(struct xhci_hcd *xhci, |
2582 |
+ * RExit to a disconnect state). If so, let the the driver know it's |
2583 |
+ * out of the RExit state. |
2584 |
+ */ |
2585 |
+- if (!DEV_SUPERSPEED_ANY(temp) && |
2586 |
++ if (!DEV_SUPERSPEED_ANY(temp) && hcd->speed < HCD_USB3 && |
2587 |
+ test_and_clear_bit(faked_port_index, |
2588 |
+ &bus_state->rexit_ports)) { |
2589 |
+ complete(&bus_state->rexit_done[faked_port_index]); |
2590 |
+diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h |
2591 |
+index b9181281aa9e..e679fec9ce3a 100644 |
2592 |
+--- a/drivers/usb/host/xhci.h |
2593 |
++++ b/drivers/usb/host/xhci.h |
2594 |
+@@ -1509,7 +1509,7 @@ struct xhci_bus_state { |
2595 |
+ * It can take up to 20 ms to transition from RExit to U0 on the |
2596 |
+ * Intel Lynx Point LP xHCI host. |
2597 |
+ */ |
2598 |
+-#define XHCI_MAX_REXIT_TIMEOUT (20 * 1000) |
2599 |
++#define XHCI_MAX_REXIT_TIMEOUT_MS 20 |
2600 |
+ |
2601 |
+ static inline unsigned int hcd_index(struct usb_hcd *hcd) |
2602 |
+ { |
2603 |
+diff --git a/fs/9p/vfs_dir.c b/fs/9p/vfs_dir.c |
2604 |
+index b0405d6aac85..48db9a9f13f9 100644 |
2605 |
+--- a/fs/9p/vfs_dir.c |
2606 |
++++ b/fs/9p/vfs_dir.c |
2607 |
+@@ -76,15 +76,6 @@ static inline int dt_type(struct p9_wstat *mistat) |
2608 |
+ return rettype; |
2609 |
+ } |
2610 |
+ |
2611 |
+-static void p9stat_init(struct p9_wstat *stbuf) |
2612 |
+-{ |
2613 |
+- stbuf->name = NULL; |
2614 |
+- stbuf->uid = NULL; |
2615 |
+- stbuf->gid = NULL; |
2616 |
+- stbuf->muid = NULL; |
2617 |
+- stbuf->extension = NULL; |
2618 |
+-} |
2619 |
+- |
2620 |
+ /** |
2621 |
+ * v9fs_alloc_rdir_buf - Allocate buffer used for read and readdir |
2622 |
+ * @filp: opened file structure |
2623 |
+@@ -145,12 +136,10 @@ static int v9fs_dir_readdir(struct file *file, struct dir_context *ctx) |
2624 |
+ rdir->tail = n; |
2625 |
+ } |
2626 |
+ while (rdir->head < rdir->tail) { |
2627 |
+- p9stat_init(&st); |
2628 |
+ err = p9stat_read(fid->clnt, rdir->buf + rdir->head, |
2629 |
+ rdir->tail - rdir->head, &st); |
2630 |
+ if (err) { |
2631 |
+ p9_debug(P9_DEBUG_VFS, "returned %d\n", err); |
2632 |
+- p9stat_free(&st); |
2633 |
+ return -EIO; |
2634 |
+ } |
2635 |
+ reclen = st.size+2; |
2636 |
+diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c |
2637 |
+index 1e5c896f6b79..0acb83efedea 100644 |
2638 |
+--- a/fs/bfs/inode.c |
2639 |
++++ b/fs/bfs/inode.c |
2640 |
+@@ -350,7 +350,8 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent) |
2641 |
+ |
2642 |
+ s->s_magic = BFS_MAGIC; |
2643 |
+ |
2644 |
+- if (le32_to_cpu(bfs_sb->s_start) > le32_to_cpu(bfs_sb->s_end)) { |
2645 |
++ if (le32_to_cpu(bfs_sb->s_start) > le32_to_cpu(bfs_sb->s_end) || |
2646 |
++ le32_to_cpu(bfs_sb->s_start) < BFS_BSIZE) { |
2647 |
+ printf("Superblock is corrupted\n"); |
2648 |
+ goto out1; |
2649 |
+ } |
2650 |
+@@ -359,9 +360,11 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent) |
2651 |
+ sizeof(struct bfs_inode) |
2652 |
+ + BFS_ROOT_INO - 1; |
2653 |
+ imap_len = (info->si_lasti / 8) + 1; |
2654 |
+- info->si_imap = kzalloc(imap_len, GFP_KERNEL); |
2655 |
+- if (!info->si_imap) |
2656 |
++ info->si_imap = kzalloc(imap_len, GFP_KERNEL | __GFP_NOWARN); |
2657 |
++ if (!info->si_imap) { |
2658 |
++ printf("Cannot allocate %u bytes\n", imap_len); |
2659 |
+ goto out1; |
2660 |
++ } |
2661 |
+ for (i = 0; i < BFS_ROOT_INO; i++) |
2662 |
+ set_bit(i, info->si_imap); |
2663 |
+ |
2664 |
+diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c |
2665 |
+index 6d7f66816319..84e5ac061b17 100644 |
2666 |
+--- a/fs/gfs2/ops_fstype.c |
2667 |
++++ b/fs/gfs2/ops_fstype.c |
2668 |
+@@ -71,13 +71,13 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb) |
2669 |
+ if (!sdp) |
2670 |
+ return NULL; |
2671 |
+ |
2672 |
+- sb->s_fs_info = sdp; |
2673 |
+ sdp->sd_vfs = sb; |
2674 |
+ sdp->sd_lkstats = alloc_percpu(struct gfs2_pcpu_lkstats); |
2675 |
+ if (!sdp->sd_lkstats) { |
2676 |
+ kfree(sdp); |
2677 |
+ return NULL; |
2678 |
+ } |
2679 |
++ sb->s_fs_info = sdp; |
2680 |
+ |
2681 |
+ set_bit(SDF_NOJOURNALID, &sdp->sd_flags); |
2682 |
+ gfs2_tune_init(&sdp->sd_tune); |
2683 |
+diff --git a/fs/namei.c b/fs/namei.c |
2684 |
+index 85ac38b99065..eb4626bad88a 100644 |
2685 |
+--- a/fs/namei.c |
2686 |
++++ b/fs/namei.c |
2687 |
+@@ -892,6 +892,8 @@ static inline void put_link(struct nameidata *nd) |
2688 |
+ |
2689 |
+ int sysctl_protected_symlinks __read_mostly = 0; |
2690 |
+ int sysctl_protected_hardlinks __read_mostly = 0; |
2691 |
++int sysctl_protected_fifos __read_mostly; |
2692 |
++int sysctl_protected_regular __read_mostly; |
2693 |
+ |
2694 |
+ /** |
2695 |
+ * may_follow_link - Check symlink following for unsafe situations |
2696 |
+@@ -1005,6 +1007,45 @@ static int may_linkat(struct path *link) |
2697 |
+ return -EPERM; |
2698 |
+ } |
2699 |
+ |
2700 |
++/** |
2701 |
++ * may_create_in_sticky - Check whether an O_CREAT open in a sticky directory |
2702 |
++ * should be allowed, or not, on files that already |
2703 |
++ * exist. |
2704 |
++ * @dir: the sticky parent directory |
2705 |
++ * @inode: the inode of the file to open |
2706 |
++ * |
2707 |
++ * Block an O_CREAT open of a FIFO (or a regular file) when: |
2708 |
++ * - sysctl_protected_fifos (or sysctl_protected_regular) is enabled |
2709 |
++ * - the file already exists |
2710 |
++ * - we are in a sticky directory |
2711 |
++ * - we don't own the file |
2712 |
++ * - the owner of the directory doesn't own the file |
2713 |
++ * - the directory is world writable |
2714 |
++ * If the sysctl_protected_fifos (or sysctl_protected_regular) is set to 2 |
2715 |
++ * the directory doesn't have to be world writable: being group writable will |
2716 |
++ * be enough. |
2717 |
++ * |
2718 |
++ * Returns 0 if the open is allowed, -ve on error. |
2719 |
++ */ |
2720 |
++static int may_create_in_sticky(struct dentry * const dir, |
2721 |
++ struct inode * const inode) |
2722 |
++{ |
2723 |
++ if ((!sysctl_protected_fifos && S_ISFIFO(inode->i_mode)) || |
2724 |
++ (!sysctl_protected_regular && S_ISREG(inode->i_mode)) || |
2725 |
++ likely(!(dir->d_inode->i_mode & S_ISVTX)) || |
2726 |
++ uid_eq(inode->i_uid, dir->d_inode->i_uid) || |
2727 |
++ uid_eq(current_fsuid(), inode->i_uid)) |
2728 |
++ return 0; |
2729 |
++ |
2730 |
++ if (likely(dir->d_inode->i_mode & 0002) || |
2731 |
++ (dir->d_inode->i_mode & 0020 && |
2732 |
++ ((sysctl_protected_fifos >= 2 && S_ISFIFO(inode->i_mode)) || |
2733 |
++ (sysctl_protected_regular >= 2 && S_ISREG(inode->i_mode))))) { |
2734 |
++ return -EACCES; |
2735 |
++ } |
2736 |
++ return 0; |
2737 |
++} |
2738 |
++ |
2739 |
+ static __always_inline |
2740 |
+ const char *get_link(struct nameidata *nd) |
2741 |
+ { |
2742 |
+@@ -3356,9 +3397,15 @@ finish_open: |
2743 |
+ if (error) |
2744 |
+ return error; |
2745 |
+ audit_inode(nd->name, nd->path.dentry, 0); |
2746 |
+- error = -EISDIR; |
2747 |
+- if ((open_flag & O_CREAT) && d_is_dir(nd->path.dentry)) |
2748 |
+- goto out; |
2749 |
++ if (open_flag & O_CREAT) { |
2750 |
++ error = -EISDIR; |
2751 |
++ if (d_is_dir(nd->path.dentry)) |
2752 |
++ goto out; |
2753 |
++ error = may_create_in_sticky(dir, |
2754 |
++ d_backing_inode(nd->path.dentry)); |
2755 |
++ if (unlikely(error)) |
2756 |
++ goto out; |
2757 |
++ } |
2758 |
+ error = -ENOTDIR; |
2759 |
+ if ((nd->flags & LOOKUP_DIRECTORY) && !d_can_lookup(nd->path.dentry)) |
2760 |
+ goto out; |
2761 |
+diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h |
2762 |
+index 5f5270941ba0..f7178f44825b 100644 |
2763 |
+--- a/include/linux/can/dev.h |
2764 |
++++ b/include/linux/can/dev.h |
2765 |
+@@ -154,6 +154,7 @@ void can_change_state(struct net_device *dev, struct can_frame *cf, |
2766 |
+ |
2767 |
+ void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, |
2768 |
+ unsigned int idx); |
2769 |
++struct sk_buff *__can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr); |
2770 |
+ unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx); |
2771 |
+ void can_free_echo_skb(struct net_device *dev, unsigned int idx); |
2772 |
+ |
2773 |
+diff --git a/include/linux/fs.h b/include/linux/fs.h |
2774 |
+index e9867aff53d8..bcad2b963296 100644 |
2775 |
+--- a/include/linux/fs.h |
2776 |
++++ b/include/linux/fs.h |
2777 |
+@@ -69,6 +69,8 @@ extern struct inodes_stat_t inodes_stat; |
2778 |
+ extern int leases_enable, lease_break_time; |
2779 |
+ extern int sysctl_protected_symlinks; |
2780 |
+ extern int sysctl_protected_hardlinks; |
2781 |
++extern int sysctl_protected_fifos; |
2782 |
++extern int sysctl_protected_regular; |
2783 |
+ |
2784 |
+ struct buffer_head; |
2785 |
+ typedef int (get_block_t)(struct inode *inode, sector_t iblock, |
2786 |
+diff --git a/include/linux/integrity.h b/include/linux/integrity.h |
2787 |
+index c2d6082a1a4c..858d3f4a2241 100644 |
2788 |
+--- a/include/linux/integrity.h |
2789 |
++++ b/include/linux/integrity.h |
2790 |
+@@ -14,6 +14,7 @@ |
2791 |
+ |
2792 |
+ enum integrity_status { |
2793 |
+ INTEGRITY_PASS = 0, |
2794 |
++ INTEGRITY_PASS_IMMUTABLE, |
2795 |
+ INTEGRITY_FAIL, |
2796 |
+ INTEGRITY_NOLABEL, |
2797 |
+ INTEGRITY_NOXATTRS, |
2798 |
+diff --git a/include/linux/of.h b/include/linux/of.h |
2799 |
+index 299aeb192727..a19cc85b9373 100644 |
2800 |
+--- a/include/linux/of.h |
2801 |
++++ b/include/linux/of.h |
2802 |
+@@ -275,6 +275,8 @@ extern struct device_node *of_get_next_child(const struct device_node *node, |
2803 |
+ extern struct device_node *of_get_next_available_child( |
2804 |
+ const struct device_node *node, struct device_node *prev); |
2805 |
+ |
2806 |
++extern struct device_node *of_get_compatible_child(const struct device_node *parent, |
2807 |
++ const char *compatible); |
2808 |
+ extern struct device_node *of_get_child_by_name(const struct device_node *node, |
2809 |
+ const char *name); |
2810 |
+ |
2811 |
+@@ -606,6 +608,12 @@ static inline bool of_have_populated_dt(void) |
2812 |
+ return false; |
2813 |
+ } |
2814 |
+ |
2815 |
++static inline struct device_node *of_get_compatible_child(const struct device_node *parent, |
2816 |
++ const char *compatible) |
2817 |
++{ |
2818 |
++ return NULL; |
2819 |
++} |
2820 |
++ |
2821 |
+ static inline struct device_node *of_get_child_by_name( |
2822 |
+ const struct device_node *node, |
2823 |
+ const char *name) |
2824 |
+diff --git a/include/linux/pfn_t.h b/include/linux/pfn_t.h |
2825 |
+index a3d90b9da18d..407874535fd3 100644 |
2826 |
+--- a/include/linux/pfn_t.h |
2827 |
++++ b/include/linux/pfn_t.h |
2828 |
+@@ -9,7 +9,7 @@ |
2829 |
+ * PFN_DEV - pfn is not covered by system memmap by default |
2830 |
+ * PFN_MAP - pfn has a dynamic page mapping established by a device driver |
2831 |
+ */ |
2832 |
+-#define PFN_FLAGS_MASK (((u64) ~PAGE_MASK) << (BITS_PER_LONG_LONG - PAGE_SHIFT)) |
2833 |
++#define PFN_FLAGS_MASK (((u64) (~PAGE_MASK)) << (BITS_PER_LONG_LONG - PAGE_SHIFT)) |
2834 |
+ #define PFN_SG_CHAIN (1ULL << (BITS_PER_LONG_LONG - 1)) |
2835 |
+ #define PFN_SG_LAST (1ULL << (BITS_PER_LONG_LONG - 2)) |
2836 |
+ #define PFN_DEV (1ULL << (BITS_PER_LONG_LONG - 3)) |
2837 |
+diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c |
2838 |
+index 77777d918676..cc892a9e109d 100644 |
2839 |
+--- a/kernel/debug/kdb/kdb_io.c |
2840 |
++++ b/kernel/debug/kdb/kdb_io.c |
2841 |
+@@ -215,7 +215,7 @@ static char *kdb_read(char *buffer, size_t bufsize) |
2842 |
+ int count; |
2843 |
+ int i; |
2844 |
+ int diag, dtab_count; |
2845 |
+- int key; |
2846 |
++ int key, buf_size, ret; |
2847 |
+ |
2848 |
+ |
2849 |
+ diag = kdbgetintenv("DTABCOUNT", &dtab_count); |
2850 |
+@@ -335,9 +335,8 @@ poll_again: |
2851 |
+ else |
2852 |
+ p_tmp = tmpbuffer; |
2853 |
+ len = strlen(p_tmp); |
2854 |
+- count = kallsyms_symbol_complete(p_tmp, |
2855 |
+- sizeof(tmpbuffer) - |
2856 |
+- (p_tmp - tmpbuffer)); |
2857 |
++ buf_size = sizeof(tmpbuffer) - (p_tmp - tmpbuffer); |
2858 |
++ count = kallsyms_symbol_complete(p_tmp, buf_size); |
2859 |
+ if (tab == 2 && count > 0) { |
2860 |
+ kdb_printf("\n%d symbols are found.", count); |
2861 |
+ if (count > dtab_count) { |
2862 |
+@@ -349,9 +348,13 @@ poll_again: |
2863 |
+ } |
2864 |
+ kdb_printf("\n"); |
2865 |
+ for (i = 0; i < count; i++) { |
2866 |
+- if (WARN_ON(!kallsyms_symbol_next(p_tmp, i))) |
2867 |
++ ret = kallsyms_symbol_next(p_tmp, i, buf_size); |
2868 |
++ if (WARN_ON(!ret)) |
2869 |
+ break; |
2870 |
+- kdb_printf("%s ", p_tmp); |
2871 |
++ if (ret != -E2BIG) |
2872 |
++ kdb_printf("%s ", p_tmp); |
2873 |
++ else |
2874 |
++ kdb_printf("%s... ", p_tmp); |
2875 |
+ *(p_tmp + len) = '\0'; |
2876 |
+ } |
2877 |
+ if (i >= dtab_count) |
2878 |
+diff --git a/kernel/debug/kdb/kdb_private.h b/kernel/debug/kdb/kdb_private.h |
2879 |
+index 75014d7f4568..533e04e75a9c 100644 |
2880 |
+--- a/kernel/debug/kdb/kdb_private.h |
2881 |
++++ b/kernel/debug/kdb/kdb_private.h |
2882 |
+@@ -83,7 +83,7 @@ typedef struct __ksymtab { |
2883 |
+ unsigned long sym_start; |
2884 |
+ unsigned long sym_end; |
2885 |
+ } kdb_symtab_t; |
2886 |
+-extern int kallsyms_symbol_next(char *prefix_name, int flag); |
2887 |
++extern int kallsyms_symbol_next(char *prefix_name, int flag, int buf_size); |
2888 |
+ extern int kallsyms_symbol_complete(char *prefix_name, int max_len); |
2889 |
+ |
2890 |
+ /* Exported Symbols for kernel loadable modules to use. */ |
2891 |
+diff --git a/kernel/debug/kdb/kdb_support.c b/kernel/debug/kdb/kdb_support.c |
2892 |
+index d35cc2d3a4cc..2aed4a33521b 100644 |
2893 |
+--- a/kernel/debug/kdb/kdb_support.c |
2894 |
++++ b/kernel/debug/kdb/kdb_support.c |
2895 |
+@@ -221,11 +221,13 @@ int kallsyms_symbol_complete(char *prefix_name, int max_len) |
2896 |
+ * Parameters: |
2897 |
+ * prefix_name prefix of a symbol name to lookup |
2898 |
+ * flag 0 means search from the head, 1 means continue search. |
2899 |
++ * buf_size maximum length that can be written to prefix_name |
2900 |
++ * buffer |
2901 |
+ * Returns: |
2902 |
+ * 1 if a symbol matches the given prefix. |
2903 |
+ * 0 if no string found |
2904 |
+ */ |
2905 |
+-int kallsyms_symbol_next(char *prefix_name, int flag) |
2906 |
++int kallsyms_symbol_next(char *prefix_name, int flag, int buf_size) |
2907 |
+ { |
2908 |
+ int prefix_len = strlen(prefix_name); |
2909 |
+ static loff_t pos; |
2910 |
+@@ -235,10 +237,8 @@ int kallsyms_symbol_next(char *prefix_name, int flag) |
2911 |
+ pos = 0; |
2912 |
+ |
2913 |
+ while ((name = kdb_walk_kallsyms(&pos))) { |
2914 |
+- if (strncmp(name, prefix_name, prefix_len) == 0) { |
2915 |
+- strncpy(prefix_name, name, strlen(name)+1); |
2916 |
+- return 1; |
2917 |
+- } |
2918 |
++ if (!strncmp(name, prefix_name, prefix_len)) |
2919 |
++ return strscpy(prefix_name, name, buf_size); |
2920 |
+ } |
2921 |
+ return 0; |
2922 |
+ } |
2923 |
+diff --git a/kernel/sched/core.c b/kernel/sched/core.c |
2924 |
+index 917be221438b..6b3fff6a6437 100644 |
2925 |
+--- a/kernel/sched/core.c |
2926 |
++++ b/kernel/sched/core.c |
2927 |
+@@ -4087,8 +4087,8 @@ static int __sched_setscheduler(struct task_struct *p, |
2928 |
+ int queue_flags = DEQUEUE_SAVE | DEQUEUE_MOVE; |
2929 |
+ struct rq *rq; |
2930 |
+ |
2931 |
+- /* may grab non-irq protected spin_locks */ |
2932 |
+- BUG_ON(in_interrupt()); |
2933 |
++ /* The pi code expects interrupts enabled */ |
2934 |
++ BUG_ON(pi && in_interrupt()); |
2935 |
+ recheck: |
2936 |
+ /* double check policy once rq lock held */ |
2937 |
+ if (policy < 0) { |
2938 |
+diff --git a/kernel/sysctl.c b/kernel/sysctl.c |
2939 |
+index 7df6be31be36..23f658d311c0 100644 |
2940 |
+--- a/kernel/sysctl.c |
2941 |
++++ b/kernel/sysctl.c |
2942 |
+@@ -1794,6 +1794,24 @@ static struct ctl_table fs_table[] = { |
2943 |
+ .extra1 = &zero, |
2944 |
+ .extra2 = &one, |
2945 |
+ }, |
2946 |
++ { |
2947 |
++ .procname = "protected_fifos", |
2948 |
++ .data = &sysctl_protected_fifos, |
2949 |
++ .maxlen = sizeof(int), |
2950 |
++ .mode = 0600, |
2951 |
++ .proc_handler = proc_dointvec_minmax, |
2952 |
++ .extra1 = &zero, |
2953 |
++ .extra2 = &two, |
2954 |
++ }, |
2955 |
++ { |
2956 |
++ .procname = "protected_regular", |
2957 |
++ .data = &sysctl_protected_regular, |
2958 |
++ .maxlen = sizeof(int), |
2959 |
++ .mode = 0600, |
2960 |
++ .proc_handler = proc_dointvec_minmax, |
2961 |
++ .extra1 = &zero, |
2962 |
++ .extra2 = &two, |
2963 |
++ }, |
2964 |
+ { |
2965 |
+ .procname = "suid_dumpable", |
2966 |
+ .data = &suid_dumpable, |
2967 |
+diff --git a/mm/shmem.c b/mm/shmem.c |
2968 |
+index 4b5cca167baf..358a92be43eb 100644 |
2969 |
+--- a/mm/shmem.c |
2970 |
++++ b/mm/shmem.c |
2971 |
+@@ -2414,9 +2414,7 @@ static loff_t shmem_file_llseek(struct file *file, loff_t offset, int whence) |
2972 |
+ inode_lock(inode); |
2973 |
+ /* We're holding i_mutex so we can access i_size directly */ |
2974 |
+ |
2975 |
+- if (offset < 0) |
2976 |
+- offset = -EINVAL; |
2977 |
+- else if (offset >= inode->i_size) |
2978 |
++ if (offset < 0 || offset >= inode->i_size) |
2979 |
+ offset = -ENXIO; |
2980 |
+ else { |
2981 |
+ start = offset >> PAGE_SHIFT; |
2982 |
+diff --git a/mm/slab.c b/mm/slab.c |
2983 |
+index c59844dbd034..263dcda6897b 100644 |
2984 |
+--- a/mm/slab.c |
2985 |
++++ b/mm/slab.c |
2986 |
+@@ -3690,6 +3690,8 @@ __do_kmalloc_node(size_t size, gfp_t flags, int node, unsigned long caller) |
2987 |
+ struct kmem_cache *cachep; |
2988 |
+ void *ret; |
2989 |
+ |
2990 |
++ if (unlikely(size > KMALLOC_MAX_CACHE_SIZE)) |
2991 |
++ return NULL; |
2992 |
+ cachep = kmalloc_slab(size, flags); |
2993 |
+ if (unlikely(ZERO_OR_NULL_PTR(cachep))) |
2994 |
+ return cachep; |
2995 |
+@@ -3725,6 +3727,8 @@ static __always_inline void *__do_kmalloc(size_t size, gfp_t flags, |
2996 |
+ struct kmem_cache *cachep; |
2997 |
+ void *ret; |
2998 |
+ |
2999 |
++ if (unlikely(size > KMALLOC_MAX_CACHE_SIZE)) |
3000 |
++ return NULL; |
3001 |
+ cachep = kmalloc_slab(size, flags); |
3002 |
+ if (unlikely(ZERO_OR_NULL_PTR(cachep))) |
3003 |
+ return cachep; |
3004 |
+diff --git a/mm/slab_common.c b/mm/slab_common.c |
3005 |
+index 622f6b6ae844..13f1926f8fcd 100644 |
3006 |
+--- a/mm/slab_common.c |
3007 |
++++ b/mm/slab_common.c |
3008 |
+@@ -883,18 +883,18 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags) |
3009 |
+ { |
3010 |
+ int index; |
3011 |
+ |
3012 |
+- if (unlikely(size > KMALLOC_MAX_SIZE)) { |
3013 |
+- WARN_ON_ONCE(!(flags & __GFP_NOWARN)); |
3014 |
+- return NULL; |
3015 |
+- } |
3016 |
+- |
3017 |
+ if (size <= 192) { |
3018 |
+ if (!size) |
3019 |
+ return ZERO_SIZE_PTR; |
3020 |
+ |
3021 |
+ index = size_index[size_index_elem(size)]; |
3022 |
+- } else |
3023 |
++ } else { |
3024 |
++ if (unlikely(size > KMALLOC_MAX_CACHE_SIZE)) { |
3025 |
++ WARN_ON(1); |
3026 |
++ return NULL; |
3027 |
++ } |
3028 |
+ index = fls(size - 1); |
3029 |
++ } |
3030 |
+ |
3031 |
+ #ifdef CONFIG_ZONE_DMA |
3032 |
+ if (unlikely((flags & GFP_DMA))) |
3033 |
+diff --git a/net/ieee802154/6lowpan/6lowpan_i.h b/net/ieee802154/6lowpan/6lowpan_i.h |
3034 |
+index 3bfec472734a..78916c510d9a 100644 |
3035 |
+--- a/net/ieee802154/6lowpan/6lowpan_i.h |
3036 |
++++ b/net/ieee802154/6lowpan/6lowpan_i.h |
3037 |
+@@ -19,8 +19,8 @@ typedef unsigned __bitwise__ lowpan_rx_result; |
3038 |
+ struct frag_lowpan_compare_key { |
3039 |
+ u16 tag; |
3040 |
+ u16 d_size; |
3041 |
+- const struct ieee802154_addr src; |
3042 |
+- const struct ieee802154_addr dst; |
3043 |
++ struct ieee802154_addr src; |
3044 |
++ struct ieee802154_addr dst; |
3045 |
+ }; |
3046 |
+ |
3047 |
+ /* Equivalent of ipv4 struct ipq |
3048 |
+diff --git a/net/ieee802154/6lowpan/reassembly.c b/net/ieee802154/6lowpan/reassembly.c |
3049 |
+index 6fca75581e13..aab1e2dfdfca 100644 |
3050 |
+--- a/net/ieee802154/6lowpan/reassembly.c |
3051 |
++++ b/net/ieee802154/6lowpan/reassembly.c |
3052 |
+@@ -74,14 +74,14 @@ fq_find(struct net *net, const struct lowpan_802154_cb *cb, |
3053 |
+ { |
3054 |
+ struct netns_ieee802154_lowpan *ieee802154_lowpan = |
3055 |
+ net_ieee802154_lowpan(net); |
3056 |
+- struct frag_lowpan_compare_key key = { |
3057 |
+- .tag = cb->d_tag, |
3058 |
+- .d_size = cb->d_size, |
3059 |
+- .src = *src, |
3060 |
+- .dst = *dst, |
3061 |
+- }; |
3062 |
++ struct frag_lowpan_compare_key key = {}; |
3063 |
+ struct inet_frag_queue *q; |
3064 |
+ |
3065 |
++ key.tag = cb->d_tag; |
3066 |
++ key.d_size = cb->d_size; |
3067 |
++ key.src = *src; |
3068 |
++ key.dst = *dst; |
3069 |
++ |
3070 |
+ q = inet_frag_find(&ieee802154_lowpan->frags, &key); |
3071 |
+ if (!q) |
3072 |
+ return NULL; |
3073 |
+@@ -371,7 +371,7 @@ int lowpan_frag_rcv(struct sk_buff *skb, u8 frag_type) |
3074 |
+ struct lowpan_frag_queue *fq; |
3075 |
+ struct net *net = dev_net(skb->dev); |
3076 |
+ struct lowpan_802154_cb *cb = lowpan_802154_cb(skb); |
3077 |
+- struct ieee802154_hdr hdr; |
3078 |
++ struct ieee802154_hdr hdr = {}; |
3079 |
+ int err; |
3080 |
+ |
3081 |
+ if (ieee802154_hdr_peek_addrs(skb, &hdr) < 0) |
3082 |
+diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c |
3083 |
+index 85aae8c84aeb..789e66b0187a 100644 |
3084 |
+--- a/net/llc/af_llc.c |
3085 |
++++ b/net/llc/af_llc.c |
3086 |
+@@ -726,7 +726,6 @@ static int llc_ui_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, |
3087 |
+ struct sk_buff *skb = NULL; |
3088 |
+ struct sock *sk = sock->sk; |
3089 |
+ struct llc_sock *llc = llc_sk(sk); |
3090 |
+- unsigned long cpu_flags; |
3091 |
+ size_t copied = 0; |
3092 |
+ u32 peek_seq = 0; |
3093 |
+ u32 *seq, skb_len; |
3094 |
+@@ -851,9 +850,8 @@ static int llc_ui_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, |
3095 |
+ goto copy_uaddr; |
3096 |
+ |
3097 |
+ if (!(flags & MSG_PEEK)) { |
3098 |
+- spin_lock_irqsave(&sk->sk_receive_queue.lock, cpu_flags); |
3099 |
+- sk_eat_skb(sk, skb); |
3100 |
+- spin_unlock_irqrestore(&sk->sk_receive_queue.lock, cpu_flags); |
3101 |
++ skb_unlink(skb, &sk->sk_receive_queue); |
3102 |
++ kfree_skb(skb); |
3103 |
+ *seq = 0; |
3104 |
+ } |
3105 |
+ |
3106 |
+@@ -874,9 +872,8 @@ copy_uaddr: |
3107 |
+ llc_cmsg_rcv(msg, skb); |
3108 |
+ |
3109 |
+ if (!(flags & MSG_PEEK)) { |
3110 |
+- spin_lock_irqsave(&sk->sk_receive_queue.lock, cpu_flags); |
3111 |
+- sk_eat_skb(sk, skb); |
3112 |
+- spin_unlock_irqrestore(&sk->sk_receive_queue.lock, cpu_flags); |
3113 |
++ skb_unlink(skb, &sk->sk_receive_queue); |
3114 |
++ kfree_skb(skb); |
3115 |
+ *seq = 0; |
3116 |
+ } |
3117 |
+ |
3118 |
+diff --git a/net/sctp/associola.c b/net/sctp/associola.c |
3119 |
+index 738c55e994c4..7e127cde1ccc 100644 |
3120 |
+--- a/net/sctp/associola.c |
3121 |
++++ b/net/sctp/associola.c |
3122 |
+@@ -488,8 +488,9 @@ void sctp_assoc_set_primary(struct sctp_association *asoc, |
3123 |
+ void sctp_assoc_rm_peer(struct sctp_association *asoc, |
3124 |
+ struct sctp_transport *peer) |
3125 |
+ { |
3126 |
+- struct list_head *pos; |
3127 |
+- struct sctp_transport *transport; |
3128 |
++ struct sctp_transport *transport; |
3129 |
++ struct list_head *pos; |
3130 |
++ struct sctp_chunk *ch; |
3131 |
+ |
3132 |
+ pr_debug("%s: association:%p addr:%pISpc\n", |
3133 |
+ __func__, asoc, &peer->ipaddr.sa); |
3134 |
+@@ -547,7 +548,6 @@ void sctp_assoc_rm_peer(struct sctp_association *asoc, |
3135 |
+ */ |
3136 |
+ if (!list_empty(&peer->transmitted)) { |
3137 |
+ struct sctp_transport *active = asoc->peer.active_path; |
3138 |
+- struct sctp_chunk *ch; |
3139 |
+ |
3140 |
+ /* Reset the transport of each chunk on this list */ |
3141 |
+ list_for_each_entry(ch, &peer->transmitted, |
3142 |
+@@ -569,6 +569,10 @@ void sctp_assoc_rm_peer(struct sctp_association *asoc, |
3143 |
+ sctp_transport_hold(active); |
3144 |
+ } |
3145 |
+ |
3146 |
++ list_for_each_entry(ch, &asoc->outqueue.out_chunk_list, list) |
3147 |
++ if (ch->transport == peer) |
3148 |
++ ch->transport = NULL; |
3149 |
++ |
3150 |
+ asoc->peer.transport_count--; |
3151 |
+ |
3152 |
+ sctp_transport_free(peer); |
3153 |
+diff --git a/net/sunrpc/auth_generic.c b/net/sunrpc/auth_generic.c |
3154 |
+index f1df9837f1ac..1ac08dcbf85d 100644 |
3155 |
+--- a/net/sunrpc/auth_generic.c |
3156 |
++++ b/net/sunrpc/auth_generic.c |
3157 |
+@@ -281,13 +281,7 @@ static bool generic_key_to_expire(struct rpc_cred *cred) |
3158 |
+ { |
3159 |
+ struct auth_cred *acred = &container_of(cred, struct generic_cred, |
3160 |
+ gc_base)->acred; |
3161 |
+- bool ret; |
3162 |
+- |
3163 |
+- get_rpccred(cred); |
3164 |
+- ret = test_bit(RPC_CRED_KEY_EXPIRE_SOON, &acred->ac_flags); |
3165 |
+- put_rpccred(cred); |
3166 |
+- |
3167 |
+- return ret; |
3168 |
++ return test_bit(RPC_CRED_KEY_EXPIRE_SOON, &acred->ac_flags); |
3169 |
+ } |
3170 |
+ |
3171 |
+ static const struct rpc_credops generic_credops = { |
3172 |
+diff --git a/security/integrity/evm/evm.h b/security/integrity/evm/evm.h |
3173 |
+index f5f12727771a..2ff02459fcfd 100644 |
3174 |
+--- a/security/integrity/evm/evm.h |
3175 |
++++ b/security/integrity/evm/evm.h |
3176 |
+@@ -48,7 +48,7 @@ int evm_calc_hmac(struct dentry *dentry, const char *req_xattr_name, |
3177 |
+ size_t req_xattr_value_len, char *digest); |
3178 |
+ int evm_calc_hash(struct dentry *dentry, const char *req_xattr_name, |
3179 |
+ const char *req_xattr_value, |
3180 |
+- size_t req_xattr_value_len, char *digest); |
3181 |
++ size_t req_xattr_value_len, char type, char *digest); |
3182 |
+ int evm_init_hmac(struct inode *inode, const struct xattr *xattr, |
3183 |
+ char *hmac_val); |
3184 |
+ int evm_init_secfs(void); |
3185 |
+diff --git a/security/integrity/evm/evm_crypto.c b/security/integrity/evm/evm_crypto.c |
3186 |
+index 6fcbd8e99baf..c783fefa558a 100644 |
3187 |
+--- a/security/integrity/evm/evm_crypto.c |
3188 |
++++ b/security/integrity/evm/evm_crypto.c |
3189 |
+@@ -139,7 +139,7 @@ out: |
3190 |
+ * protection.) |
3191 |
+ */ |
3192 |
+ static void hmac_add_misc(struct shash_desc *desc, struct inode *inode, |
3193 |
+- char *digest) |
3194 |
++ char type, char *digest) |
3195 |
+ { |
3196 |
+ struct h_misc { |
3197 |
+ unsigned long ino; |
3198 |
+@@ -150,13 +150,27 @@ static void hmac_add_misc(struct shash_desc *desc, struct inode *inode, |
3199 |
+ } hmac_misc; |
3200 |
+ |
3201 |
+ memset(&hmac_misc, 0, sizeof(hmac_misc)); |
3202 |
+- hmac_misc.ino = inode->i_ino; |
3203 |
+- hmac_misc.generation = inode->i_generation; |
3204 |
+- hmac_misc.uid = from_kuid(inode->i_sb->s_user_ns, inode->i_uid); |
3205 |
+- hmac_misc.gid = from_kgid(inode->i_sb->s_user_ns, inode->i_gid); |
3206 |
++ /* Don't include the inode or generation number in portable |
3207 |
++ * signatures |
3208 |
++ */ |
3209 |
++ if (type != EVM_XATTR_PORTABLE_DIGSIG) { |
3210 |
++ hmac_misc.ino = inode->i_ino; |
3211 |
++ hmac_misc.generation = inode->i_generation; |
3212 |
++ } |
3213 |
++ /* The hmac uid and gid must be encoded in the initial user |
3214 |
++ * namespace (not the filesystems user namespace) as encoding |
3215 |
++ * them in the filesystems user namespace allows an attack |
3216 |
++ * where first they are written in an unprivileged fuse mount |
3217 |
++ * of a filesystem and then the system is tricked to mount the |
3218 |
++ * filesystem for real on next boot and trust it because |
3219 |
++ * everything is signed. |
3220 |
++ */ |
3221 |
++ hmac_misc.uid = from_kuid(&init_user_ns, inode->i_uid); |
3222 |
++ hmac_misc.gid = from_kgid(&init_user_ns, inode->i_gid); |
3223 |
+ hmac_misc.mode = inode->i_mode; |
3224 |
+ crypto_shash_update(desc, (const u8 *)&hmac_misc, sizeof(hmac_misc)); |
3225 |
+- if (evm_hmac_attrs & EVM_ATTR_FSUUID) |
3226 |
++ if ((evm_hmac_attrs & EVM_ATTR_FSUUID) && |
3227 |
++ type != EVM_XATTR_PORTABLE_DIGSIG) |
3228 |
+ crypto_shash_update(desc, inode->i_sb->s_uuid, |
3229 |
+ sizeof(inode->i_sb->s_uuid)); |
3230 |
+ crypto_shash_final(desc, digest); |
3231 |
+@@ -182,6 +196,7 @@ static int evm_calc_hmac_or_hash(struct dentry *dentry, |
3232 |
+ char *xattr_value = NULL; |
3233 |
+ int error; |
3234 |
+ int size; |
3235 |
++ bool ima_present = false; |
3236 |
+ |
3237 |
+ if (!(inode->i_opflags & IOP_XATTR)) |
3238 |
+ return -EOPNOTSUPP; |
3239 |
+@@ -192,11 +207,18 @@ static int evm_calc_hmac_or_hash(struct dentry *dentry, |
3240 |
+ |
3241 |
+ error = -ENODATA; |
3242 |
+ for (xattrname = evm_config_xattrnames; *xattrname != NULL; xattrname++) { |
3243 |
++ bool is_ima = false; |
3244 |
++ |
3245 |
++ if (strcmp(*xattrname, XATTR_NAME_IMA) == 0) |
3246 |
++ is_ima = true; |
3247 |
++ |
3248 |
+ if ((req_xattr_name && req_xattr_value) |
3249 |
+ && !strcmp(*xattrname, req_xattr_name)) { |
3250 |
+ error = 0; |
3251 |
+ crypto_shash_update(desc, (const u8 *)req_xattr_value, |
3252 |
+ req_xattr_value_len); |
3253 |
++ if (is_ima) |
3254 |
++ ima_present = true; |
3255 |
+ continue; |
3256 |
+ } |
3257 |
+ size = vfs_getxattr_alloc(dentry, *xattrname, |
3258 |
+@@ -211,9 +233,14 @@ static int evm_calc_hmac_or_hash(struct dentry *dentry, |
3259 |
+ error = 0; |
3260 |
+ xattr_size = size; |
3261 |
+ crypto_shash_update(desc, (const u8 *)xattr_value, xattr_size); |
3262 |
++ if (is_ima) |
3263 |
++ ima_present = true; |
3264 |
+ } |
3265 |
+- hmac_add_misc(desc, inode, digest); |
3266 |
++ hmac_add_misc(desc, inode, type, digest); |
3267 |
+ |
3268 |
++ /* Portable EVM signatures must include an IMA hash */ |
3269 |
++ if (type == EVM_XATTR_PORTABLE_DIGSIG && !ima_present) |
3270 |
++ return -EPERM; |
3271 |
+ out: |
3272 |
+ kfree(xattr_value); |
3273 |
+ kfree(desc); |
3274 |
+@@ -225,17 +252,45 @@ int evm_calc_hmac(struct dentry *dentry, const char *req_xattr_name, |
3275 |
+ char *digest) |
3276 |
+ { |
3277 |
+ return evm_calc_hmac_or_hash(dentry, req_xattr_name, req_xattr_value, |
3278 |
+- req_xattr_value_len, EVM_XATTR_HMAC, digest); |
3279 |
++ req_xattr_value_len, EVM_XATTR_HMAC, digest); |
3280 |
+ } |
3281 |
+ |
3282 |
+ int evm_calc_hash(struct dentry *dentry, const char *req_xattr_name, |
3283 |
+ const char *req_xattr_value, size_t req_xattr_value_len, |
3284 |
+- char *digest) |
3285 |
++ char type, char *digest) |
3286 |
+ { |
3287 |
+ return evm_calc_hmac_or_hash(dentry, req_xattr_name, req_xattr_value, |
3288 |
+- req_xattr_value_len, IMA_XATTR_DIGEST, digest); |
3289 |
++ req_xattr_value_len, type, digest); |
3290 |
++} |
3291 |
++ |
3292 |
++static int evm_is_immutable(struct dentry *dentry, struct inode *inode) |
3293 |
++{ |
3294 |
++ const struct evm_ima_xattr_data *xattr_data = NULL; |
3295 |
++ struct integrity_iint_cache *iint; |
3296 |
++ int rc = 0; |
3297 |
++ |
3298 |
++ iint = integrity_iint_find(inode); |
3299 |
++ if (iint && (iint->flags & EVM_IMMUTABLE_DIGSIG)) |
3300 |
++ return 1; |
3301 |
++ |
3302 |
++ /* Do this the hard way */ |
3303 |
++ rc = vfs_getxattr_alloc(dentry, XATTR_NAME_EVM, (char **)&xattr_data, 0, |
3304 |
++ GFP_NOFS); |
3305 |
++ if (rc <= 0) { |
3306 |
++ if (rc == -ENODATA) |
3307 |
++ return 0; |
3308 |
++ return rc; |
3309 |
++ } |
3310 |
++ if (xattr_data->type == EVM_XATTR_PORTABLE_DIGSIG) |
3311 |
++ rc = 1; |
3312 |
++ else |
3313 |
++ rc = 0; |
3314 |
++ |
3315 |
++ kfree(xattr_data); |
3316 |
++ return rc; |
3317 |
+ } |
3318 |
+ |
3319 |
++ |
3320 |
+ /* |
3321 |
+ * Calculate the hmac and update security.evm xattr |
3322 |
+ * |
3323 |
+@@ -248,6 +303,16 @@ int evm_update_evmxattr(struct dentry *dentry, const char *xattr_name, |
3324 |
+ struct evm_ima_xattr_data xattr_data; |
3325 |
+ int rc = 0; |
3326 |
+ |
3327 |
++ /* |
3328 |
++ * Don't permit any transformation of the EVM xattr if the signature |
3329 |
++ * is of an immutable type |
3330 |
++ */ |
3331 |
++ rc = evm_is_immutable(dentry, inode); |
3332 |
++ if (rc < 0) |
3333 |
++ return rc; |
3334 |
++ if (rc) |
3335 |
++ return -EPERM; |
3336 |
++ |
3337 |
+ rc = evm_calc_hmac(dentry, xattr_name, xattr_value, |
3338 |
+ xattr_value_len, xattr_data.digest); |
3339 |
+ if (rc == 0) { |
3340 |
+@@ -273,7 +338,7 @@ int evm_init_hmac(struct inode *inode, const struct xattr *lsm_xattr, |
3341 |
+ } |
3342 |
+ |
3343 |
+ crypto_shash_update(desc, lsm_xattr->value, lsm_xattr->value_len); |
3344 |
+- hmac_add_misc(desc, inode, hmac_val); |
3345 |
++ hmac_add_misc(desc, inode, EVM_XATTR_HMAC, hmac_val); |
3346 |
+ kfree(desc); |
3347 |
+ return 0; |
3348 |
+ } |
3349 |
+diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c |
3350 |
+index ba8615576d4d..976b8dce6496 100644 |
3351 |
+--- a/security/integrity/evm/evm_main.c |
3352 |
++++ b/security/integrity/evm/evm_main.c |
3353 |
+@@ -29,7 +29,7 @@ |
3354 |
+ int evm_initialized; |
3355 |
+ |
3356 |
+ static char *integrity_status_msg[] = { |
3357 |
+- "pass", "fail", "no_label", "no_xattrs", "unknown" |
3358 |
++ "pass", "pass_immutable", "fail", "no_label", "no_xattrs", "unknown" |
3359 |
+ }; |
3360 |
+ char *evm_hmac = "hmac(sha1)"; |
3361 |
+ char *evm_hash = "sha1"; |
3362 |
+@@ -118,7 +118,8 @@ static enum integrity_status evm_verify_hmac(struct dentry *dentry, |
3363 |
+ enum integrity_status evm_status = INTEGRITY_PASS; |
3364 |
+ int rc, xattr_len; |
3365 |
+ |
3366 |
+- if (iint && iint->evm_status == INTEGRITY_PASS) |
3367 |
++ if (iint && (iint->evm_status == INTEGRITY_PASS || |
3368 |
++ iint->evm_status == INTEGRITY_PASS_IMMUTABLE)) |
3369 |
+ return iint->evm_status; |
3370 |
+ |
3371 |
+ /* if status is not PASS, try to check again - against -ENOMEM */ |
3372 |
+@@ -155,22 +156,26 @@ static enum integrity_status evm_verify_hmac(struct dentry *dentry, |
3373 |
+ rc = -EINVAL; |
3374 |
+ break; |
3375 |
+ case EVM_IMA_XATTR_DIGSIG: |
3376 |
++ case EVM_XATTR_PORTABLE_DIGSIG: |
3377 |
+ rc = evm_calc_hash(dentry, xattr_name, xattr_value, |
3378 |
+- xattr_value_len, calc.digest); |
3379 |
++ xattr_value_len, xattr_data->type, |
3380 |
++ calc.digest); |
3381 |
+ if (rc) |
3382 |
+ break; |
3383 |
+ rc = integrity_digsig_verify(INTEGRITY_KEYRING_EVM, |
3384 |
+ (const char *)xattr_data, xattr_len, |
3385 |
+ calc.digest, sizeof(calc.digest)); |
3386 |
+ if (!rc) { |
3387 |
+- /* Replace RSA with HMAC if not mounted readonly and |
3388 |
+- * not immutable |
3389 |
+- */ |
3390 |
+- if (!IS_RDONLY(d_backing_inode(dentry)) && |
3391 |
+- !IS_IMMUTABLE(d_backing_inode(dentry))) |
3392 |
++ if (xattr_data->type == EVM_XATTR_PORTABLE_DIGSIG) { |
3393 |
++ if (iint) |
3394 |
++ iint->flags |= EVM_IMMUTABLE_DIGSIG; |
3395 |
++ evm_status = INTEGRITY_PASS_IMMUTABLE; |
3396 |
++ } else if (!IS_RDONLY(d_backing_inode(dentry)) && |
3397 |
++ !IS_IMMUTABLE(d_backing_inode(dentry))) { |
3398 |
+ evm_update_evmxattr(dentry, xattr_name, |
3399 |
+ xattr_value, |
3400 |
+ xattr_value_len); |
3401 |
++ } |
3402 |
+ } |
3403 |
+ break; |
3404 |
+ default: |
3405 |
+@@ -271,7 +276,7 @@ static enum integrity_status evm_verify_current_integrity(struct dentry *dentry) |
3406 |
+ * affect security.evm. An interesting side affect of writing posix xattr |
3407 |
+ * acls is their modifying of the i_mode, which is included in security.evm. |
3408 |
+ * For posix xattr acls only, permit security.evm, even if it currently |
3409 |
+- * doesn't exist, to be updated. |
3410 |
++ * doesn't exist, to be updated unless the EVM signature is immutable. |
3411 |
+ */ |
3412 |
+ static int evm_protect_xattr(struct dentry *dentry, const char *xattr_name, |
3413 |
+ const void *xattr_value, size_t xattr_value_len) |
3414 |
+@@ -339,7 +344,8 @@ int evm_inode_setxattr(struct dentry *dentry, const char *xattr_name, |
3415 |
+ if (strcmp(xattr_name, XATTR_NAME_EVM) == 0) { |
3416 |
+ if (!xattr_value_len) |
3417 |
+ return -EINVAL; |
3418 |
+- if (xattr_data->type != EVM_IMA_XATTR_DIGSIG) |
3419 |
++ if (xattr_data->type != EVM_IMA_XATTR_DIGSIG && |
3420 |
++ xattr_data->type != EVM_XATTR_PORTABLE_DIGSIG) |
3421 |
+ return -EPERM; |
3422 |
+ } |
3423 |
+ return evm_protect_xattr(dentry, xattr_name, xattr_value, |
3424 |
+@@ -416,6 +422,9 @@ void evm_inode_post_removexattr(struct dentry *dentry, const char *xattr_name) |
3425 |
+ /** |
3426 |
+ * evm_inode_setattr - prevent updating an invalid EVM extended attribute |
3427 |
+ * @dentry: pointer to the affected dentry |
3428 |
++ * |
3429 |
++ * Permit update of file attributes when files have a valid EVM signature, |
3430 |
++ * except in the case of them having an immutable portable signature. |
3431 |
+ */ |
3432 |
+ int evm_inode_setattr(struct dentry *dentry, struct iattr *attr) |
3433 |
+ { |
3434 |
+diff --git a/security/integrity/iint.c b/security/integrity/iint.c |
3435 |
+index c710d22042f9..7ea39b19e8ad 100644 |
3436 |
+--- a/security/integrity/iint.c |
3437 |
++++ b/security/integrity/iint.c |
3438 |
+@@ -74,6 +74,7 @@ static void iint_free(struct integrity_iint_cache *iint) |
3439 |
+ iint->ima_hash = NULL; |
3440 |
+ iint->version = 0; |
3441 |
+ iint->flags = 0UL; |
3442 |
++ iint->atomic_flags = 0UL; |
3443 |
+ iint->ima_file_status = INTEGRITY_UNKNOWN; |
3444 |
+ iint->ima_mmap_status = INTEGRITY_UNKNOWN; |
3445 |
+ iint->ima_bprm_status = INTEGRITY_UNKNOWN; |
3446 |
+@@ -155,12 +156,14 @@ static void init_once(void *foo) |
3447 |
+ memset(iint, 0, sizeof(*iint)); |
3448 |
+ iint->version = 0; |
3449 |
+ iint->flags = 0UL; |
3450 |
++ iint->atomic_flags = 0; |
3451 |
+ iint->ima_file_status = INTEGRITY_UNKNOWN; |
3452 |
+ iint->ima_mmap_status = INTEGRITY_UNKNOWN; |
3453 |
+ iint->ima_bprm_status = INTEGRITY_UNKNOWN; |
3454 |
+ iint->ima_read_status = INTEGRITY_UNKNOWN; |
3455 |
+ iint->evm_status = INTEGRITY_UNKNOWN; |
3456 |
+ iint->measured_pcrs = 0; |
3457 |
++ mutex_init(&iint->mutex); |
3458 |
+ } |
3459 |
+ |
3460 |
+ static int __init integrity_iintcache_init(void) |
3461 |
+diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c |
3462 |
+index d01a52f8f708..3b43057bf949 100644 |
3463 |
+--- a/security/integrity/ima/ima_api.c |
3464 |
++++ b/security/integrity/ima/ima_api.c |
3465 |
+@@ -198,42 +198,59 @@ int ima_collect_measurement(struct integrity_iint_cache *iint, |
3466 |
+ struct inode *inode = file_inode(file); |
3467 |
+ const char *filename = file->f_path.dentry->d_name.name; |
3468 |
+ int result = 0; |
3469 |
++ int length; |
3470 |
++ void *tmpbuf; |
3471 |
++ u64 i_version; |
3472 |
+ struct { |
3473 |
+ struct ima_digest_data hdr; |
3474 |
+ char digest[IMA_MAX_DIGEST_SIZE]; |
3475 |
+ } hash; |
3476 |
+ |
3477 |
+- if (!(iint->flags & IMA_COLLECTED)) { |
3478 |
+- u64 i_version = file_inode(file)->i_version; |
3479 |
++ if (iint->flags & IMA_COLLECTED) |
3480 |
++ goto out; |
3481 |
+ |
3482 |
+- if (file->f_flags & O_DIRECT) { |
3483 |
+- audit_cause = "failed(directio)"; |
3484 |
+- result = -EACCES; |
3485 |
+- goto out; |
3486 |
+- } |
3487 |
++ /* |
3488 |
++ * Dectecting file change is based on i_version. On filesystems |
3489 |
++ * which do not support i_version, support is limited to an initial |
3490 |
++ * measurement/appraisal/audit. |
3491 |
++ */ |
3492 |
++ i_version = file_inode(file)->i_version; |
3493 |
++ hash.hdr.algo = algo; |
3494 |
+ |
3495 |
+- hash.hdr.algo = algo; |
3496 |
+- |
3497 |
+- result = (!buf) ? ima_calc_file_hash(file, &hash.hdr) : |
3498 |
+- ima_calc_buffer_hash(buf, size, &hash.hdr); |
3499 |
+- if (!result) { |
3500 |
+- int length = sizeof(hash.hdr) + hash.hdr.length; |
3501 |
+- void *tmpbuf = krealloc(iint->ima_hash, length, |
3502 |
+- GFP_NOFS); |
3503 |
+- if (tmpbuf) { |
3504 |
+- iint->ima_hash = tmpbuf; |
3505 |
+- memcpy(iint->ima_hash, &hash, length); |
3506 |
+- iint->version = i_version; |
3507 |
+- iint->flags |= IMA_COLLECTED; |
3508 |
+- } else |
3509 |
+- result = -ENOMEM; |
3510 |
+- } |
3511 |
++ /* Initialize hash digest to 0's in case of failure */ |
3512 |
++ memset(&hash.digest, 0, sizeof(hash.digest)); |
3513 |
++ |
3514 |
++ if (buf) |
3515 |
++ result = ima_calc_buffer_hash(buf, size, &hash.hdr); |
3516 |
++ else |
3517 |
++ result = ima_calc_file_hash(file, &hash.hdr); |
3518 |
++ |
3519 |
++ if (result && result != -EBADF && result != -EINVAL) |
3520 |
++ goto out; |
3521 |
++ |
3522 |
++ length = sizeof(hash.hdr) + hash.hdr.length; |
3523 |
++ tmpbuf = krealloc(iint->ima_hash, length, GFP_NOFS); |
3524 |
++ if (!tmpbuf) { |
3525 |
++ result = -ENOMEM; |
3526 |
++ goto out; |
3527 |
+ } |
3528 |
++ |
3529 |
++ iint->ima_hash = tmpbuf; |
3530 |
++ memcpy(iint->ima_hash, &hash, length); |
3531 |
++ iint->version = i_version; |
3532 |
++ |
3533 |
++ /* Possibly temporary failure due to type of read (eg. O_DIRECT) */ |
3534 |
++ if (!result) |
3535 |
++ iint->flags |= IMA_COLLECTED; |
3536 |
+ out: |
3537 |
+- if (result) |
3538 |
++ if (result) { |
3539 |
++ if (file->f_flags & O_DIRECT) |
3540 |
++ audit_cause = "failed(directio)"; |
3541 |
++ |
3542 |
+ integrity_audit_msg(AUDIT_INTEGRITY_DATA, inode, |
3543 |
+ filename, "collect_data", audit_cause, |
3544 |
+ result, 0); |
3545 |
++ } |
3546 |
+ return result; |
3547 |
+ } |
3548 |
+ |
3549 |
+@@ -277,7 +294,7 @@ void ima_store_measurement(struct integrity_iint_cache *iint, |
3550 |
+ } |
3551 |
+ |
3552 |
+ result = ima_store_template(entry, violation, inode, filename, pcr); |
3553 |
+- if (!result || result == -EEXIST) { |
3554 |
++ if ((!result || result == -EEXIST) && !(file->f_flags & O_DIRECT)) { |
3555 |
+ iint->flags |= IMA_MEASURED; |
3556 |
+ iint->measured_pcrs |= (0x1 << pcr); |
3557 |
+ } |
3558 |
+diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c |
3559 |
+index 1e6f23f77f15..af55c31754a4 100644 |
3560 |
+--- a/security/integrity/ima/ima_appraise.c |
3561 |
++++ b/security/integrity/ima/ima_appraise.c |
3562 |
+@@ -214,7 +214,9 @@ int ima_appraise_measurement(enum ima_hooks func, |
3563 |
+ } |
3564 |
+ |
3565 |
+ status = evm_verifyxattr(dentry, XATTR_NAME_IMA, xattr_value, rc, iint); |
3566 |
+- if ((status != INTEGRITY_PASS) && (status != INTEGRITY_UNKNOWN)) { |
3567 |
++ if ((status != INTEGRITY_PASS) && |
3568 |
++ (status != INTEGRITY_PASS_IMMUTABLE) && |
3569 |
++ (status != INTEGRITY_UNKNOWN)) { |
3570 |
+ if ((status == INTEGRITY_NOLABEL) |
3571 |
+ || (status == INTEGRITY_NOXATTRS)) |
3572 |
+ cause = "missing-HMAC"; |
3573 |
+@@ -232,6 +234,7 @@ int ima_appraise_measurement(enum ima_hooks func, |
3574 |
+ status = INTEGRITY_FAIL; |
3575 |
+ break; |
3576 |
+ } |
3577 |
++ clear_bit(IMA_DIGSIG, &iint->atomic_flags); |
3578 |
+ if (xattr_len - sizeof(xattr_value->type) - hash_start >= |
3579 |
+ iint->ima_hash->length) |
3580 |
+ /* xattr length may be longer. md5 hash in previous |
3581 |
+@@ -250,7 +253,7 @@ int ima_appraise_measurement(enum ima_hooks func, |
3582 |
+ status = INTEGRITY_PASS; |
3583 |
+ break; |
3584 |
+ case EVM_IMA_XATTR_DIGSIG: |
3585 |
+- iint->flags |= IMA_DIGSIG; |
3586 |
++ set_bit(IMA_DIGSIG, &iint->atomic_flags); |
3587 |
+ rc = integrity_digsig_verify(INTEGRITY_KEYRING_IMA, |
3588 |
+ (const char *)xattr_value, rc, |
3589 |
+ iint->ima_hash->digest, |
3590 |
+@@ -301,7 +304,7 @@ void ima_update_xattr(struct integrity_iint_cache *iint, struct file *file) |
3591 |
+ int rc = 0; |
3592 |
+ |
3593 |
+ /* do not collect and update hash for digital signatures */ |
3594 |
+- if (iint->flags & IMA_DIGSIG) |
3595 |
++ if (test_bit(IMA_DIGSIG, &iint->atomic_flags)) |
3596 |
+ return; |
3597 |
+ |
3598 |
+ if (iint->ima_file_status != INTEGRITY_PASS) |
3599 |
+@@ -311,7 +314,9 @@ void ima_update_xattr(struct integrity_iint_cache *iint, struct file *file) |
3600 |
+ if (rc < 0) |
3601 |
+ return; |
3602 |
+ |
3603 |
++ inode_lock(file_inode(file)); |
3604 |
+ ima_fix_xattr(dentry, iint); |
3605 |
++ inode_unlock(file_inode(file)); |
3606 |
+ } |
3607 |
+ |
3608 |
+ /** |
3609 |
+@@ -334,16 +339,14 @@ void ima_inode_post_setattr(struct dentry *dentry) |
3610 |
+ return; |
3611 |
+ |
3612 |
+ must_appraise = ima_must_appraise(inode, MAY_ACCESS, POST_SETATTR); |
3613 |
++ if (!must_appraise) |
3614 |
++ __vfs_removexattr(dentry, XATTR_NAME_IMA); |
3615 |
+ iint = integrity_iint_find(inode); |
3616 |
+ if (iint) { |
3617 |
+- iint->flags &= ~(IMA_APPRAISE | IMA_APPRAISED | |
3618 |
+- IMA_APPRAISE_SUBMASK | IMA_APPRAISED_SUBMASK | |
3619 |
+- IMA_ACTION_RULE_FLAGS); |
3620 |
+- if (must_appraise) |
3621 |
+- iint->flags |= IMA_APPRAISE; |
3622 |
++ set_bit(IMA_CHANGE_ATTR, &iint->atomic_flags); |
3623 |
++ if (!must_appraise) |
3624 |
++ clear_bit(IMA_UPDATE_XATTR, &iint->atomic_flags); |
3625 |
+ } |
3626 |
+- if (!must_appraise) |
3627 |
+- __vfs_removexattr(dentry, XATTR_NAME_IMA); |
3628 |
+ } |
3629 |
+ |
3630 |
+ /* |
3631 |
+@@ -372,12 +375,12 @@ static void ima_reset_appraise_flags(struct inode *inode, int digsig) |
3632 |
+ iint = integrity_iint_find(inode); |
3633 |
+ if (!iint) |
3634 |
+ return; |
3635 |
+- |
3636 |
+- iint->flags &= ~IMA_DONE_MASK; |
3637 |
+ iint->measured_pcrs = 0; |
3638 |
++ set_bit(IMA_CHANGE_XATTR, &iint->atomic_flags); |
3639 |
+ if (digsig) |
3640 |
+- iint->flags |= IMA_DIGSIG; |
3641 |
+- return; |
3642 |
++ set_bit(IMA_DIGSIG, &iint->atomic_flags); |
3643 |
++ else |
3644 |
++ clear_bit(IMA_DIGSIG, &iint->atomic_flags); |
3645 |
+ } |
3646 |
+ |
3647 |
+ int ima_inode_setxattr(struct dentry *dentry, const char *xattr_name, |
3648 |
+diff --git a/security/integrity/ima/ima_crypto.c b/security/integrity/ima/ima_crypto.c |
3649 |
+index 93f09173cc49..20e66291ca99 100644 |
3650 |
+--- a/security/integrity/ima/ima_crypto.c |
3651 |
++++ b/security/integrity/ima/ima_crypto.c |
3652 |
+@@ -443,6 +443,16 @@ int ima_calc_file_hash(struct file *file, struct ima_digest_data *hash) |
3653 |
+ loff_t i_size; |
3654 |
+ int rc; |
3655 |
+ |
3656 |
++ /* |
3657 |
++ * For consistency, fail file's opened with the O_DIRECT flag on |
3658 |
++ * filesystems mounted with/without DAX option. |
3659 |
++ */ |
3660 |
++ if (file->f_flags & O_DIRECT) { |
3661 |
++ hash->length = hash_digest_size[ima_hash_algo]; |
3662 |
++ hash->algo = ima_hash_algo; |
3663 |
++ return -EINVAL; |
3664 |
++ } |
3665 |
++ |
3666 |
+ i_size = i_size_read(file_inode(file)); |
3667 |
+ |
3668 |
+ if (ima_ahash_minsize && i_size >= ima_ahash_minsize) { |
3669 |
+diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c |
3670 |
+index 9652541c4d43..ea1e629a5d4c 100644 |
3671 |
+--- a/security/integrity/ima/ima_main.c |
3672 |
++++ b/security/integrity/ima/ima_main.c |
3673 |
+@@ -99,10 +99,13 @@ static void ima_rdwr_violation_check(struct file *file, |
3674 |
+ if (!iint) |
3675 |
+ iint = integrity_iint_find(inode); |
3676 |
+ /* IMA_MEASURE is set from reader side */ |
3677 |
+- if (iint && (iint->flags & IMA_MEASURE)) |
3678 |
++ if (iint && test_bit(IMA_MUST_MEASURE, |
3679 |
++ &iint->atomic_flags)) |
3680 |
+ send_tomtou = true; |
3681 |
+ } |
3682 |
+ } else { |
3683 |
++ if (must_measure) |
3684 |
++ set_bit(IMA_MUST_MEASURE, &iint->atomic_flags); |
3685 |
+ if ((atomic_read(&inode->i_writecount) > 0) && must_measure) |
3686 |
+ send_writers = true; |
3687 |
+ } |
3688 |
+@@ -124,21 +127,24 @@ static void ima_check_last_writer(struct integrity_iint_cache *iint, |
3689 |
+ struct inode *inode, struct file *file) |
3690 |
+ { |
3691 |
+ fmode_t mode = file->f_mode; |
3692 |
++ bool update; |
3693 |
+ |
3694 |
+ if (!(mode & FMODE_WRITE)) |
3695 |
+ return; |
3696 |
+ |
3697 |
+- inode_lock(inode); |
3698 |
++ mutex_lock(&iint->mutex); |
3699 |
+ if (atomic_read(&inode->i_writecount) == 1) { |
3700 |
++ update = test_and_clear_bit(IMA_UPDATE_XATTR, |
3701 |
++ &iint->atomic_flags); |
3702 |
+ if ((iint->version != inode->i_version) || |
3703 |
+ (iint->flags & IMA_NEW_FILE)) { |
3704 |
+ iint->flags &= ~(IMA_DONE_MASK | IMA_NEW_FILE); |
3705 |
+ iint->measured_pcrs = 0; |
3706 |
+- if (iint->flags & IMA_APPRAISE) |
3707 |
++ if (update) |
3708 |
+ ima_update_xattr(iint, file); |
3709 |
+ } |
3710 |
+ } |
3711 |
+- inode_unlock(inode); |
3712 |
++ mutex_unlock(&iint->mutex); |
3713 |
+ } |
3714 |
+ |
3715 |
+ /** |
3716 |
+@@ -171,7 +177,7 @@ static int process_measurement(struct file *file, char *buf, loff_t size, |
3717 |
+ char *pathbuf = NULL; |
3718 |
+ char filename[NAME_MAX]; |
3719 |
+ const char *pathname = NULL; |
3720 |
+- int rc = -ENOMEM, action, must_appraise; |
3721 |
++ int rc = 0, action, must_appraise = 0; |
3722 |
+ int pcr = CONFIG_IMA_MEASURE_PCR_IDX; |
3723 |
+ struct evm_ima_xattr_data *xattr_value = NULL; |
3724 |
+ int xattr_len = 0; |
3725 |
+@@ -202,17 +208,31 @@ static int process_measurement(struct file *file, char *buf, loff_t size, |
3726 |
+ if (action) { |
3727 |
+ iint = integrity_inode_get(inode); |
3728 |
+ if (!iint) |
3729 |
+- goto out; |
3730 |
++ rc = -ENOMEM; |
3731 |
+ } |
3732 |
+ |
3733 |
+- if (violation_check) { |
3734 |
++ if (!rc && violation_check) |
3735 |
+ ima_rdwr_violation_check(file, iint, action & IMA_MEASURE, |
3736 |
+ &pathbuf, &pathname); |
3737 |
+- if (!action) { |
3738 |
+- rc = 0; |
3739 |
+- goto out_free; |
3740 |
+- } |
3741 |
+- } |
3742 |
++ |
3743 |
++ inode_unlock(inode); |
3744 |
++ |
3745 |
++ if (rc) |
3746 |
++ goto out; |
3747 |
++ if (!action) |
3748 |
++ goto out; |
3749 |
++ |
3750 |
++ mutex_lock(&iint->mutex); |
3751 |
++ |
3752 |
++ if (test_and_clear_bit(IMA_CHANGE_ATTR, &iint->atomic_flags)) |
3753 |
++ /* reset appraisal flags if ima_inode_post_setattr was called */ |
3754 |
++ iint->flags &= ~(IMA_APPRAISE | IMA_APPRAISED | |
3755 |
++ IMA_APPRAISE_SUBMASK | IMA_APPRAISED_SUBMASK | |
3756 |
++ IMA_ACTION_FLAGS); |
3757 |
++ |
3758 |
++ if (test_and_clear_bit(IMA_CHANGE_XATTR, &iint->atomic_flags)) |
3759 |
++ /* reset all flags if ima_inode_setxattr was called */ |
3760 |
++ iint->flags &= ~IMA_DONE_MASK; |
3761 |
+ |
3762 |
+ /* Determine if already appraised/measured based on bitmask |
3763 |
+ * (IMA_MEASURE, IMA_MEASURED, IMA_XXXX_APPRAISE, IMA_XXXX_APPRAISED, |
3764 |
+@@ -230,7 +250,7 @@ static int process_measurement(struct file *file, char *buf, loff_t size, |
3765 |
+ if (!action) { |
3766 |
+ if (must_appraise) |
3767 |
+ rc = ima_get_cache_status(iint, func); |
3768 |
+- goto out_digsig; |
3769 |
++ goto out_locked; |
3770 |
+ } |
3771 |
+ |
3772 |
+ template_desc = ima_template_desc_current(); |
3773 |
+@@ -242,11 +262,8 @@ static int process_measurement(struct file *file, char *buf, loff_t size, |
3774 |
+ hash_algo = ima_get_hash_algo(xattr_value, xattr_len); |
3775 |
+ |
3776 |
+ rc = ima_collect_measurement(iint, file, buf, size, hash_algo); |
3777 |
+- if (rc != 0) { |
3778 |
+- if (file->f_flags & O_DIRECT) |
3779 |
+- rc = (iint->flags & IMA_PERMIT_DIRECTIO) ? 0 : -EACCES; |
3780 |
+- goto out_digsig; |
3781 |
+- } |
3782 |
++ if (rc != 0 && rc != -EBADF && rc != -EINVAL) |
3783 |
++ goto out_locked; |
3784 |
+ |
3785 |
+ if (!pathbuf) /* ima_rdwr_violation possibly pre-fetched */ |
3786 |
+ pathname = ima_d_path(&file->f_path, &pathbuf, filename); |
3787 |
+@@ -254,24 +271,32 @@ static int process_measurement(struct file *file, char *buf, loff_t size, |
3788 |
+ if (action & IMA_MEASURE) |
3789 |
+ ima_store_measurement(iint, file, pathname, |
3790 |
+ xattr_value, xattr_len, pcr); |
3791 |
+- if (action & IMA_APPRAISE_SUBMASK) |
3792 |
++ if (rc == 0 && (action & IMA_APPRAISE_SUBMASK)) { |
3793 |
++ inode_lock(inode); |
3794 |
+ rc = ima_appraise_measurement(func, iint, file, pathname, |
3795 |
+ xattr_value, xattr_len, opened); |
3796 |
++ inode_unlock(inode); |
3797 |
++ } |
3798 |
+ if (action & IMA_AUDIT) |
3799 |
+ ima_audit_measurement(iint, pathname); |
3800 |
+ |
3801 |
+-out_digsig: |
3802 |
+- if ((mask & MAY_WRITE) && (iint->flags & IMA_DIGSIG) && |
3803 |
++ if ((file->f_flags & O_DIRECT) && (iint->flags & IMA_PERMIT_DIRECTIO)) |
3804 |
++ rc = 0; |
3805 |
++out_locked: |
3806 |
++ if ((mask & MAY_WRITE) && test_bit(IMA_DIGSIG, &iint->atomic_flags) && |
3807 |
+ !(iint->flags & IMA_NEW_FILE)) |
3808 |
+ rc = -EACCES; |
3809 |
++ mutex_unlock(&iint->mutex); |
3810 |
+ kfree(xattr_value); |
3811 |
+-out_free: |
3812 |
++out: |
3813 |
+ if (pathbuf) |
3814 |
+ __putname(pathbuf); |
3815 |
+-out: |
3816 |
+- inode_unlock(inode); |
3817 |
+- if ((rc && must_appraise) && (ima_appraise & IMA_APPRAISE_ENFORCE)) |
3818 |
+- return -EACCES; |
3819 |
++ if (must_appraise) { |
3820 |
++ if (rc && (ima_appraise & IMA_APPRAISE_ENFORCE)) |
3821 |
++ return -EACCES; |
3822 |
++ if (file->f_mode & FMODE_WRITE) |
3823 |
++ set_bit(IMA_UPDATE_XATTR, &iint->atomic_flags); |
3824 |
++ } |
3825 |
+ return 0; |
3826 |
+ } |
3827 |
+ |
3828 |
+diff --git a/security/integrity/integrity.h b/security/integrity/integrity.h |
3829 |
+index 24520b4ef3b0..2f7e236b931c 100644 |
3830 |
+--- a/security/integrity/integrity.h |
3831 |
++++ b/security/integrity/integrity.h |
3832 |
+@@ -29,10 +29,10 @@ |
3833 |
+ /* iint cache flags */ |
3834 |
+ #define IMA_ACTION_FLAGS 0xff000000 |
3835 |
+ #define IMA_ACTION_RULE_FLAGS 0x06000000 |
3836 |
+-#define IMA_DIGSIG 0x01000000 |
3837 |
+-#define IMA_DIGSIG_REQUIRED 0x02000000 |
3838 |
+-#define IMA_PERMIT_DIRECTIO 0x04000000 |
3839 |
+-#define IMA_NEW_FILE 0x08000000 |
3840 |
++#define IMA_DIGSIG_REQUIRED 0x01000000 |
3841 |
++#define IMA_PERMIT_DIRECTIO 0x02000000 |
3842 |
++#define IMA_NEW_FILE 0x04000000 |
3843 |
++#define EVM_IMMUTABLE_DIGSIG 0x08000000 |
3844 |
+ |
3845 |
+ #define IMA_DO_MASK (IMA_MEASURE | IMA_APPRAISE | IMA_AUDIT | \ |
3846 |
+ IMA_APPRAISE_SUBMASK) |
3847 |
+@@ -53,11 +53,19 @@ |
3848 |
+ #define IMA_APPRAISED_SUBMASK (IMA_FILE_APPRAISED | IMA_MMAP_APPRAISED | \ |
3849 |
+ IMA_BPRM_APPRAISED | IMA_READ_APPRAISED) |
3850 |
+ |
3851 |
++/* iint cache atomic_flags */ |
3852 |
++#define IMA_CHANGE_XATTR 0 |
3853 |
++#define IMA_UPDATE_XATTR 1 |
3854 |
++#define IMA_CHANGE_ATTR 2 |
3855 |
++#define IMA_DIGSIG 3 |
3856 |
++#define IMA_MUST_MEASURE 4 |
3857 |
++ |
3858 |
+ enum evm_ima_xattr_type { |
3859 |
+ IMA_XATTR_DIGEST = 0x01, |
3860 |
+ EVM_XATTR_HMAC, |
3861 |
+ EVM_IMA_XATTR_DIGSIG, |
3862 |
+ IMA_XATTR_DIGEST_NG, |
3863 |
++ EVM_XATTR_PORTABLE_DIGSIG, |
3864 |
+ IMA_XATTR_LAST |
3865 |
+ }; |
3866 |
+ |
3867 |
+@@ -100,10 +108,12 @@ struct signature_v2_hdr { |
3868 |
+ /* integrity data associated with an inode */ |
3869 |
+ struct integrity_iint_cache { |
3870 |
+ struct rb_node rb_node; /* rooted in integrity_iint_tree */ |
3871 |
++ struct mutex mutex; /* protects: version, flags, digest */ |
3872 |
+ struct inode *inode; /* back pointer to inode in question */ |
3873 |
+ u64 version; /* track inode changes */ |
3874 |
+ unsigned long flags; |
3875 |
+ unsigned long measured_pcrs; |
3876 |
++ unsigned long atomic_flags; |
3877 |
+ enum integrity_status ima_file_status:4; |
3878 |
+ enum integrity_status ima_mmap_status:4; |
3879 |
+ enum integrity_status ima_bprm_status:4; |
3880 |
+diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c |
3881 |
+index d719db4219cd..175e4dce58df 100644 |
3882 |
+--- a/security/selinux/ss/policydb.c |
3883 |
++++ b/security/selinux/ss/policydb.c |
3884 |
+@@ -1097,7 +1097,7 @@ static int str_read(char **strp, gfp_t flags, void *fp, u32 len) |
3885 |
+ if ((len == 0) || (len == (u32)-1)) |
3886 |
+ return -EINVAL; |
3887 |
+ |
3888 |
+- str = kmalloc(len + 1, flags); |
3889 |
++ str = kmalloc(len + 1, flags | __GFP_NOWARN); |
3890 |
+ if (!str) |
3891 |
+ return -ENOMEM; |
3892 |
+ |
3893 |
+diff --git a/tools/power/cpupower/bench/Makefile b/tools/power/cpupower/bench/Makefile |
3894 |
+index 3e59f1aa3947..8a285bca8e6c 100644 |
3895 |
+--- a/tools/power/cpupower/bench/Makefile |
3896 |
++++ b/tools/power/cpupower/bench/Makefile |
3897 |
+@@ -8,7 +8,7 @@ endif |
3898 |
+ ifeq ($(strip $(STATIC)),true) |
3899 |
+ LIBS = -L../ -L$(OUTPUT) -lm |
3900 |
+ OBJS = $(OUTPUT)main.o $(OUTPUT)parse.o $(OUTPUT)system.o $(OUTPUT)benchmark.o \ |
3901 |
+- $(OUTPUT)../lib/cpufreq.o $(OUTPUT)../lib/sysfs.o |
3902 |
++ $(OUTPUT)../lib/cpufreq.o $(OUTPUT)../lib/cpupower.o |
3903 |
+ else |
3904 |
+ LIBS = -L../ -L$(OUTPUT) -lm -lcpupower |
3905 |
+ OBJS = $(OUTPUT)main.o $(OUTPUT)parse.o $(OUTPUT)system.o $(OUTPUT)benchmark.o |
3906 |
+diff --git a/tools/power/cpupower/lib/cpufreq.c b/tools/power/cpupower/lib/cpufreq.c |
3907 |
+index 1b993fe1ce23..0c0f3e3f0d80 100644 |
3908 |
+--- a/tools/power/cpupower/lib/cpufreq.c |
3909 |
++++ b/tools/power/cpupower/lib/cpufreq.c |
3910 |
+@@ -28,7 +28,7 @@ static unsigned int sysfs_cpufreq_read_file(unsigned int cpu, const char *fname, |
3911 |
+ |
3912 |
+ snprintf(path, sizeof(path), PATH_TO_CPU "cpu%u/cpufreq/%s", |
3913 |
+ cpu, fname); |
3914 |
+- return sysfs_read_file(path, buf, buflen); |
3915 |
++ return cpupower_read_sysfs(path, buf, buflen); |
3916 |
+ } |
3917 |
+ |
3918 |
+ /* helper function to write a new value to a /sys file */ |
3919 |
+diff --git a/tools/power/cpupower/lib/cpuidle.c b/tools/power/cpupower/lib/cpuidle.c |
3920 |
+index 9bd4c7655fdb..852d25462388 100644 |
3921 |
+--- a/tools/power/cpupower/lib/cpuidle.c |
3922 |
++++ b/tools/power/cpupower/lib/cpuidle.c |
3923 |
+@@ -319,7 +319,7 @@ static unsigned int sysfs_cpuidle_read_file(const char *fname, char *buf, |
3924 |
+ |
3925 |
+ snprintf(path, sizeof(path), PATH_TO_CPU "cpuidle/%s", fname); |
3926 |
+ |
3927 |
+- return sysfs_read_file(path, buf, buflen); |
3928 |
++ return cpupower_read_sysfs(path, buf, buflen); |
3929 |
+ } |
3930 |
+ |
3931 |
+ |
3932 |
+diff --git a/tools/power/cpupower/lib/cpupower.c b/tools/power/cpupower/lib/cpupower.c |
3933 |
+index 9c395ec924de..9711d628b0f4 100644 |
3934 |
+--- a/tools/power/cpupower/lib/cpupower.c |
3935 |
++++ b/tools/power/cpupower/lib/cpupower.c |
3936 |
+@@ -15,7 +15,7 @@ |
3937 |
+ #include "cpupower.h" |
3938 |
+ #include "cpupower_intern.h" |
3939 |
+ |
3940 |
+-unsigned int sysfs_read_file(const char *path, char *buf, size_t buflen) |
3941 |
++unsigned int cpupower_read_sysfs(const char *path, char *buf, size_t buflen) |
3942 |
+ { |
3943 |
+ int fd; |
3944 |
+ ssize_t numread; |
3945 |
+@@ -95,7 +95,7 @@ static int sysfs_topology_read_file(unsigned int cpu, const char *fname, int *re |
3946 |
+ |
3947 |
+ snprintf(path, sizeof(path), PATH_TO_CPU "cpu%u/topology/%s", |
3948 |
+ cpu, fname); |
3949 |
+- if (sysfs_read_file(path, linebuf, MAX_LINE_LEN) == 0) |
3950 |
++ if (cpupower_read_sysfs(path, linebuf, MAX_LINE_LEN) == 0) |
3951 |
+ return -1; |
3952 |
+ *result = strtol(linebuf, &endp, 0); |
3953 |
+ if (endp == linebuf || errno == ERANGE) |
3954 |
+diff --git a/tools/power/cpupower/lib/cpupower_intern.h b/tools/power/cpupower/lib/cpupower_intern.h |
3955 |
+index f8ec4009621c..433fa8619679 100644 |
3956 |
+--- a/tools/power/cpupower/lib/cpupower_intern.h |
3957 |
++++ b/tools/power/cpupower/lib/cpupower_intern.h |
3958 |
+@@ -2,4 +2,4 @@ |
3959 |
+ #define MAX_LINE_LEN 4096 |
3960 |
+ #define SYSFS_PATH_MAX 255 |
3961 |
+ |
3962 |
+-unsigned int sysfs_read_file(const char *path, char *buf, size_t buflen); |
3963 |
++unsigned int cpupower_read_sysfs(const char *path, char *buf, size_t buflen); |