1 |
commit: deb270ae0369d146f1904edb0cecb7130fff5442 |
2 |
Author: Mike Pagano <mpagano <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Aug 17 19:24:25 2018 +0000 |
4 |
Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Nov 21 15:01:12 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=deb270ae |
7 |
|
8 |
Linux patch 4.4.149 |
9 |
|
10 |
Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org> |
11 |
|
12 |
0000_README | 4 + |
13 |
1148_linux-4.4.149.patch | 1202 ++++++++++++++++++++++++++++++++++++++++++++++ |
14 |
2 files changed, 1206 insertions(+) |
15 |
|
16 |
diff --git a/0000_README b/0000_README |
17 |
index 99860c8..1b036be 100644 |
18 |
--- a/0000_README |
19 |
+++ b/0000_README |
20 |
@@ -635,6 +635,10 @@ Patch: 1147_linux-4.4.148.patch |
21 |
From: http://www.kernel.org |
22 |
Desc: Linux 4.4.148 |
23 |
|
24 |
+Patch: 1148_linux-4.4.149.patch |
25 |
+From: http://www.kernel.org |
26 |
+Desc: Linux 4.4.149 |
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/1148_linux-4.4.149.patch b/1148_linux-4.4.149.patch |
33 |
new file mode 100644 |
34 |
index 0000000..95d38f8 |
35 |
--- /dev/null |
36 |
+++ b/1148_linux-4.4.149.patch |
37 |
@@ -0,0 +1,1202 @@ |
38 |
+diff --git a/Documentation/Changes b/Documentation/Changes |
39 |
+index ec97b77c8b00..f25649ffb892 100644 |
40 |
+--- a/Documentation/Changes |
41 |
++++ b/Documentation/Changes |
42 |
+@@ -25,7 +25,7 @@ o GNU C 3.2 # gcc --version |
43 |
+ o GNU make 3.80 # make --version |
44 |
+ o binutils 2.12 # ld -v |
45 |
+ o util-linux 2.10o # fdformat --version |
46 |
+-o module-init-tools 0.9.10 # depmod -V |
47 |
++o kmod 13 # depmod -V |
48 |
+ o e2fsprogs 1.41.4 # e2fsck -V |
49 |
+ o jfsutils 1.1.3 # fsck.jfs -V |
50 |
+ o reiserfsprogs 3.6.3 # reiserfsck -V |
51 |
+@@ -132,12 +132,6 @@ is not build with CONFIG_KALLSYMS and you have no way to rebuild and |
52 |
+ reproduce the Oops with that option, then you can still decode that Oops |
53 |
+ with ksymoops. |
54 |
+ |
55 |
+-Module-Init-Tools |
56 |
+------------------ |
57 |
+- |
58 |
+-A new module loader is now in the kernel that requires module-init-tools |
59 |
+-to use. It is backward compatible with the 2.4.x series kernels. |
60 |
+- |
61 |
+ Mkinitrd |
62 |
+ -------- |
63 |
+ |
64 |
+@@ -319,14 +313,15 @@ Util-linux |
65 |
+ ---------- |
66 |
+ o <ftp://ftp.kernel.org/pub/linux/utils/util-linux/> |
67 |
+ |
68 |
++Kmod |
69 |
++---- |
70 |
++o <https://www.kernel.org/pub/linux/utils/kernel/kmod/> |
71 |
++o <https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git> |
72 |
++ |
73 |
+ Ksymoops |
74 |
+ -------- |
75 |
+ o <ftp://ftp.kernel.org/pub/linux/utils/kernel/ksymoops/v2.4/> |
76 |
+ |
77 |
+-Module-Init-Tools |
78 |
+------------------ |
79 |
+-o <ftp://ftp.kernel.org/pub/linux/kernel/people/rusty/modules/> |
80 |
+- |
81 |
+ Mkinitrd |
82 |
+ -------- |
83 |
+ o <https://code.launchpad.net/initrd-tools/main> |
84 |
+diff --git a/Makefile b/Makefile |
85 |
+index 9b795164122e..e7c46ece5f27 100644 |
86 |
+--- a/Makefile |
87 |
++++ b/Makefile |
88 |
+@@ -1,6 +1,6 @@ |
89 |
+ VERSION = 4 |
90 |
+ PATCHLEVEL = 4 |
91 |
+-SUBLEVEL = 148 |
92 |
++SUBLEVEL = 149 |
93 |
+ EXTRAVERSION = |
94 |
+ NAME = Blurry Fish Butt |
95 |
+ |
96 |
+@@ -418,7 +418,8 @@ export MAKE AWK GENKSYMS INSTALLKERNEL PERL PYTHON UTS_MACHINE |
97 |
+ export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS |
98 |
+ |
99 |
+ export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS |
100 |
+-export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_GCOV CFLAGS_KASAN |
101 |
++export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_GCOV |
102 |
++export CFLAGS_KASAN CFLAGS_KASAN_NOSANITIZE |
103 |
+ export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE |
104 |
+ export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE |
105 |
+ export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL |
106 |
+diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c |
107 |
+index 51ac84e0812d..e9d96b028766 100644 |
108 |
+--- a/arch/arm64/mm/mmu.c |
109 |
++++ b/arch/arm64/mm/mmu.c |
110 |
+@@ -699,12 +699,12 @@ void *__init fixmap_remap_fdt(phys_addr_t dt_phys) |
111 |
+ } |
112 |
+ |
113 |
+ #ifdef CONFIG_HAVE_ARCH_HUGE_VMAP |
114 |
+-int pud_free_pmd_page(pud_t *pud) |
115 |
++int pud_free_pmd_page(pud_t *pud, unsigned long addr) |
116 |
+ { |
117 |
+ return pud_none(*pud); |
118 |
+ } |
119 |
+ |
120 |
+-int pmd_free_pte_page(pmd_t *pmd) |
121 |
++int pmd_free_pte_page(pmd_t *pmd, unsigned long addr) |
122 |
+ { |
123 |
+ return pmd_none(*pmd); |
124 |
+ } |
125 |
+diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c |
126 |
+index 08e94b6139ab..55c7446311a7 100644 |
127 |
+--- a/arch/x86/mm/pgtable.c |
128 |
++++ b/arch/x86/mm/pgtable.c |
129 |
+@@ -676,28 +676,50 @@ int pmd_clear_huge(pmd_t *pmd) |
130 |
+ return 0; |
131 |
+ } |
132 |
+ |
133 |
++#ifdef CONFIG_X86_64 |
134 |
+ /** |
135 |
+ * pud_free_pmd_page - Clear pud entry and free pmd page. |
136 |
+ * @pud: Pointer to a PUD. |
137 |
++ * @addr: Virtual address associated with pud. |
138 |
+ * |
139 |
+- * Context: The pud range has been unmaped and TLB purged. |
140 |
++ * Context: The pud range has been unmapped and TLB purged. |
141 |
+ * Return: 1 if clearing the entry succeeded. 0 otherwise. |
142 |
++ * |
143 |
++ * NOTE: Callers must allow a single page allocation. |
144 |
+ */ |
145 |
+-int pud_free_pmd_page(pud_t *pud) |
146 |
++int pud_free_pmd_page(pud_t *pud, unsigned long addr) |
147 |
+ { |
148 |
+- pmd_t *pmd; |
149 |
++ pmd_t *pmd, *pmd_sv; |
150 |
++ pte_t *pte; |
151 |
+ int i; |
152 |
+ |
153 |
+ if (pud_none(*pud)) |
154 |
+ return 1; |
155 |
+ |
156 |
+ pmd = (pmd_t *)pud_page_vaddr(*pud); |
157 |
++ pmd_sv = (pmd_t *)__get_free_page(GFP_KERNEL); |
158 |
++ if (!pmd_sv) |
159 |
++ return 0; |
160 |
+ |
161 |
+- for (i = 0; i < PTRS_PER_PMD; i++) |
162 |
+- if (!pmd_free_pte_page(&pmd[i])) |
163 |
+- return 0; |
164 |
++ for (i = 0; i < PTRS_PER_PMD; i++) { |
165 |
++ pmd_sv[i] = pmd[i]; |
166 |
++ if (!pmd_none(pmd[i])) |
167 |
++ pmd_clear(&pmd[i]); |
168 |
++ } |
169 |
+ |
170 |
+ pud_clear(pud); |
171 |
++ |
172 |
++ /* INVLPG to clear all paging-structure caches */ |
173 |
++ flush_tlb_kernel_range(addr, addr + PAGE_SIZE-1); |
174 |
++ |
175 |
++ for (i = 0; i < PTRS_PER_PMD; i++) { |
176 |
++ if (!pmd_none(pmd_sv[i])) { |
177 |
++ pte = (pte_t *)pmd_page_vaddr(pmd_sv[i]); |
178 |
++ free_page((unsigned long)pte); |
179 |
++ } |
180 |
++ } |
181 |
++ |
182 |
++ free_page((unsigned long)pmd_sv); |
183 |
+ free_page((unsigned long)pmd); |
184 |
+ |
185 |
+ return 1; |
186 |
+@@ -706,11 +728,12 @@ int pud_free_pmd_page(pud_t *pud) |
187 |
+ /** |
188 |
+ * pmd_free_pte_page - Clear pmd entry and free pte page. |
189 |
+ * @pmd: Pointer to a PMD. |
190 |
++ * @addr: Virtual address associated with pmd. |
191 |
+ * |
192 |
+- * Context: The pmd range has been unmaped and TLB purged. |
193 |
++ * Context: The pmd range has been unmapped and TLB purged. |
194 |
+ * Return: 1 if clearing the entry succeeded. 0 otherwise. |
195 |
+ */ |
196 |
+-int pmd_free_pte_page(pmd_t *pmd) |
197 |
++int pmd_free_pte_page(pmd_t *pmd, unsigned long addr) |
198 |
+ { |
199 |
+ pte_t *pte; |
200 |
+ |
201 |
+@@ -719,8 +742,30 @@ int pmd_free_pte_page(pmd_t *pmd) |
202 |
+ |
203 |
+ pte = (pte_t *)pmd_page_vaddr(*pmd); |
204 |
+ pmd_clear(pmd); |
205 |
++ |
206 |
++ /* INVLPG to clear all paging-structure caches */ |
207 |
++ flush_tlb_kernel_range(addr, addr + PAGE_SIZE-1); |
208 |
++ |
209 |
+ free_page((unsigned long)pte); |
210 |
+ |
211 |
+ return 1; |
212 |
+ } |
213 |
++ |
214 |
++#else /* !CONFIG_X86_64 */ |
215 |
++ |
216 |
++int pud_free_pmd_page(pud_t *pud, unsigned long addr) |
217 |
++{ |
218 |
++ return pud_none(*pud); |
219 |
++} |
220 |
++ |
221 |
++/* |
222 |
++ * Disable free page handling on x86-PAE. This assures that ioremap() |
223 |
++ * does not update sync'd pmd entries. See vmalloc_sync_one(). |
224 |
++ */ |
225 |
++int pmd_free_pte_page(pmd_t *pmd, unsigned long addr) |
226 |
++{ |
227 |
++ return pmd_none(*pmd); |
228 |
++} |
229 |
++ |
230 |
++#endif /* CONFIG_X86_64 */ |
231 |
+ #endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */ |
232 |
+diff --git a/crypto/ablkcipher.c b/crypto/ablkcipher.c |
233 |
+index e5b5721809e2..149e7a7f04fe 100644 |
234 |
+--- a/crypto/ablkcipher.c |
235 |
++++ b/crypto/ablkcipher.c |
236 |
+@@ -73,11 +73,9 @@ static inline u8 *ablkcipher_get_spot(u8 *start, unsigned int len) |
237 |
+ return max(start, end_page); |
238 |
+ } |
239 |
+ |
240 |
+-static inline unsigned int ablkcipher_done_slow(struct ablkcipher_walk *walk, |
241 |
+- unsigned int bsize) |
242 |
++static inline void ablkcipher_done_slow(struct ablkcipher_walk *walk, |
243 |
++ unsigned int n) |
244 |
+ { |
245 |
+- unsigned int n = bsize; |
246 |
+- |
247 |
+ for (;;) { |
248 |
+ unsigned int len_this_page = scatterwalk_pagelen(&walk->out); |
249 |
+ |
250 |
+@@ -89,17 +87,13 @@ static inline unsigned int ablkcipher_done_slow(struct ablkcipher_walk *walk, |
251 |
+ n -= len_this_page; |
252 |
+ scatterwalk_start(&walk->out, sg_next(walk->out.sg)); |
253 |
+ } |
254 |
+- |
255 |
+- return bsize; |
256 |
+ } |
257 |
+ |
258 |
+-static inline unsigned int ablkcipher_done_fast(struct ablkcipher_walk *walk, |
259 |
+- unsigned int n) |
260 |
++static inline void ablkcipher_done_fast(struct ablkcipher_walk *walk, |
261 |
++ unsigned int n) |
262 |
+ { |
263 |
+ scatterwalk_advance(&walk->in, n); |
264 |
+ scatterwalk_advance(&walk->out, n); |
265 |
+- |
266 |
+- return n; |
267 |
+ } |
268 |
+ |
269 |
+ static int ablkcipher_walk_next(struct ablkcipher_request *req, |
270 |
+@@ -109,39 +103,40 @@ int ablkcipher_walk_done(struct ablkcipher_request *req, |
271 |
+ struct ablkcipher_walk *walk, int err) |
272 |
+ { |
273 |
+ struct crypto_tfm *tfm = req->base.tfm; |
274 |
+- unsigned int nbytes = 0; |
275 |
++ unsigned int n; /* bytes processed */ |
276 |
++ bool more; |
277 |
+ |
278 |
+- if (likely(err >= 0)) { |
279 |
+- unsigned int n = walk->nbytes - err; |
280 |
++ if (unlikely(err < 0)) |
281 |
++ goto finish; |
282 |
+ |
283 |
+- if (likely(!(walk->flags & ABLKCIPHER_WALK_SLOW))) |
284 |
+- n = ablkcipher_done_fast(walk, n); |
285 |
+- else if (WARN_ON(err)) { |
286 |
+- err = -EINVAL; |
287 |
+- goto err; |
288 |
+- } else |
289 |
+- n = ablkcipher_done_slow(walk, n); |
290 |
++ n = walk->nbytes - err; |
291 |
++ walk->total -= n; |
292 |
++ more = (walk->total != 0); |
293 |
+ |
294 |
+- nbytes = walk->total - n; |
295 |
+- err = 0; |
296 |
++ if (likely(!(walk->flags & ABLKCIPHER_WALK_SLOW))) { |
297 |
++ ablkcipher_done_fast(walk, n); |
298 |
++ } else { |
299 |
++ if (WARN_ON(err)) { |
300 |
++ /* unexpected case; didn't process all bytes */ |
301 |
++ err = -EINVAL; |
302 |
++ goto finish; |
303 |
++ } |
304 |
++ ablkcipher_done_slow(walk, n); |
305 |
+ } |
306 |
+ |
307 |
+- scatterwalk_done(&walk->in, 0, nbytes); |
308 |
+- scatterwalk_done(&walk->out, 1, nbytes); |
309 |
+- |
310 |
+-err: |
311 |
+- walk->total = nbytes; |
312 |
+- walk->nbytes = nbytes; |
313 |
++ scatterwalk_done(&walk->in, 0, more); |
314 |
++ scatterwalk_done(&walk->out, 1, more); |
315 |
+ |
316 |
+- if (nbytes) { |
317 |
++ if (more) { |
318 |
+ crypto_yield(req->base.flags); |
319 |
+ return ablkcipher_walk_next(req, walk); |
320 |
+ } |
321 |
+- |
322 |
++ err = 0; |
323 |
++finish: |
324 |
++ walk->nbytes = 0; |
325 |
+ if (walk->iv != req->info) |
326 |
+ memcpy(req->info, walk->iv, tfm->crt_ablkcipher.ivsize); |
327 |
+ kfree(walk->iv_buffer); |
328 |
+- |
329 |
+ return err; |
330 |
+ } |
331 |
+ EXPORT_SYMBOL_GPL(ablkcipher_walk_done); |
332 |
+diff --git a/crypto/blkcipher.c b/crypto/blkcipher.c |
333 |
+index dca7bc87dad9..2d08e59b3212 100644 |
334 |
+--- a/crypto/blkcipher.c |
335 |
++++ b/crypto/blkcipher.c |
336 |
+@@ -71,19 +71,18 @@ static inline u8 *blkcipher_get_spot(u8 *start, unsigned int len) |
337 |
+ return max(start, end_page); |
338 |
+ } |
339 |
+ |
340 |
+-static inline unsigned int blkcipher_done_slow(struct blkcipher_walk *walk, |
341 |
+- unsigned int bsize) |
342 |
++static inline void blkcipher_done_slow(struct blkcipher_walk *walk, |
343 |
++ unsigned int bsize) |
344 |
+ { |
345 |
+ u8 *addr; |
346 |
+ |
347 |
+ addr = (u8 *)ALIGN((unsigned long)walk->buffer, walk->alignmask + 1); |
348 |
+ addr = blkcipher_get_spot(addr, bsize); |
349 |
+ scatterwalk_copychunks(addr, &walk->out, bsize, 1); |
350 |
+- return bsize; |
351 |
+ } |
352 |
+ |
353 |
+-static inline unsigned int blkcipher_done_fast(struct blkcipher_walk *walk, |
354 |
+- unsigned int n) |
355 |
++static inline void blkcipher_done_fast(struct blkcipher_walk *walk, |
356 |
++ unsigned int n) |
357 |
+ { |
358 |
+ if (walk->flags & BLKCIPHER_WALK_COPY) { |
359 |
+ blkcipher_map_dst(walk); |
360 |
+@@ -97,49 +96,48 @@ static inline unsigned int blkcipher_done_fast(struct blkcipher_walk *walk, |
361 |
+ |
362 |
+ scatterwalk_advance(&walk->in, n); |
363 |
+ scatterwalk_advance(&walk->out, n); |
364 |
+- |
365 |
+- return n; |
366 |
+ } |
367 |
+ |
368 |
+ int blkcipher_walk_done(struct blkcipher_desc *desc, |
369 |
+ struct blkcipher_walk *walk, int err) |
370 |
+ { |
371 |
+- unsigned int nbytes = 0; |
372 |
++ unsigned int n; /* bytes processed */ |
373 |
++ bool more; |
374 |
+ |
375 |
+- if (likely(err >= 0)) { |
376 |
+- unsigned int n = walk->nbytes - err; |
377 |
++ if (unlikely(err < 0)) |
378 |
++ goto finish; |
379 |
+ |
380 |
+- if (likely(!(walk->flags & BLKCIPHER_WALK_SLOW))) |
381 |
+- n = blkcipher_done_fast(walk, n); |
382 |
+- else if (WARN_ON(err)) { |
383 |
+- err = -EINVAL; |
384 |
+- goto err; |
385 |
+- } else |
386 |
+- n = blkcipher_done_slow(walk, n); |
387 |
++ n = walk->nbytes - err; |
388 |
++ walk->total -= n; |
389 |
++ more = (walk->total != 0); |
390 |
+ |
391 |
+- nbytes = walk->total - n; |
392 |
+- err = 0; |
393 |
++ if (likely(!(walk->flags & BLKCIPHER_WALK_SLOW))) { |
394 |
++ blkcipher_done_fast(walk, n); |
395 |
++ } else { |
396 |
++ if (WARN_ON(err)) { |
397 |
++ /* unexpected case; didn't process all bytes */ |
398 |
++ err = -EINVAL; |
399 |
++ goto finish; |
400 |
++ } |
401 |
++ blkcipher_done_slow(walk, n); |
402 |
+ } |
403 |
+ |
404 |
+- scatterwalk_done(&walk->in, 0, nbytes); |
405 |
+- scatterwalk_done(&walk->out, 1, nbytes); |
406 |
+- |
407 |
+-err: |
408 |
+- walk->total = nbytes; |
409 |
+- walk->nbytes = nbytes; |
410 |
++ scatterwalk_done(&walk->in, 0, more); |
411 |
++ scatterwalk_done(&walk->out, 1, more); |
412 |
+ |
413 |
+- if (nbytes) { |
414 |
++ if (more) { |
415 |
+ crypto_yield(desc->flags); |
416 |
+ return blkcipher_walk_next(desc, walk); |
417 |
+ } |
418 |
+- |
419 |
++ err = 0; |
420 |
++finish: |
421 |
++ walk->nbytes = 0; |
422 |
+ if (walk->iv != desc->info) |
423 |
+ memcpy(desc->info, walk->iv, walk->ivsize); |
424 |
+ if (walk->buffer != walk->page) |
425 |
+ kfree(walk->buffer); |
426 |
+ if (walk->page) |
427 |
+ free_page((unsigned long)walk->page); |
428 |
+- |
429 |
+ return err; |
430 |
+ } |
431 |
+ EXPORT_SYMBOL_GPL(blkcipher_walk_done); |
432 |
+diff --git a/crypto/vmac.c b/crypto/vmac.c |
433 |
+index df76a816cfb2..bb2fc787d615 100644 |
434 |
+--- a/crypto/vmac.c |
435 |
++++ b/crypto/vmac.c |
436 |
+@@ -1,6 +1,10 @@ |
437 |
+ /* |
438 |
+- * Modified to interface to the Linux kernel |
439 |
++ * VMAC: Message Authentication Code using Universal Hashing |
440 |
++ * |
441 |
++ * Reference: https://tools.ietf.org/html/draft-krovetz-vmac-01 |
442 |
++ * |
443 |
+ * Copyright (c) 2009, Intel Corporation. |
444 |
++ * Copyright (c) 2018, Google Inc. |
445 |
+ * |
446 |
+ * This program is free software; you can redistribute it and/or modify it |
447 |
+ * under the terms and conditions of the GNU General Public License, |
448 |
+@@ -16,14 +20,15 @@ |
449 |
+ * Place - Suite 330, Boston, MA 02111-1307 USA. |
450 |
+ */ |
451 |
+ |
452 |
+-/* -------------------------------------------------------------------------- |
453 |
+- * VMAC and VHASH Implementation by Ted Krovetz (tdk@×××.org) and Wei Dai. |
454 |
+- * This implementation is herby placed in the public domain. |
455 |
+- * The authors offers no warranty. Use at your own risk. |
456 |
+- * Please send bug reports to the authors. |
457 |
+- * Last modified: 17 APR 08, 1700 PDT |
458 |
+- * ----------------------------------------------------------------------- */ |
459 |
++/* |
460 |
++ * Derived from: |
461 |
++ * VMAC and VHASH Implementation by Ted Krovetz (tdk@×××.org) and Wei Dai. |
462 |
++ * This implementation is herby placed in the public domain. |
463 |
++ * The authors offers no warranty. Use at your own risk. |
464 |
++ * Last modified: 17 APR 08, 1700 PDT |
465 |
++ */ |
466 |
+ |
467 |
++#include <asm/unaligned.h> |
468 |
+ #include <linux/init.h> |
469 |
+ #include <linux/types.h> |
470 |
+ #include <linux/crypto.h> |
471 |
+@@ -31,9 +36,35 @@ |
472 |
+ #include <linux/scatterlist.h> |
473 |
+ #include <asm/byteorder.h> |
474 |
+ #include <crypto/scatterwalk.h> |
475 |
+-#include <crypto/vmac.h> |
476 |
+ #include <crypto/internal/hash.h> |
477 |
+ |
478 |
++/* |
479 |
++ * User definable settings. |
480 |
++ */ |
481 |
++#define VMAC_TAG_LEN 64 |
482 |
++#define VMAC_KEY_SIZE 128/* Must be 128, 192 or 256 */ |
483 |
++#define VMAC_KEY_LEN (VMAC_KEY_SIZE/8) |
484 |
++#define VMAC_NHBYTES 128/* Must 2^i for any 3 < i < 13 Standard = 128*/ |
485 |
++ |
486 |
++/* per-transform (per-key) context */ |
487 |
++struct vmac_tfm_ctx { |
488 |
++ struct crypto_cipher *cipher; |
489 |
++ u64 nhkey[(VMAC_NHBYTES/8)+2*(VMAC_TAG_LEN/64-1)]; |
490 |
++ u64 polykey[2*VMAC_TAG_LEN/64]; |
491 |
++ u64 l3key[2*VMAC_TAG_LEN/64]; |
492 |
++}; |
493 |
++ |
494 |
++/* per-request context */ |
495 |
++struct vmac_desc_ctx { |
496 |
++ union { |
497 |
++ u8 partial[VMAC_NHBYTES]; /* partial block */ |
498 |
++ __le64 partial_words[VMAC_NHBYTES / 8]; |
499 |
++ }; |
500 |
++ unsigned int partial_size; /* size of the partial block */ |
501 |
++ bool first_block_processed; |
502 |
++ u64 polytmp[2*VMAC_TAG_LEN/64]; /* running total of L2-hash */ |
503 |
++}; |
504 |
++ |
505 |
+ /* |
506 |
+ * Constants and masks |
507 |
+ */ |
508 |
+@@ -318,13 +349,6 @@ static void poly_step_func(u64 *ahi, u64 *alo, |
509 |
+ } while (0) |
510 |
+ #endif |
511 |
+ |
512 |
+-static void vhash_abort(struct vmac_ctx *ctx) |
513 |
+-{ |
514 |
+- ctx->polytmp[0] = ctx->polykey[0] ; |
515 |
+- ctx->polytmp[1] = ctx->polykey[1] ; |
516 |
+- ctx->first_block_processed = 0; |
517 |
+-} |
518 |
+- |
519 |
+ static u64 l3hash(u64 p1, u64 p2, u64 k1, u64 k2, u64 len) |
520 |
+ { |
521 |
+ u64 rh, rl, t, z = 0; |
522 |
+@@ -364,280 +388,209 @@ static u64 l3hash(u64 p1, u64 p2, u64 k1, u64 k2, u64 len) |
523 |
+ return rl; |
524 |
+ } |
525 |
+ |
526 |
+-static void vhash_update(const unsigned char *m, |
527 |
+- unsigned int mbytes, /* Pos multiple of VMAC_NHBYTES */ |
528 |
+- struct vmac_ctx *ctx) |
529 |
++/* L1 and L2-hash one or more VMAC_NHBYTES-byte blocks */ |
530 |
++static void vhash_blocks(const struct vmac_tfm_ctx *tctx, |
531 |
++ struct vmac_desc_ctx *dctx, |
532 |
++ const __le64 *mptr, unsigned int blocks) |
533 |
+ { |
534 |
+- u64 rh, rl, *mptr; |
535 |
+- const u64 *kptr = (u64 *)ctx->nhkey; |
536 |
+- int i; |
537 |
+- u64 ch, cl; |
538 |
+- u64 pkh = ctx->polykey[0]; |
539 |
+- u64 pkl = ctx->polykey[1]; |
540 |
+- |
541 |
+- if (!mbytes) |
542 |
+- return; |
543 |
+- |
544 |
+- BUG_ON(mbytes % VMAC_NHBYTES); |
545 |
+- |
546 |
+- mptr = (u64 *)m; |
547 |
+- i = mbytes / VMAC_NHBYTES; /* Must be non-zero */ |
548 |
+- |
549 |
+- ch = ctx->polytmp[0]; |
550 |
+- cl = ctx->polytmp[1]; |
551 |
+- |
552 |
+- if (!ctx->first_block_processed) { |
553 |
+- ctx->first_block_processed = 1; |
554 |
++ const u64 *kptr = tctx->nhkey; |
555 |
++ const u64 pkh = tctx->polykey[0]; |
556 |
++ const u64 pkl = tctx->polykey[1]; |
557 |
++ u64 ch = dctx->polytmp[0]; |
558 |
++ u64 cl = dctx->polytmp[1]; |
559 |
++ u64 rh, rl; |
560 |
++ |
561 |
++ if (!dctx->first_block_processed) { |
562 |
++ dctx->first_block_processed = true; |
563 |
+ nh_vmac_nhbytes(mptr, kptr, VMAC_NHBYTES/8, rh, rl); |
564 |
+ rh &= m62; |
565 |
+ ADD128(ch, cl, rh, rl); |
566 |
+ mptr += (VMAC_NHBYTES/sizeof(u64)); |
567 |
+- i--; |
568 |
++ blocks--; |
569 |
+ } |
570 |
+ |
571 |
+- while (i--) { |
572 |
++ while (blocks--) { |
573 |
+ nh_vmac_nhbytes(mptr, kptr, VMAC_NHBYTES/8, rh, rl); |
574 |
+ rh &= m62; |
575 |
+ poly_step(ch, cl, pkh, pkl, rh, rl); |
576 |
+ mptr += (VMAC_NHBYTES/sizeof(u64)); |
577 |
+ } |
578 |
+ |
579 |
+- ctx->polytmp[0] = ch; |
580 |
+- ctx->polytmp[1] = cl; |
581 |
++ dctx->polytmp[0] = ch; |
582 |
++ dctx->polytmp[1] = cl; |
583 |
+ } |
584 |
+ |
585 |
+-static u64 vhash(unsigned char m[], unsigned int mbytes, |
586 |
+- u64 *tagl, struct vmac_ctx *ctx) |
587 |
++static int vmac_setkey(struct crypto_shash *tfm, |
588 |
++ const u8 *key, unsigned int keylen) |
589 |
+ { |
590 |
+- u64 rh, rl, *mptr; |
591 |
+- const u64 *kptr = (u64 *)ctx->nhkey; |
592 |
+- int i, remaining; |
593 |
+- u64 ch, cl; |
594 |
+- u64 pkh = ctx->polykey[0]; |
595 |
+- u64 pkl = ctx->polykey[1]; |
596 |
+- |
597 |
+- mptr = (u64 *)m; |
598 |
+- i = mbytes / VMAC_NHBYTES; |
599 |
+- remaining = mbytes % VMAC_NHBYTES; |
600 |
+- |
601 |
+- if (ctx->first_block_processed) { |
602 |
+- ch = ctx->polytmp[0]; |
603 |
+- cl = ctx->polytmp[1]; |
604 |
+- } else if (i) { |
605 |
+- nh_vmac_nhbytes(mptr, kptr, VMAC_NHBYTES/8, ch, cl); |
606 |
+- ch &= m62; |
607 |
+- ADD128(ch, cl, pkh, pkl); |
608 |
+- mptr += (VMAC_NHBYTES/sizeof(u64)); |
609 |
+- i--; |
610 |
+- } else if (remaining) { |
611 |
+- nh_16(mptr, kptr, 2*((remaining+15)/16), ch, cl); |
612 |
+- ch &= m62; |
613 |
+- ADD128(ch, cl, pkh, pkl); |
614 |
+- mptr += (VMAC_NHBYTES/sizeof(u64)); |
615 |
+- goto do_l3; |
616 |
+- } else {/* Empty String */ |
617 |
+- ch = pkh; cl = pkl; |
618 |
+- goto do_l3; |
619 |
+- } |
620 |
+- |
621 |
+- while (i--) { |
622 |
+- nh_vmac_nhbytes(mptr, kptr, VMAC_NHBYTES/8, rh, rl); |
623 |
+- rh &= m62; |
624 |
+- poly_step(ch, cl, pkh, pkl, rh, rl); |
625 |
+- mptr += (VMAC_NHBYTES/sizeof(u64)); |
626 |
+- } |
627 |
+- if (remaining) { |
628 |
+- nh_16(mptr, kptr, 2*((remaining+15)/16), rh, rl); |
629 |
+- rh &= m62; |
630 |
+- poly_step(ch, cl, pkh, pkl, rh, rl); |
631 |
+- } |
632 |
+- |
633 |
+-do_l3: |
634 |
+- vhash_abort(ctx); |
635 |
+- remaining *= 8; |
636 |
+- return l3hash(ch, cl, ctx->l3key[0], ctx->l3key[1], remaining); |
637 |
+-} |
638 |
++ struct vmac_tfm_ctx *tctx = crypto_shash_ctx(tfm); |
639 |
++ __be64 out[2]; |
640 |
++ u8 in[16] = { 0 }; |
641 |
++ unsigned int i; |
642 |
++ int err; |
643 |
+ |
644 |
+-static u64 vmac(unsigned char m[], unsigned int mbytes, |
645 |
+- const unsigned char n[16], u64 *tagl, |
646 |
+- struct vmac_ctx_t *ctx) |
647 |
+-{ |
648 |
+- u64 *in_n, *out_p; |
649 |
+- u64 p, h; |
650 |
+- int i; |
651 |
+- |
652 |
+- in_n = ctx->__vmac_ctx.cached_nonce; |
653 |
+- out_p = ctx->__vmac_ctx.cached_aes; |
654 |
+- |
655 |
+- i = n[15] & 1; |
656 |
+- if ((*(u64 *)(n+8) != in_n[1]) || (*(u64 *)(n) != in_n[0])) { |
657 |
+- in_n[0] = *(u64 *)(n); |
658 |
+- in_n[1] = *(u64 *)(n+8); |
659 |
+- ((unsigned char *)in_n)[15] &= 0xFE; |
660 |
+- crypto_cipher_encrypt_one(ctx->child, |
661 |
+- (unsigned char *)out_p, (unsigned char *)in_n); |
662 |
+- |
663 |
+- ((unsigned char *)in_n)[15] |= (unsigned char)(1-i); |
664 |
++ if (keylen != VMAC_KEY_LEN) { |
665 |
++ crypto_shash_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); |
666 |
++ return -EINVAL; |
667 |
+ } |
668 |
+- p = be64_to_cpup(out_p + i); |
669 |
+- h = vhash(m, mbytes, (u64 *)0, &ctx->__vmac_ctx); |
670 |
+- return le64_to_cpu(p + h); |
671 |
+-} |
672 |
+ |
673 |
+-static int vmac_set_key(unsigned char user_key[], struct vmac_ctx_t *ctx) |
674 |
+-{ |
675 |
+- u64 in[2] = {0}, out[2]; |
676 |
+- unsigned i; |
677 |
+- int err = 0; |
678 |
+- |
679 |
+- err = crypto_cipher_setkey(ctx->child, user_key, VMAC_KEY_LEN); |
680 |
++ err = crypto_cipher_setkey(tctx->cipher, key, keylen); |
681 |
+ if (err) |
682 |
+ return err; |
683 |
+ |
684 |
+ /* Fill nh key */ |
685 |
+- ((unsigned char *)in)[0] = 0x80; |
686 |
+- for (i = 0; i < sizeof(ctx->__vmac_ctx.nhkey)/8; i += 2) { |
687 |
+- crypto_cipher_encrypt_one(ctx->child, |
688 |
+- (unsigned char *)out, (unsigned char *)in); |
689 |
+- ctx->__vmac_ctx.nhkey[i] = be64_to_cpup(out); |
690 |
+- ctx->__vmac_ctx.nhkey[i+1] = be64_to_cpup(out+1); |
691 |
+- ((unsigned char *)in)[15] += 1; |
692 |
++ in[0] = 0x80; |
693 |
++ for (i = 0; i < ARRAY_SIZE(tctx->nhkey); i += 2) { |
694 |
++ crypto_cipher_encrypt_one(tctx->cipher, (u8 *)out, in); |
695 |
++ tctx->nhkey[i] = be64_to_cpu(out[0]); |
696 |
++ tctx->nhkey[i+1] = be64_to_cpu(out[1]); |
697 |
++ in[15]++; |
698 |
+ } |
699 |
+ |
700 |
+ /* Fill poly key */ |
701 |
+- ((unsigned char *)in)[0] = 0xC0; |
702 |
+- in[1] = 0; |
703 |
+- for (i = 0; i < sizeof(ctx->__vmac_ctx.polykey)/8; i += 2) { |
704 |
+- crypto_cipher_encrypt_one(ctx->child, |
705 |
+- (unsigned char *)out, (unsigned char *)in); |
706 |
+- ctx->__vmac_ctx.polytmp[i] = |
707 |
+- ctx->__vmac_ctx.polykey[i] = |
708 |
+- be64_to_cpup(out) & mpoly; |
709 |
+- ctx->__vmac_ctx.polytmp[i+1] = |
710 |
+- ctx->__vmac_ctx.polykey[i+1] = |
711 |
+- be64_to_cpup(out+1) & mpoly; |
712 |
+- ((unsigned char *)in)[15] += 1; |
713 |
++ in[0] = 0xC0; |
714 |
++ in[15] = 0; |
715 |
++ for (i = 0; i < ARRAY_SIZE(tctx->polykey); i += 2) { |
716 |
++ crypto_cipher_encrypt_one(tctx->cipher, (u8 *)out, in); |
717 |
++ tctx->polykey[i] = be64_to_cpu(out[0]) & mpoly; |
718 |
++ tctx->polykey[i+1] = be64_to_cpu(out[1]) & mpoly; |
719 |
++ in[15]++; |
720 |
+ } |
721 |
+ |
722 |
+ /* Fill ip key */ |
723 |
+- ((unsigned char *)in)[0] = 0xE0; |
724 |
+- in[1] = 0; |
725 |
+- for (i = 0; i < sizeof(ctx->__vmac_ctx.l3key)/8; i += 2) { |
726 |
++ in[0] = 0xE0; |
727 |
++ in[15] = 0; |
728 |
++ for (i = 0; i < ARRAY_SIZE(tctx->l3key); i += 2) { |
729 |
+ do { |
730 |
+- crypto_cipher_encrypt_one(ctx->child, |
731 |
+- (unsigned char *)out, (unsigned char *)in); |
732 |
+- ctx->__vmac_ctx.l3key[i] = be64_to_cpup(out); |
733 |
+- ctx->__vmac_ctx.l3key[i+1] = be64_to_cpup(out+1); |
734 |
+- ((unsigned char *)in)[15] += 1; |
735 |
+- } while (ctx->__vmac_ctx.l3key[i] >= p64 |
736 |
+- || ctx->__vmac_ctx.l3key[i+1] >= p64); |
737 |
++ crypto_cipher_encrypt_one(tctx->cipher, (u8 *)out, in); |
738 |
++ tctx->l3key[i] = be64_to_cpu(out[0]); |
739 |
++ tctx->l3key[i+1] = be64_to_cpu(out[1]); |
740 |
++ in[15]++; |
741 |
++ } while (tctx->l3key[i] >= p64 || tctx->l3key[i+1] >= p64); |
742 |
+ } |
743 |
+ |
744 |
+- /* Invalidate nonce/aes cache and reset other elements */ |
745 |
+- ctx->__vmac_ctx.cached_nonce[0] = (u64)-1; /* Ensure illegal nonce */ |
746 |
+- ctx->__vmac_ctx.cached_nonce[1] = (u64)0; /* Ensure illegal nonce */ |
747 |
+- ctx->__vmac_ctx.first_block_processed = 0; |
748 |
+- |
749 |
+- return err; |
750 |
++ return 0; |
751 |
+ } |
752 |
+ |
753 |
+-static int vmac_setkey(struct crypto_shash *parent, |
754 |
+- const u8 *key, unsigned int keylen) |
755 |
++static int vmac_init(struct shash_desc *desc) |
756 |
+ { |
757 |
+- struct vmac_ctx_t *ctx = crypto_shash_ctx(parent); |
758 |
++ const struct vmac_tfm_ctx *tctx = crypto_shash_ctx(desc->tfm); |
759 |
++ struct vmac_desc_ctx *dctx = shash_desc_ctx(desc); |
760 |
+ |
761 |
+- if (keylen != VMAC_KEY_LEN) { |
762 |
+- crypto_shash_set_flags(parent, CRYPTO_TFM_RES_BAD_KEY_LEN); |
763 |
+- return -EINVAL; |
764 |
+- } |
765 |
+- |
766 |
+- return vmac_set_key((u8 *)key, ctx); |
767 |
+-} |
768 |
+- |
769 |
+-static int vmac_init(struct shash_desc *pdesc) |
770 |
+-{ |
771 |
++ dctx->partial_size = 0; |
772 |
++ dctx->first_block_processed = false; |
773 |
++ memcpy(dctx->polytmp, tctx->polykey, sizeof(dctx->polytmp)); |
774 |
+ return 0; |
775 |
+ } |
776 |
+ |
777 |
+-static int vmac_update(struct shash_desc *pdesc, const u8 *p, |
778 |
+- unsigned int len) |
779 |
++static int vmac_update(struct shash_desc *desc, const u8 *p, unsigned int len) |
780 |
+ { |
781 |
+- struct crypto_shash *parent = pdesc->tfm; |
782 |
+- struct vmac_ctx_t *ctx = crypto_shash_ctx(parent); |
783 |
+- int expand; |
784 |
+- int min; |
785 |
+- |
786 |
+- expand = VMAC_NHBYTES - ctx->partial_size > 0 ? |
787 |
+- VMAC_NHBYTES - ctx->partial_size : 0; |
788 |
+- |
789 |
+- min = len < expand ? len : expand; |
790 |
+- |
791 |
+- memcpy(ctx->partial + ctx->partial_size, p, min); |
792 |
+- ctx->partial_size += min; |
793 |
+- |
794 |
+- if (len < expand) |
795 |
+- return 0; |
796 |
+- |
797 |
+- vhash_update(ctx->partial, VMAC_NHBYTES, &ctx->__vmac_ctx); |
798 |
+- ctx->partial_size = 0; |
799 |
+- |
800 |
+- len -= expand; |
801 |
+- p += expand; |
802 |
++ const struct vmac_tfm_ctx *tctx = crypto_shash_ctx(desc->tfm); |
803 |
++ struct vmac_desc_ctx *dctx = shash_desc_ctx(desc); |
804 |
++ unsigned int n; |
805 |
++ |
806 |
++ if (dctx->partial_size) { |
807 |
++ n = min(len, VMAC_NHBYTES - dctx->partial_size); |
808 |
++ memcpy(&dctx->partial[dctx->partial_size], p, n); |
809 |
++ dctx->partial_size += n; |
810 |
++ p += n; |
811 |
++ len -= n; |
812 |
++ if (dctx->partial_size == VMAC_NHBYTES) { |
813 |
++ vhash_blocks(tctx, dctx, dctx->partial_words, 1); |
814 |
++ dctx->partial_size = 0; |
815 |
++ } |
816 |
++ } |
817 |
+ |
818 |
+- if (len % VMAC_NHBYTES) { |
819 |
+- memcpy(ctx->partial, p + len - (len % VMAC_NHBYTES), |
820 |
+- len % VMAC_NHBYTES); |
821 |
+- ctx->partial_size = len % VMAC_NHBYTES; |
822 |
++ if (len >= VMAC_NHBYTES) { |
823 |
++ n = round_down(len, VMAC_NHBYTES); |
824 |
++ /* TODO: 'p' may be misaligned here */ |
825 |
++ vhash_blocks(tctx, dctx, (const __le64 *)p, n / VMAC_NHBYTES); |
826 |
++ p += n; |
827 |
++ len -= n; |
828 |
+ } |
829 |
+ |
830 |
+- vhash_update(p, len - len % VMAC_NHBYTES, &ctx->__vmac_ctx); |
831 |
++ if (len) { |
832 |
++ memcpy(dctx->partial, p, len); |
833 |
++ dctx->partial_size = len; |
834 |
++ } |
835 |
+ |
836 |
+ return 0; |
837 |
+ } |
838 |
+ |
839 |
+-static int vmac_final(struct shash_desc *pdesc, u8 *out) |
840 |
++static u64 vhash_final(const struct vmac_tfm_ctx *tctx, |
841 |
++ struct vmac_desc_ctx *dctx) |
842 |
+ { |
843 |
+- struct crypto_shash *parent = pdesc->tfm; |
844 |
+- struct vmac_ctx_t *ctx = crypto_shash_ctx(parent); |
845 |
+- vmac_t mac; |
846 |
+- u8 nonce[16] = {}; |
847 |
+- |
848 |
+- /* vmac() ends up accessing outside the array bounds that |
849 |
+- * we specify. In appears to access up to the next 2-word |
850 |
+- * boundary. We'll just be uber cautious and zero the |
851 |
+- * unwritten bytes in the buffer. |
852 |
+- */ |
853 |
+- if (ctx->partial_size) { |
854 |
+- memset(ctx->partial + ctx->partial_size, 0, |
855 |
+- VMAC_NHBYTES - ctx->partial_size); |
856 |
++ unsigned int partial = dctx->partial_size; |
857 |
++ u64 ch = dctx->polytmp[0]; |
858 |
++ u64 cl = dctx->polytmp[1]; |
859 |
++ |
860 |
++ /* L1 and L2-hash the final block if needed */ |
861 |
++ if (partial) { |
862 |
++ /* Zero-pad to next 128-bit boundary */ |
863 |
++ unsigned int n = round_up(partial, 16); |
864 |
++ u64 rh, rl; |
865 |
++ |
866 |
++ memset(&dctx->partial[partial], 0, n - partial); |
867 |
++ nh_16(dctx->partial_words, tctx->nhkey, n / 8, rh, rl); |
868 |
++ rh &= m62; |
869 |
++ if (dctx->first_block_processed) |
870 |
++ poly_step(ch, cl, tctx->polykey[0], tctx->polykey[1], |
871 |
++ rh, rl); |
872 |
++ else |
873 |
++ ADD128(ch, cl, rh, rl); |
874 |
+ } |
875 |
+- mac = vmac(ctx->partial, ctx->partial_size, nonce, NULL, ctx); |
876 |
+- memcpy(out, &mac, sizeof(vmac_t)); |
877 |
+- memzero_explicit(&mac, sizeof(vmac_t)); |
878 |
+- memset(&ctx->__vmac_ctx, 0, sizeof(struct vmac_ctx)); |
879 |
+- ctx->partial_size = 0; |
880 |
++ |
881 |
++ /* L3-hash the 128-bit output of L2-hash */ |
882 |
++ return l3hash(ch, cl, tctx->l3key[0], tctx->l3key[1], partial * 8); |
883 |
++} |
884 |
++ |
885 |
++static int vmac_final(struct shash_desc *desc, u8 *out) |
886 |
++{ |
887 |
++ const struct vmac_tfm_ctx *tctx = crypto_shash_ctx(desc->tfm); |
888 |
++ struct vmac_desc_ctx *dctx = shash_desc_ctx(desc); |
889 |
++ static const u8 nonce[16] = {}; /* TODO: this is insecure */ |
890 |
++ union { |
891 |
++ u8 bytes[16]; |
892 |
++ __be64 pads[2]; |
893 |
++ } block; |
894 |
++ int index; |
895 |
++ u64 hash, pad; |
896 |
++ |
897 |
++ /* Finish calculating the VHASH of the message */ |
898 |
++ hash = vhash_final(tctx, dctx); |
899 |
++ |
900 |
++ /* Generate pseudorandom pad by encrypting the nonce */ |
901 |
++ memcpy(&block, nonce, 16); |
902 |
++ index = block.bytes[15] & 1; |
903 |
++ block.bytes[15] &= ~1; |
904 |
++ crypto_cipher_encrypt_one(tctx->cipher, block.bytes, block.bytes); |
905 |
++ pad = be64_to_cpu(block.pads[index]); |
906 |
++ |
907 |
++ /* The VMAC is the sum of VHASH and the pseudorandom pad */ |
908 |
++ put_unaligned_le64(hash + pad, out); |
909 |
+ return 0; |
910 |
+ } |
911 |
+ |
912 |
+ static int vmac_init_tfm(struct crypto_tfm *tfm) |
913 |
+ { |
914 |
+- struct crypto_cipher *cipher; |
915 |
+- struct crypto_instance *inst = (void *)tfm->__crt_alg; |
916 |
++ struct crypto_instance *inst = crypto_tfm_alg_instance(tfm); |
917 |
+ struct crypto_spawn *spawn = crypto_instance_ctx(inst); |
918 |
+- struct vmac_ctx_t *ctx = crypto_tfm_ctx(tfm); |
919 |
++ struct vmac_tfm_ctx *tctx = crypto_tfm_ctx(tfm); |
920 |
++ struct crypto_cipher *cipher; |
921 |
+ |
922 |
+ cipher = crypto_spawn_cipher(spawn); |
923 |
+ if (IS_ERR(cipher)) |
924 |
+ return PTR_ERR(cipher); |
925 |
+ |
926 |
+- ctx->child = cipher; |
927 |
++ tctx->cipher = cipher; |
928 |
+ return 0; |
929 |
+ } |
930 |
+ |
931 |
+ static void vmac_exit_tfm(struct crypto_tfm *tfm) |
932 |
+ { |
933 |
+- struct vmac_ctx_t *ctx = crypto_tfm_ctx(tfm); |
934 |
+- crypto_free_cipher(ctx->child); |
935 |
++ struct vmac_tfm_ctx *tctx = crypto_tfm_ctx(tfm); |
936 |
++ |
937 |
++ crypto_free_cipher(tctx->cipher); |
938 |
+ } |
939 |
+ |
940 |
+ static int vmac_create(struct crypto_template *tmpl, struct rtattr **tb) |
941 |
+@@ -655,6 +608,10 @@ static int vmac_create(struct crypto_template *tmpl, struct rtattr **tb) |
942 |
+ if (IS_ERR(alg)) |
943 |
+ return PTR_ERR(alg); |
944 |
+ |
945 |
++ err = -EINVAL; |
946 |
++ if (alg->cra_blocksize != 16) |
947 |
++ goto out_put_alg; |
948 |
++ |
949 |
+ inst = shash_alloc_instance("vmac", alg); |
950 |
+ err = PTR_ERR(inst); |
951 |
+ if (IS_ERR(inst)) |
952 |
+@@ -670,11 +627,12 @@ static int vmac_create(struct crypto_template *tmpl, struct rtattr **tb) |
953 |
+ inst->alg.base.cra_blocksize = alg->cra_blocksize; |
954 |
+ inst->alg.base.cra_alignmask = alg->cra_alignmask; |
955 |
+ |
956 |
+- inst->alg.digestsize = sizeof(vmac_t); |
957 |
+- inst->alg.base.cra_ctxsize = sizeof(struct vmac_ctx_t); |
958 |
++ inst->alg.base.cra_ctxsize = sizeof(struct vmac_tfm_ctx); |
959 |
+ inst->alg.base.cra_init = vmac_init_tfm; |
960 |
+ inst->alg.base.cra_exit = vmac_exit_tfm; |
961 |
+ |
962 |
++ inst->alg.descsize = sizeof(struct vmac_desc_ctx); |
963 |
++ inst->alg.digestsize = VMAC_TAG_LEN / 8; |
964 |
+ inst->alg.init = vmac_init; |
965 |
+ inst->alg.update = vmac_update; |
966 |
+ inst->alg.final = vmac_final; |
967 |
+diff --git a/drivers/i2c/busses/i2c-ismt.c b/drivers/i2c/busses/i2c-ismt.c |
968 |
+index 1111cb966a44..fa2b58142cde 100644 |
969 |
+--- a/drivers/i2c/busses/i2c-ismt.c |
970 |
++++ b/drivers/i2c/busses/i2c-ismt.c |
971 |
+@@ -587,7 +587,7 @@ static int ismt_access(struct i2c_adapter *adap, u16 addr, |
972 |
+ |
973 |
+ /* unmap the data buffer */ |
974 |
+ if (dma_size != 0) |
975 |
+- dma_unmap_single(&adap->dev, dma_addr, dma_size, dma_direction); |
976 |
++ dma_unmap_single(dev, dma_addr, dma_size, dma_direction); |
977 |
+ |
978 |
+ if (unlikely(!time_left)) { |
979 |
+ dev_err(dev, "completion wait timed out\n"); |
980 |
+diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h |
981 |
+index dabecb661264..53a47d75cc43 100644 |
982 |
+--- a/include/asm-generic/pgtable.h |
983 |
++++ b/include/asm-generic/pgtable.h |
984 |
+@@ -770,8 +770,8 @@ int pud_set_huge(pud_t *pud, phys_addr_t addr, pgprot_t prot); |
985 |
+ int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot); |
986 |
+ int pud_clear_huge(pud_t *pud); |
987 |
+ int pmd_clear_huge(pmd_t *pmd); |
988 |
+-int pud_free_pmd_page(pud_t *pud); |
989 |
+-int pmd_free_pte_page(pmd_t *pmd); |
990 |
++int pud_free_pmd_page(pud_t *pud, unsigned long addr); |
991 |
++int pmd_free_pte_page(pmd_t *pmd, unsigned long addr); |
992 |
+ #else /* !CONFIG_HAVE_ARCH_HUGE_VMAP */ |
993 |
+ static inline int pud_set_huge(pud_t *pud, phys_addr_t addr, pgprot_t prot) |
994 |
+ { |
995 |
+@@ -789,11 +789,11 @@ static inline int pmd_clear_huge(pmd_t *pmd) |
996 |
+ { |
997 |
+ return 0; |
998 |
+ } |
999 |
+-static inline int pud_free_pmd_page(pud_t *pud) |
1000 |
++static inline int pud_free_pmd_page(pud_t *pud, unsigned long addr) |
1001 |
+ { |
1002 |
+ return 0; |
1003 |
+ } |
1004 |
+-static inline int pmd_free_pte_page(pmd_t *pmd) |
1005 |
++static inline int pmd_free_pte_page(pmd_t *pmd, unsigned long addr) |
1006 |
+ { |
1007 |
+ return 0; |
1008 |
+ } |
1009 |
+diff --git a/include/crypto/vmac.h b/include/crypto/vmac.h |
1010 |
+deleted file mode 100644 |
1011 |
+index 6b700c7b2fe1..000000000000 |
1012 |
+--- a/include/crypto/vmac.h |
1013 |
++++ /dev/null |
1014 |
+@@ -1,63 +0,0 @@ |
1015 |
+-/* |
1016 |
+- * Modified to interface to the Linux kernel |
1017 |
+- * Copyright (c) 2009, Intel Corporation. |
1018 |
+- * |
1019 |
+- * This program is free software; you can redistribute it and/or modify it |
1020 |
+- * under the terms and conditions of the GNU General Public License, |
1021 |
+- * version 2, as published by the Free Software Foundation. |
1022 |
+- * |
1023 |
+- * This program is distributed in the hope it will be useful, but WITHOUT |
1024 |
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1025 |
+- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
1026 |
+- * more details. |
1027 |
+- * |
1028 |
+- * You should have received a copy of the GNU General Public License along with |
1029 |
+- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
1030 |
+- * Place - Suite 330, Boston, MA 02111-1307 USA. |
1031 |
+- */ |
1032 |
+- |
1033 |
+-#ifndef __CRYPTO_VMAC_H |
1034 |
+-#define __CRYPTO_VMAC_H |
1035 |
+- |
1036 |
+-/* -------------------------------------------------------------------------- |
1037 |
+- * VMAC and VHASH Implementation by Ted Krovetz (tdk@×××.org) and Wei Dai. |
1038 |
+- * This implementation is herby placed in the public domain. |
1039 |
+- * The authors offers no warranty. Use at your own risk. |
1040 |
+- * Please send bug reports to the authors. |
1041 |
+- * Last modified: 17 APR 08, 1700 PDT |
1042 |
+- * ----------------------------------------------------------------------- */ |
1043 |
+- |
1044 |
+-/* |
1045 |
+- * User definable settings. |
1046 |
+- */ |
1047 |
+-#define VMAC_TAG_LEN 64 |
1048 |
+-#define VMAC_KEY_SIZE 128/* Must be 128, 192 or 256 */ |
1049 |
+-#define VMAC_KEY_LEN (VMAC_KEY_SIZE/8) |
1050 |
+-#define VMAC_NHBYTES 128/* Must 2^i for any 3 < i < 13 Standard = 128*/ |
1051 |
+- |
1052 |
+-/* |
1053 |
+- * This implementation uses u32 and u64 as names for unsigned 32- |
1054 |
+- * and 64-bit integer types. These are defined in C99 stdint.h. The |
1055 |
+- * following may need adaptation if you are not running a C99 or |
1056 |
+- * Microsoft C environment. |
1057 |
+- */ |
1058 |
+-struct vmac_ctx { |
1059 |
+- u64 nhkey[(VMAC_NHBYTES/8)+2*(VMAC_TAG_LEN/64-1)]; |
1060 |
+- u64 polykey[2*VMAC_TAG_LEN/64]; |
1061 |
+- u64 l3key[2*VMAC_TAG_LEN/64]; |
1062 |
+- u64 polytmp[2*VMAC_TAG_LEN/64]; |
1063 |
+- u64 cached_nonce[2]; |
1064 |
+- u64 cached_aes[2]; |
1065 |
+- int first_block_processed; |
1066 |
+-}; |
1067 |
+- |
1068 |
+-typedef u64 vmac_t; |
1069 |
+- |
1070 |
+-struct vmac_ctx_t { |
1071 |
+- struct crypto_cipher *child; |
1072 |
+- struct vmac_ctx __vmac_ctx; |
1073 |
+- u8 partial[VMAC_NHBYTES]; /* partial block */ |
1074 |
+- int partial_size; /* size of the partial block */ |
1075 |
+-}; |
1076 |
+- |
1077 |
+-#endif /* __CRYPTO_VMAC_H */ |
1078 |
+diff --git a/lib/ioremap.c b/lib/ioremap.c |
1079 |
+index 5323b59ca393..b9462037868d 100644 |
1080 |
+--- a/lib/ioremap.c |
1081 |
++++ b/lib/ioremap.c |
1082 |
+@@ -84,7 +84,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr, |
1083 |
+ if (ioremap_pmd_enabled() && |
1084 |
+ ((next - addr) == PMD_SIZE) && |
1085 |
+ IS_ALIGNED(phys_addr + addr, PMD_SIZE) && |
1086 |
+- pmd_free_pte_page(pmd)) { |
1087 |
++ pmd_free_pte_page(pmd, addr)) { |
1088 |
+ if (pmd_set_huge(pmd, phys_addr + addr, prot)) |
1089 |
+ continue; |
1090 |
+ } |
1091 |
+@@ -111,7 +111,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr, |
1092 |
+ if (ioremap_pud_enabled() && |
1093 |
+ ((next - addr) == PUD_SIZE) && |
1094 |
+ IS_ALIGNED(phys_addr + addr, PUD_SIZE) && |
1095 |
+- pud_free_pmd_page(pud)) { |
1096 |
++ pud_free_pmd_page(pud, addr)) { |
1097 |
+ if (pud_set_huge(pud, phys_addr + addr, prot)) |
1098 |
+ continue; |
1099 |
+ } |
1100 |
+diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c |
1101 |
+index 1fc076420d1e..1811f8e7ddf4 100644 |
1102 |
+--- a/net/bluetooth/hidp/core.c |
1103 |
++++ b/net/bluetooth/hidp/core.c |
1104 |
+@@ -431,8 +431,8 @@ static void hidp_del_timer(struct hidp_session *session) |
1105 |
+ del_timer(&session->timer); |
1106 |
+ } |
1107 |
+ |
1108 |
+-static void hidp_process_report(struct hidp_session *session, |
1109 |
+- int type, const u8 *data, int len, int intr) |
1110 |
++static void hidp_process_report(struct hidp_session *session, int type, |
1111 |
++ const u8 *data, unsigned int len, int intr) |
1112 |
+ { |
1113 |
+ if (len > HID_MAX_BUFFER_SIZE) |
1114 |
+ len = HID_MAX_BUFFER_SIZE; |
1115 |
+diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c |
1116 |
+index 4a261e078082..9c4c6cd0316e 100644 |
1117 |
+--- a/net/ipv4/tcp_input.c |
1118 |
++++ b/net/ipv4/tcp_input.c |
1119 |
+@@ -4835,6 +4835,7 @@ static void tcp_collapse_ofo_queue(struct sock *sk) |
1120 |
+ end = TCP_SKB_CB(skb)->end_seq; |
1121 |
+ range_truesize = skb->truesize; |
1122 |
+ } else { |
1123 |
++ range_truesize += skb->truesize; |
1124 |
+ if (before(TCP_SKB_CB(skb)->seq, start)) |
1125 |
+ start = TCP_SKB_CB(skb)->seq; |
1126 |
+ if (after(TCP_SKB_CB(skb)->end_seq, end)) |
1127 |
+diff --git a/scripts/Makefile.kasan b/scripts/Makefile.kasan |
1128 |
+index 37323b0df374..2624d4bf9a45 100644 |
1129 |
+--- a/scripts/Makefile.kasan |
1130 |
++++ b/scripts/Makefile.kasan |
1131 |
+@@ -28,4 +28,7 @@ else |
1132 |
+ CFLAGS_KASAN := $(CFLAGS_KASAN_MINIMAL) |
1133 |
+ endif |
1134 |
+ endif |
1135 |
++ |
1136 |
++CFLAGS_KASAN_NOSANITIZE := -fno-builtin |
1137 |
++ |
1138 |
+ endif |
1139 |
+diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib |
1140 |
+index 24914e7de944..a2d0e6d32659 100644 |
1141 |
+--- a/scripts/Makefile.lib |
1142 |
++++ b/scripts/Makefile.lib |
1143 |
+@@ -126,7 +126,7 @@ endif |
1144 |
+ ifeq ($(CONFIG_KASAN),y) |
1145 |
+ _c_flags += $(if $(patsubst n%,, \ |
1146 |
+ $(KASAN_SANITIZE_$(basetarget).o)$(KASAN_SANITIZE)y), \ |
1147 |
+- $(CFLAGS_KASAN)) |
1148 |
++ $(CFLAGS_KASAN), $(CFLAGS_KASAN_NOSANITIZE)) |
1149 |
+ endif |
1150 |
+ |
1151 |
+ # If building the kernel in a separate objtree expand all occurrences |
1152 |
+diff --git a/scripts/depmod.sh b/scripts/depmod.sh |
1153 |
+index 122599b1c13b..ea1e96921e3b 100755 |
1154 |
+--- a/scripts/depmod.sh |
1155 |
++++ b/scripts/depmod.sh |
1156 |
+@@ -10,10 +10,16 @@ DEPMOD=$1 |
1157 |
+ KERNELRELEASE=$2 |
1158 |
+ SYMBOL_PREFIX=$3 |
1159 |
+ |
1160 |
+-if ! test -r System.map -a -x "$DEPMOD"; then |
1161 |
++if ! test -r System.map ; then |
1162 |
+ exit 0 |
1163 |
+ fi |
1164 |
+ |
1165 |
++if [ -z $(command -v $DEPMOD) ]; then |
1166 |
++ echo "'make modules_install' requires $DEPMOD. Please install it." >&2 |
1167 |
++ echo "This is probably in the kmod package." >&2 |
1168 |
++ exit 1 |
1169 |
++fi |
1170 |
++ |
1171 |
+ # older versions of depmod don't support -P <symbol-prefix> |
1172 |
+ # support was added in module-init-tools 3.13 |
1173 |
+ if test -n "$SYMBOL_PREFIX"; then |
1174 |
+diff --git a/sound/soc/intel/boards/cht_bsw_max98090_ti.c b/sound/soc/intel/boards/cht_bsw_max98090_ti.c |
1175 |
+index 4e2fcf188dd1..01a573a063d1 100644 |
1176 |
+--- a/sound/soc/intel/boards/cht_bsw_max98090_ti.c |
1177 |
++++ b/sound/soc/intel/boards/cht_bsw_max98090_ti.c |
1178 |
+@@ -131,23 +131,19 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime) |
1179 |
+ struct cht_mc_private *ctx = snd_soc_card_get_drvdata(runtime->card); |
1180 |
+ struct snd_soc_jack *jack = &ctx->jack; |
1181 |
+ |
1182 |
+- /** |
1183 |
+- * TI supports 4 butons headset detection |
1184 |
+- * KEY_MEDIA |
1185 |
+- * KEY_VOICECOMMAND |
1186 |
+- * KEY_VOLUMEUP |
1187 |
+- * KEY_VOLUMEDOWN |
1188 |
+- */ |
1189 |
+- if (ctx->ts3a227e_present) |
1190 |
+- jack_type = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE | |
1191 |
+- SND_JACK_BTN_0 | SND_JACK_BTN_1 | |
1192 |
+- SND_JACK_BTN_2 | SND_JACK_BTN_3; |
1193 |
+- else |
1194 |
+- jack_type = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE; |
1195 |
++ if (ctx->ts3a227e_present) { |
1196 |
++ /* |
1197 |
++ * The jack has already been created in the |
1198 |
++ * cht_max98090_headset_init() function. |
1199 |
++ */ |
1200 |
++ snd_soc_jack_notifier_register(jack, &cht_jack_nb); |
1201 |
++ return 0; |
1202 |
++ } |
1203 |
++ |
1204 |
++ jack_type = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE; |
1205 |
+ |
1206 |
+ ret = snd_soc_card_jack_new(runtime->card, "Headset Jack", |
1207 |
+ jack_type, jack, NULL, 0); |
1208 |
+- |
1209 |
+ if (ret) { |
1210 |
+ dev_err(runtime->dev, "Headset Jack creation failed %d\n", ret); |
1211 |
+ return ret; |
1212 |
+@@ -203,6 +199,27 @@ static int cht_max98090_headset_init(struct snd_soc_component *component) |
1213 |
+ { |
1214 |
+ struct snd_soc_card *card = component->card; |
1215 |
+ struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card); |
1216 |
++ struct snd_soc_jack *jack = &ctx->jack; |
1217 |
++ int jack_type; |
1218 |
++ int ret; |
1219 |
++ |
1220 |
++ /* |
1221 |
++ * TI supports 4 butons headset detection |
1222 |
++ * KEY_MEDIA |
1223 |
++ * KEY_VOICECOMMAND |
1224 |
++ * KEY_VOLUMEUP |
1225 |
++ * KEY_VOLUMEDOWN |
1226 |
++ */ |
1227 |
++ jack_type = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE | |
1228 |
++ SND_JACK_BTN_0 | SND_JACK_BTN_1 | |
1229 |
++ SND_JACK_BTN_2 | SND_JACK_BTN_3; |
1230 |
++ |
1231 |
++ ret = snd_soc_card_jack_new(card, "Headset Jack", jack_type, |
1232 |
++ jack, NULL, 0); |
1233 |
++ if (ret) { |
1234 |
++ dev_err(card->dev, "Headset Jack creation failed %d\n", ret); |
1235 |
++ return ret; |
1236 |
++ } |
1237 |
+ |
1238 |
+ return ts3a227e_enable_jack_detect(component, &ctx->jack); |
1239 |
+ } |