mirror of https://gitee.com/openkylin/linux.git
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>
This commit is contained in:
parent
29e48ce87f
commit
8acdf50559
|
@ -116,7 +116,7 @@ struct cpu_cache_fns {
|
||||||
void (*dma_unmap_area)(const void *, size_t, int);
|
void (*dma_unmap_area)(const void *, size_t, int);
|
||||||
|
|
||||||
void (*dma_flush_range)(const void *, const void *);
|
void (*dma_flush_range)(const void *, const void *);
|
||||||
};
|
} __no_randomize_layout;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Select the calling method
|
* Select the calling method
|
||||||
|
|
|
@ -83,7 +83,7 @@ struct pv_init_ops {
|
||||||
*/
|
*/
|
||||||
unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
|
unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
|
||||||
unsigned long addr, unsigned len);
|
unsigned long addr, unsigned len);
|
||||||
};
|
} __no_randomize_layout;
|
||||||
|
|
||||||
|
|
||||||
struct pv_lazy_ops {
|
struct pv_lazy_ops {
|
||||||
|
@ -91,12 +91,12 @@ struct pv_lazy_ops {
|
||||||
void (*enter)(void);
|
void (*enter)(void);
|
||||||
void (*leave)(void);
|
void (*leave)(void);
|
||||||
void (*flush)(void);
|
void (*flush)(void);
|
||||||
};
|
} __no_randomize_layout;
|
||||||
|
|
||||||
struct pv_time_ops {
|
struct pv_time_ops {
|
||||||
unsigned long long (*sched_clock)(void);
|
unsigned long long (*sched_clock)(void);
|
||||||
unsigned long long (*steal_clock)(int cpu);
|
unsigned long long (*steal_clock)(int cpu);
|
||||||
};
|
} __no_randomize_layout;
|
||||||
|
|
||||||
struct pv_cpu_ops {
|
struct pv_cpu_ops {
|
||||||
/* hooks for various privileged instructions */
|
/* hooks for various privileged instructions */
|
||||||
|
@ -175,7 +175,7 @@ struct pv_cpu_ops {
|
||||||
|
|
||||||
void (*start_context_switch)(struct task_struct *prev);
|
void (*start_context_switch)(struct task_struct *prev);
|
||||||
void (*end_context_switch)(struct task_struct *next);
|
void (*end_context_switch)(struct task_struct *next);
|
||||||
};
|
} __no_randomize_layout;
|
||||||
|
|
||||||
struct pv_irq_ops {
|
struct pv_irq_ops {
|
||||||
/*
|
/*
|
||||||
|
@ -198,7 +198,7 @@ struct pv_irq_ops {
|
||||||
#ifdef CONFIG_X86_64
|
#ifdef CONFIG_X86_64
|
||||||
void (*adjust_exception_frame)(void);
|
void (*adjust_exception_frame)(void);
|
||||||
#endif
|
#endif
|
||||||
};
|
} __no_randomize_layout;
|
||||||
|
|
||||||
struct pv_mmu_ops {
|
struct pv_mmu_ops {
|
||||||
unsigned long (*read_cr2)(void);
|
unsigned long (*read_cr2)(void);
|
||||||
|
@ -306,7 +306,7 @@ struct pv_mmu_ops {
|
||||||
an mfn. We can tell which is which from the index. */
|
an mfn. We can tell which is which from the index. */
|
||||||
void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
|
void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
|
||||||
phys_addr_t phys, pgprot_t flags);
|
phys_addr_t phys, pgprot_t flags);
|
||||||
};
|
} __no_randomize_layout;
|
||||||
|
|
||||||
struct arch_spinlock;
|
struct arch_spinlock;
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
|
@ -323,7 +323,7 @@ struct pv_lock_ops {
|
||||||
void (*kick)(int cpu);
|
void (*kick)(int cpu);
|
||||||
|
|
||||||
struct paravirt_callee_save vcpu_is_preempted;
|
struct paravirt_callee_save vcpu_is_preempted;
|
||||||
};
|
} __no_randomize_layout;
|
||||||
|
|
||||||
/* This contains all the paravirt structures: we get a convenient
|
/* This contains all the paravirt structures: we get a convenient
|
||||||
* number for each function using the offset which we use to indicate
|
* number for each function using the offset which we use to indicate
|
||||||
|
@ -335,7 +335,7 @@ struct paravirt_patch_template {
|
||||||
struct pv_irq_ops pv_irq_ops;
|
struct pv_irq_ops pv_irq_ops;
|
||||||
struct pv_mmu_ops pv_mmu_ops;
|
struct pv_mmu_ops pv_mmu_ops;
|
||||||
struct pv_lock_ops pv_lock_ops;
|
struct pv_lock_ops pv_lock_ops;
|
||||||
};
|
} __no_randomize_layout;
|
||||||
|
|
||||||
extern struct pv_info pv_info;
|
extern struct pv_info pv_info;
|
||||||
extern struct pv_init_ops pv_init_ops;
|
extern struct pv_init_ops pv_init_ops;
|
||||||
|
|
Loading…
Reference in New Issue