Commit d1909c0
module: Don't ignore errors from set_memory_XX()
set_memory_ro(), set_memory_nx(), set_memory_x() and other helpers
can fail and return an error. In that case the memory might not be
protected as expected and the module loading has to be aborted to
avoid security issues.
Check return value of all calls to set_memory_XX() and handle
error if any.
Add a check to not call set_memory_XX() on NULL pointers as some
architectures may not like it allthough numpages is always 0 in that
case. This also avoid a useless call to set_vm_flush_reset_perms().
Link: KSPP#7
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>1 parent 1572853 commit d1909c0
3 files changed
+55
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
322 | 322 | | |
323 | 323 | | |
324 | 324 | | |
325 | | - | |
326 | | - | |
327 | | - | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
328 | 328 | | |
329 | 329 | | |
330 | 330 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2571 | 2571 | | |
2572 | 2572 | | |
2573 | 2573 | | |
2574 | | - | |
| 2574 | + | |
| 2575 | + | |
| 2576 | + | |
2575 | 2577 | | |
2576 | 2578 | | |
2577 | 2579 | | |
| |||
2609 | 2611 | | |
2610 | 2612 | | |
2611 | 2613 | | |
| 2614 | + | |
| 2615 | + | |
2612 | 2616 | | |
2613 | 2617 | | |
2614 | 2618 | | |
| |||
2736 | 2740 | | |
2737 | 2741 | | |
2738 | 2742 | | |
2739 | | - | |
2740 | | - | |
2741 | | - | |
| 2743 | + | |
| 2744 | + | |
| 2745 | + | |
| 2746 | + | |
| 2747 | + | |
| 2748 | + | |
| 2749 | + | |
| 2750 | + | |
| 2751 | + | |
2742 | 2752 | | |
2743 | 2753 | | |
2744 | 2754 | | |
| |||
2749 | 2759 | | |
2750 | 2760 | | |
2751 | 2761 | | |
| 2762 | + | |
| 2763 | + | |
2752 | 2764 | | |
2753 | 2765 | | |
2754 | 2766 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
| 14 | + | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
19 | 22 | | |
20 | | - | |
| 23 | + | |
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
| |||
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
29 | | - | |
| 32 | + | |
30 | 33 | | |
31 | 34 | | |
| 35 | + | |
| 36 | + | |
32 | 37 | | |
33 | | - | |
| 38 | + | |
34 | 39 | | |
35 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
36 | 43 | | |
| 44 | + | |
37 | 45 | | |
38 | 46 | | |
39 | | - | |
| 47 | + | |
40 | 48 | | |
| 49 | + | |
| 50 | + | |
41 | 51 | | |
42 | | - | |
| 52 | + | |
43 | 53 | | |
44 | | - | |
45 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
46 | 60 | | |
47 | 61 | | |
48 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
49 | 65 | | |
50 | 66 | | |
51 | | - | |
| 67 | + | |
52 | 68 | | |
53 | 69 | | |
54 | | - | |
| 70 | + | |
55 | 71 | | |
56 | | - | |
57 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
58 | 79 | | |
59 | 80 | | |
60 | 81 | | |
| |||
0 commit comments