Skip to content

Commit

Permalink
randstruct: opt-out externally exposed function pointer structs
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
kees committed Jun 30, 2017
1 parent 29e48ce commit 8acdf50
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion arch/arm/include/asm/cacheflush.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ struct cpu_cache_fns {
void (*dma_unmap_area)(const void *, size_t, int);

void (*dma_flush_range)(const void *, const void *);
};
} __no_randomize_layout;

/*
* Select the calling method
Expand Down
16 changes: 8 additions & 8 deletions arch/x86/include/asm/paravirt_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,20 @@ struct pv_init_ops {
*/
unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
unsigned long addr, unsigned len);
};
} __no_randomize_layout;


struct pv_lazy_ops {
/* Set deferred update mode, used for batching operations. */
void (*enter)(void);
void (*leave)(void);
void (*flush)(void);
};
} __no_randomize_layout;

struct pv_time_ops {
unsigned long long (*sched_clock)(void);
unsigned long long (*steal_clock)(int cpu);
};
} __no_randomize_layout;

struct pv_cpu_ops {
/* hooks for various privileged instructions */
Expand Down Expand Up @@ -175,7 +175,7 @@ struct pv_cpu_ops {

void (*start_context_switch)(struct task_struct *prev);
void (*end_context_switch)(struct task_struct *next);
};
} __no_randomize_layout;

struct pv_irq_ops {
/*
Expand All @@ -198,7 +198,7 @@ struct pv_irq_ops {
#ifdef CONFIG_X86_64
void (*adjust_exception_frame)(void);
#endif
};
} __no_randomize_layout;

struct pv_mmu_ops {
unsigned long (*read_cr2)(void);
Expand Down Expand Up @@ -306,7 +306,7 @@ struct pv_mmu_ops {
an mfn. We can tell which is which from the index. */
void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
phys_addr_t phys, pgprot_t flags);
};
} __no_randomize_layout;

struct arch_spinlock;
#ifdef CONFIG_SMP
Expand All @@ -323,7 +323,7 @@ struct pv_lock_ops {
void (*kick)(int cpu);

struct paravirt_callee_save vcpu_is_preempted;
};
} __no_randomize_layout;

/* This contains all the paravirt structures: we get a convenient
* number for each function using the offset which we use to indicate
Expand All @@ -335,7 +335,7 @@ struct paravirt_patch_template {
struct pv_irq_ops pv_irq_ops;
struct pv_mmu_ops pv_mmu_ops;
struct pv_lock_ops pv_lock_ops;
};
} __no_randomize_layout;

extern struct pv_info pv_info;
extern struct pv_init_ops pv_init_ops;
Expand Down

0 comments on commit 8acdf50

Please sign in to comment.