aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2016-10-28 03:45:16 -0400
committerKees Cook <keescook@chromium.org>2017-06-30 15:00:52 -0400
commit8acdf5055974e49d337d51ac7011449cfd7b7d05 (patch)
tree6a2f0911e7eff74141bed50c2a5db94cd2bce577
parent29e48ce87f1eaaa4b1fe3d9af90c586ac2d1fb74 (diff)
randstruct: opt-out externally exposed function pointer structs
Some function pointer structures are used externally to the kernel, like the paravirt structures. These should never be randomized, so mark them as such, in preparation for enabling randstruct's automatic selection of all-function-pointer structures. These markings are verbatim from Brad Spengler/PaX Team's code in the last public patch of grsecurity/PaX based on my understanding of the code. Changes or omissions from the original code are mine and don't reflect the original grsecurity/PaX code. Signed-off-by: Kees Cook <keescook@chromium.org>
-rw-r--r--arch/arm/include/asm/cacheflush.h2
-rw-r--r--arch/x86/include/asm/paravirt_types.h16
2 files changed, 9 insertions, 9 deletions
diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
index d69bebf697e7..74504b154256 100644
--- a/arch/arm/include/asm/cacheflush.h
+++ b/arch/arm/include/asm/cacheflush.h
@@ -116,7 +116,7 @@ struct cpu_cache_fns {
116 void (*dma_unmap_area)(const void *, size_t, int); 116 void (*dma_unmap_area)(const void *, size_t, int);
117 117
118 void (*dma_flush_range)(const void *, const void *); 118 void (*dma_flush_range)(const void *, const void *);
119}; 119} __no_randomize_layout;
120 120
121/* 121/*
122 * Select the calling method 122 * Select the calling method
diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
index 7465d6fe336f..96c7e3cf43fa 100644
--- a/arch/x86/include/asm/paravirt_types.h
+++ b/arch/x86/include/asm/paravirt_types.h
@@ -83,7 +83,7 @@ struct pv_init_ops {
83 */ 83 */
84 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf, 84 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
85 unsigned long addr, unsigned len); 85 unsigned long addr, unsigned len);
86}; 86} __no_randomize_layout;
87 87
88 88
89struct pv_lazy_ops { 89struct pv_lazy_ops {
@@ -91,12 +91,12 @@ struct pv_lazy_ops {
91 void (*enter)(void); 91 void (*enter)(void);
92 void (*leave)(void); 92 void (*leave)(void);
93 void (*flush)(void); 93 void (*flush)(void);
94}; 94} __no_randomize_layout;
95 95
96struct pv_time_ops { 96struct pv_time_ops {
97 unsigned long long (*sched_clock)(void); 97 unsigned long long (*sched_clock)(void);
98 unsigned long long (*steal_clock)(int cpu); 98 unsigned long long (*steal_clock)(int cpu);
99}; 99} __no_randomize_layout;
100 100
101struct pv_cpu_ops { 101struct pv_cpu_ops {
102 /* hooks for various privileged instructions */ 102 /* hooks for various privileged instructions */
@@ -175,7 +175,7 @@ struct pv_cpu_ops {
175 175
176 void (*start_context_switch)(struct task_struct *prev); 176 void (*start_context_switch)(struct task_struct *prev);
177 void (*end_context_switch)(struct task_struct *next); 177 void (*end_context_switch)(struct task_struct *next);
178}; 178} __no_randomize_layout;
179 179
180struct pv_irq_ops { 180struct pv_irq_ops {
181 /* 181 /*
@@ -198,7 +198,7 @@ struct pv_irq_ops {
198#ifdef CONFIG_X86_64 198#ifdef CONFIG_X86_64
199 void (*adjust_exception_frame)(void); 199 void (*adjust_exception_frame)(void);
200#endif 200#endif
201}; 201} __no_randomize_layout;
202 202
203struct pv_mmu_ops { 203struct pv_mmu_ops {
204 unsigned long (*read_cr2)(void); 204 unsigned long (*read_cr2)(void);
@@ -306,7 +306,7 @@ struct pv_mmu_ops {
306 an mfn. We can tell which is which from the index. */ 306 an mfn. We can tell which is which from the index. */
307 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx, 307 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
308 phys_addr_t phys, pgprot_t flags); 308 phys_addr_t phys, pgprot_t flags);
309}; 309} __no_randomize_layout;
310 310
311struct arch_spinlock; 311struct arch_spinlock;
312#ifdef CONFIG_SMP 312#ifdef CONFIG_SMP
@@ -323,7 +323,7 @@ struct pv_lock_ops {
323 void (*kick)(int cpu); 323 void (*kick)(int cpu);
324 324
325 struct paravirt_callee_save vcpu_is_preempted; 325 struct paravirt_callee_save vcpu_is_preempted;
326}; 326} __no_randomize_layout;
327 327
328/* This contains all the paravirt structures: we get a convenient 328/* This contains all the paravirt structures: we get a convenient
329 * number for each function using the offset which we use to indicate 329 * number for each function using the offset which we use to indicate
@@ -335,7 +335,7 @@ struct paravirt_patch_template {
335 struct pv_irq_ops pv_irq_ops; 335 struct pv_irq_ops pv_irq_ops;
336 struct pv_mmu_ops pv_mmu_ops; 336 struct pv_mmu_ops pv_mmu_ops;
337 struct pv_lock_ops pv_lock_ops; 337 struct pv_lock_ops pv_lock_ops;
338}; 338} __no_randomize_layout;
339 339
340extern struct pv_info pv_info; 340extern struct pv_info pv_info;
341extern struct pv_init_ops pv_init_ops; 341extern struct pv_init_ops pv_init_ops;