Gentoo Archives: gentoo-commits

From: Alice Ferrazzi <alicef@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.4 commit in: /
Date: Tue, 01 Nov 2016 03:15:02
Message-Id: 1477970042.69a7525da9273507079df4501f998d2a743fb1b2.alicef@gentoo
1 commit: 69a7525da9273507079df4501f998d2a743fb1b2
2 Author: Alice Ferrazzi <alicef <AT> gentoo <DOT> org>
3 AuthorDate: Tue Nov 1 03:14:02 2016 +0000
4 Commit: Alice Ferrazzi <alicef <AT> gentoo <DOT> org>
5 CommitDate: Tue Nov 1 03:14:02 2016 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=69a7525d
7
8 Linux patch 4.4.30
9
10 0000_README | 4 +
11 1029_linux-4.4.30.patch | 434 ++++++++++++++++++++++++++++++++++++++++++++++++
12 2 files changed, 438 insertions(+)
13
14 diff --git a/0000_README b/0000_README
15 index de6d5fd..3d770fc 100644
16 --- a/0000_README
17 +++ b/0000_README
18 @@ -159,6 +159,10 @@ Patch: 1028_linux-4.4.29.patch
19 From: http://www.kernel.org
20 Desc: Linux 4.4.29
21
22 +Patch: 1029_linux-4.4.30.patch
23 +From: http://www.kernel.org
24 +Desc: Linux 4.4.30
25 +
26 Patch: 1500_XATTR_USER_PREFIX.patch
27 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
28 Desc: Support for namespace user.pax.* on tmpfs.
29
30 diff --git a/1029_linux-4.4.30.patch b/1029_linux-4.4.30.patch
31 new file mode 100644
32 index 0000000..e19a680
33 --- /dev/null
34 +++ b/1029_linux-4.4.30.patch
35 @@ -0,0 +1,434 @@
36 +diff --git a/Documentation/x86/exception-tables.txt b/Documentation/x86/exception-tables.txt
37 +index e396bcd8d830..32901aa36f0a 100644
38 +--- a/Documentation/x86/exception-tables.txt
39 ++++ b/Documentation/x86/exception-tables.txt
40 +@@ -290,38 +290,3 @@ Due to the way that the exception table is built and needs to be ordered,
41 + only use exceptions for code in the .text section. Any other section
42 + will cause the exception table to not be sorted correctly, and the
43 + exceptions will fail.
44 +-
45 +-Things changed when 64-bit support was added to x86 Linux. Rather than
46 +-double the size of the exception table by expanding the two entries
47 +-from 32-bits to 64 bits, a clever trick was used to store addresses
48 +-as relative offsets from the table itself. The assembly code changed
49 +-from:
50 +- .long 1b,3b
51 +-to:
52 +- .long (from) - .
53 +- .long (to) - .
54 +-
55 +-and the C-code that uses these values converts back to absolute addresses
56 +-like this:
57 +-
58 +- ex_insn_addr(const struct exception_table_entry *x)
59 +- {
60 +- return (unsigned long)&x->insn + x->insn;
61 +- }
62 +-
63 +-In v4.6 the exception table entry was expanded with a new field "handler".
64 +-This is also 32-bits wide and contains a third relative function
65 +-pointer which points to one of:
66 +-
67 +-1) int ex_handler_default(const struct exception_table_entry *fixup)
68 +- This is legacy case that just jumps to the fixup code
69 +-2) int ex_handler_fault(const struct exception_table_entry *fixup)
70 +- This case provides the fault number of the trap that occurred at
71 +- entry->insn. It is used to distinguish page faults from machine
72 +- check.
73 +-3) int ex_handler_ext(const struct exception_table_entry *fixup)
74 +- This case is used for uaccess_err ... we need to set a flag
75 +- in the task structure. Before the handler functions existed this
76 +- case was handled by adding a large offset to the fixup to tag
77 +- it as special.
78 +-More functions can easily be added.
79 +diff --git a/Makefile b/Makefile
80 +index 19d7d9f68e35..98239d56924c 100644
81 +--- a/Makefile
82 ++++ b/Makefile
83 +@@ -1,6 +1,6 @@
84 + VERSION = 4
85 + PATCHLEVEL = 4
86 +-SUBLEVEL = 29
87 ++SUBLEVEL = 30
88 + EXTRAVERSION =
89 + NAME = Blurry Fish Butt
90 +
91 +diff --git a/arch/x86/include/asm/asm.h b/arch/x86/include/asm/asm.h
92 +index f5063b6659eb..189679aba703 100644
93 +--- a/arch/x86/include/asm/asm.h
94 ++++ b/arch/x86/include/asm/asm.h
95 +@@ -44,22 +44,19 @@
96 +
97 + /* Exception table entry */
98 + #ifdef __ASSEMBLY__
99 +-# define _ASM_EXTABLE_HANDLE(from, to, handler) \
100 ++# define _ASM_EXTABLE(from,to) \
101 + .pushsection "__ex_table","a" ; \
102 +- .balign 4 ; \
103 ++ .balign 8 ; \
104 + .long (from) - . ; \
105 + .long (to) - . ; \
106 +- .long (handler) - . ; \
107 + .popsection
108 +
109 +-# define _ASM_EXTABLE(from, to) \
110 +- _ASM_EXTABLE_HANDLE(from, to, ex_handler_default)
111 +-
112 +-# define _ASM_EXTABLE_FAULT(from, to) \
113 +- _ASM_EXTABLE_HANDLE(from, to, ex_handler_fault)
114 +-
115 +-# define _ASM_EXTABLE_EX(from, to) \
116 +- _ASM_EXTABLE_HANDLE(from, to, ex_handler_ext)
117 ++# define _ASM_EXTABLE_EX(from,to) \
118 ++ .pushsection "__ex_table","a" ; \
119 ++ .balign 8 ; \
120 ++ .long (from) - . ; \
121 ++ .long (to) - . + 0x7ffffff0 ; \
122 ++ .popsection
123 +
124 + # define _ASM_NOKPROBE(entry) \
125 + .pushsection "_kprobe_blacklist","aw" ; \
126 +@@ -92,24 +89,19 @@
127 + .endm
128 +
129 + #else
130 +-# define _EXPAND_EXTABLE_HANDLE(x) #x
131 +-# define _ASM_EXTABLE_HANDLE(from, to, handler) \
132 ++# define _ASM_EXTABLE(from,to) \
133 + " .pushsection \"__ex_table\",\"a\"\n" \
134 +- " .balign 4\n" \
135 ++ " .balign 8\n" \
136 + " .long (" #from ") - .\n" \
137 + " .long (" #to ") - .\n" \
138 +- " .long (" _EXPAND_EXTABLE_HANDLE(handler) ") - .\n" \
139 + " .popsection\n"
140 +
141 +-# define _ASM_EXTABLE(from, to) \
142 +- _ASM_EXTABLE_HANDLE(from, to, ex_handler_default)
143 +-
144 +-# define _ASM_EXTABLE_FAULT(from, to) \
145 +- _ASM_EXTABLE_HANDLE(from, to, ex_handler_fault)
146 +-
147 +-# define _ASM_EXTABLE_EX(from, to) \
148 +- _ASM_EXTABLE_HANDLE(from, to, ex_handler_ext)
149 +-
150 ++# define _ASM_EXTABLE_EX(from,to) \
151 ++ " .pushsection \"__ex_table\",\"a\"\n" \
152 ++ " .balign 8\n" \
153 ++ " .long (" #from ") - .\n" \
154 ++ " .long (" #to ") - . + 0x7ffffff0\n" \
155 ++ " .popsection\n"
156 + /* For C file, we already have NOKPROBE_SYMBOL macro */
157 + #endif
158 +
159 +diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
160 +index 3794c7331cfc..09b1b0ab94b7 100644
161 +--- a/arch/x86/include/asm/uaccess.h
162 ++++ b/arch/x86/include/asm/uaccess.h
163 +@@ -90,11 +90,12 @@ static inline bool __chk_range_not_ok(unsigned long addr, unsigned long size, un
164 + likely(!__range_not_ok(addr, size, user_addr_max()))
165 +
166 + /*
167 +- * The exception table consists of triples of addresses relative to the
168 +- * exception table entry itself. The first address is of an instruction
169 +- * that is allowed to fault, the second is the target at which the program
170 +- * should continue. The third is a handler function to deal with the fault
171 +- * caused by the instruction in the first field.
172 ++ * The exception table consists of pairs of addresses relative to the
173 ++ * exception table enty itself: the first is the address of an
174 ++ * instruction that is allowed to fault, and the second is the address
175 ++ * at which the program should continue. No registers are modified,
176 ++ * so it is entirely up to the continuation code to figure out what to
177 ++ * do.
178 + *
179 + * All the routines below use bits of fixup code that are out of line
180 + * with the main instruction path. This means when everything is well,
181 +@@ -103,14 +104,13 @@ static inline bool __chk_range_not_ok(unsigned long addr, unsigned long size, un
182 + */
183 +
184 + struct exception_table_entry {
185 +- int insn, fixup, handler;
186 ++ int insn, fixup;
187 + };
188 + /* This is not the generic standard exception_table_entry format */
189 + #define ARCH_HAS_SORT_EXTABLE
190 + #define ARCH_HAS_SEARCH_EXTABLE
191 +
192 +-extern int fixup_exception(struct pt_regs *regs, int trapnr);
193 +-extern bool ex_has_fault_handler(unsigned long ip);
194 ++extern int fixup_exception(struct pt_regs *regs);
195 + extern int early_fixup_exception(unsigned long *ip);
196 +
197 + /*
198 +@@ -394,11 +394,7 @@ do { \
199 + #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
200 + asm volatile("1: mov"itype" %1,%"rtype"0\n" \
201 + "2:\n" \
202 +- ".section .fixup,\"ax\"\n" \
203 +- "3:xor"itype" %"rtype"0,%"rtype"0\n" \
204 +- " jmp 2b\n" \
205 +- ".previous\n" \
206 +- _ASM_EXTABLE_EX(1b, 3b) \
207 ++ _ASM_EXTABLE_EX(1b, 2b) \
208 + : ltype(x) : "m" (__m(addr)))
209 +
210 + #define __put_user_nocheck(x, ptr, size) \
211 +diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
212 +index e1d1f6cbaf11..023c442c33bb 100644
213 +--- a/arch/x86/kernel/kprobes/core.c
214 ++++ b/arch/x86/kernel/kprobes/core.c
215 +@@ -1000,7 +1000,7 @@ int kprobe_fault_handler(struct pt_regs *regs, int trapnr)
216 + * In case the user-specified fault handler returned
217 + * zero, try to fix up.
218 + */
219 +- if (fixup_exception(regs, trapnr))
220 ++ if (fixup_exception(regs))
221 + return 1;
222 +
223 + /*
224 +diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
225 +index 5621f882645e..679302c312f8 100644
226 +--- a/arch/x86/kernel/traps.c
227 ++++ b/arch/x86/kernel/traps.c
228 +@@ -199,7 +199,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
229 + }
230 +
231 + if (!user_mode(regs)) {
232 +- if (!fixup_exception(regs, trapnr)) {
233 ++ if (!fixup_exception(regs)) {
234 + tsk->thread.error_code = error_code;
235 + tsk->thread.trap_nr = trapnr;
236 + die(str, regs, error_code);
237 +@@ -453,7 +453,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
238 +
239 + tsk = current;
240 + if (!user_mode(regs)) {
241 +- if (fixup_exception(regs, X86_TRAP_GP))
242 ++ if (fixup_exception(regs))
243 + return;
244 +
245 + tsk->thread.error_code = error_code;
246 +@@ -699,7 +699,7 @@ static void math_error(struct pt_regs *regs, int error_code, int trapnr)
247 + conditional_sti(regs);
248 +
249 + if (!user_mode(regs)) {
250 +- if (!fixup_exception(regs, trapnr)) {
251 ++ if (!fixup_exception(regs)) {
252 + task->thread.error_code = error_code;
253 + task->thread.trap_nr = trapnr;
254 + die(str, regs, error_code);
255 +diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
256 +index 9dd7e4b7fcde..903ec1e9c326 100644
257 +--- a/arch/x86/mm/extable.c
258 ++++ b/arch/x86/mm/extable.c
259 +@@ -3,9 +3,6 @@
260 + #include <linux/sort.h>
261 + #include <asm/uaccess.h>
262 +
263 +-typedef bool (*ex_handler_t)(const struct exception_table_entry *,
264 +- struct pt_regs *, int);
265 +-
266 + static inline unsigned long
267 + ex_insn_addr(const struct exception_table_entry *x)
268 + {
269 +@@ -16,56 +13,11 @@ ex_fixup_addr(const struct exception_table_entry *x)
270 + {
271 + return (unsigned long)&x->fixup + x->fixup;
272 + }
273 +-static inline ex_handler_t
274 +-ex_fixup_handler(const struct exception_table_entry *x)
275 +-{
276 +- return (ex_handler_t)((unsigned long)&x->handler + x->handler);
277 +-}
278 +-
279 +-bool ex_handler_default(const struct exception_table_entry *fixup,
280 +- struct pt_regs *regs, int trapnr)
281 +-{
282 +- regs->ip = ex_fixup_addr(fixup);
283 +- return true;
284 +-}
285 +-EXPORT_SYMBOL(ex_handler_default);
286 +-
287 +-bool ex_handler_fault(const struct exception_table_entry *fixup,
288 +- struct pt_regs *regs, int trapnr)
289 +-{
290 +- regs->ip = ex_fixup_addr(fixup);
291 +- regs->ax = trapnr;
292 +- return true;
293 +-}
294 +-EXPORT_SYMBOL_GPL(ex_handler_fault);
295 +-
296 +-bool ex_handler_ext(const struct exception_table_entry *fixup,
297 +- struct pt_regs *regs, int trapnr)
298 +-{
299 +- /* Special hack for uaccess_err */
300 +- current_thread_info()->uaccess_err = 1;
301 +- regs->ip = ex_fixup_addr(fixup);
302 +- return true;
303 +-}
304 +-EXPORT_SYMBOL(ex_handler_ext);
305 +-
306 +-bool ex_has_fault_handler(unsigned long ip)
307 +-{
308 +- const struct exception_table_entry *e;
309 +- ex_handler_t handler;
310 +-
311 +- e = search_exception_tables(ip);
312 +- if (!e)
313 +- return false;
314 +- handler = ex_fixup_handler(e);
315 +-
316 +- return handler == ex_handler_fault;
317 +-}
318 +
319 +-int fixup_exception(struct pt_regs *regs, int trapnr)
320 ++int fixup_exception(struct pt_regs *regs)
321 + {
322 +- const struct exception_table_entry *e;
323 +- ex_handler_t handler;
324 ++ const struct exception_table_entry *fixup;
325 ++ unsigned long new_ip;
326 +
327 + #ifdef CONFIG_PNPBIOS
328 + if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
329 +@@ -81,34 +33,42 @@ int fixup_exception(struct pt_regs *regs, int trapnr)
330 + }
331 + #endif
332 +
333 +- e = search_exception_tables(regs->ip);
334 +- if (!e)
335 +- return 0;
336 ++ fixup = search_exception_tables(regs->ip);
337 ++ if (fixup) {
338 ++ new_ip = ex_fixup_addr(fixup);
339 ++
340 ++ if (fixup->fixup - fixup->insn >= 0x7ffffff0 - 4) {
341 ++ /* Special hack for uaccess_err */
342 ++ current_thread_info()->uaccess_err = 1;
343 ++ new_ip -= 0x7ffffff0;
344 ++ }
345 ++ regs->ip = new_ip;
346 ++ return 1;
347 ++ }
348 +
349 +- handler = ex_fixup_handler(e);
350 +- return handler(e, regs, trapnr);
351 ++ return 0;
352 + }
353 +
354 + /* Restricted version used during very early boot */
355 + int __init early_fixup_exception(unsigned long *ip)
356 + {
357 +- const struct exception_table_entry *e;
358 ++ const struct exception_table_entry *fixup;
359 + unsigned long new_ip;
360 +- ex_handler_t handler;
361 +
362 +- e = search_exception_tables(*ip);
363 +- if (!e)
364 +- return 0;
365 ++ fixup = search_exception_tables(*ip);
366 ++ if (fixup) {
367 ++ new_ip = ex_fixup_addr(fixup);
368 +
369 +- new_ip = ex_fixup_addr(e);
370 +- handler = ex_fixup_handler(e);
371 ++ if (fixup->fixup - fixup->insn >= 0x7ffffff0 - 4) {
372 ++ /* uaccess handling not supported during early boot */
373 ++ return 0;
374 ++ }
375 +
376 +- /* special handling not supported during early boot */
377 +- if (handler != ex_handler_default)
378 +- return 0;
379 ++ *ip = new_ip;
380 ++ return 1;
381 ++ }
382 +
383 +- *ip = new_ip;
384 +- return 1;
385 ++ return 0;
386 + }
387 +
388 + /*
389 +@@ -173,8 +133,6 @@ void sort_extable(struct exception_table_entry *start,
390 + i += 4;
391 + p->fixup += i;
392 + i += 4;
393 +- p->handler += i;
394 +- i += 4;
395 + }
396 +
397 + sort(start, finish - start, sizeof(struct exception_table_entry),
398 +@@ -187,8 +145,6 @@ void sort_extable(struct exception_table_entry *start,
399 + i += 4;
400 + p->fixup -= i;
401 + i += 4;
402 +- p->handler -= i;
403 +- i += 4;
404 + }
405 + }
406 +
407 +diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
408 +index 03898aea6e0f..e830c71a1323 100644
409 +--- a/arch/x86/mm/fault.c
410 ++++ b/arch/x86/mm/fault.c
411 +@@ -663,7 +663,7 @@ no_context(struct pt_regs *regs, unsigned long error_code,
412 + int sig;
413 +
414 + /* Are we prepared to handle this kernel fault? */
415 +- if (fixup_exception(regs, X86_TRAP_PF)) {
416 ++ if (fixup_exception(regs)) {
417 + /*
418 + * Any interrupt that takes a fault gets the fixup. This makes
419 + * the below recursive fault logic only apply to a faults from
420 +diff --git a/scripts/sortextable.c b/scripts/sortextable.c
421 +index 7b29fb14f870..c2423d913b46 100644
422 +--- a/scripts/sortextable.c
423 ++++ b/scripts/sortextable.c
424 +@@ -209,35 +209,6 @@ static int compare_relative_table(const void *a, const void *b)
425 + return 0;
426 + }
427 +
428 +-static void x86_sort_relative_table(char *extab_image, int image_size)
429 +-{
430 +- int i;
431 +-
432 +- i = 0;
433 +- while (i < image_size) {
434 +- uint32_t *loc = (uint32_t *)(extab_image + i);
435 +-
436 +- w(r(loc) + i, loc);
437 +- w(r(loc + 1) + i + 4, loc + 1);
438 +- w(r(loc + 2) + i + 8, loc + 2);
439 +-
440 +- i += sizeof(uint32_t) * 3;
441 +- }
442 +-
443 +- qsort(extab_image, image_size / 12, 12, compare_relative_table);
444 +-
445 +- i = 0;
446 +- while (i < image_size) {
447 +- uint32_t *loc = (uint32_t *)(extab_image + i);
448 +-
449 +- w(r(loc) - i, loc);
450 +- w(r(loc + 1) - (i + 4), loc + 1);
451 +- w(r(loc + 2) - (i + 8), loc + 2);
452 +-
453 +- i += sizeof(uint32_t) * 3;
454 +- }
455 +-}
456 +-
457 + static void sort_relative_table(char *extab_image, int image_size)
458 + {
459 + int i;
460 +@@ -310,9 +281,6 @@ do_file(char const *const fname)
461 + break;
462 + case EM_386:
463 + case EM_X86_64:
464 +- custom_sort = x86_sort_relative_table;
465 +- break;
466 +-
467 + case EM_S390:
468 + custom_sort = sort_relative_table;
469 + break;