All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: kernel-hardening@lists.openwall.com
Cc: Kees Cook <keescook@chromium.org>,
	Michael Leibowitz <michael.leibowitz@intel.com>
Subject: [kernel-hardening] [PATCH 13/18] randstruct: opt-out externally exposed function pointer structs
Date: Thu,  6 Apr 2017 14:18:28 -0700	[thread overview]
Message-ID: <1491513513-84351-14-git-send-email-keescook@chromium.org> (raw)
In-Reply-To: <1491513513-84351-1-git-send-email-keescook@chromium.org>

Some function pointer structures are used externally to the kernel, like
the paravirt structures. These should never be randomized, so mark them as
such. This set was extracted from grsecurity.

One difference from grsecurity is the opting out of sgi-xp, until
maintainers can decide if randomization is actually safe there.

Signed-off-by: Kees Cook <keescook@chromium.org>
---
 arch/arm/include/asm/cacheflush.h     |  2 +-
 arch/x86/include/asm/paravirt_types.h | 16 ++++++++--------
 drivers/misc/sgi-xp/xp.h              |  2 +-
 3 files changed, 10 insertions(+), 10 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 {
 	void (*dma_unmap_area)(const void *, size_t, int);
 
 	void (*dma_flush_range)(const void *, const void *);
-};
+} __no_randomize_layout;
 
 /*
  * Select the calling method
diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
index 93c49cf09b63..82f7d92b9232 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 {
 	 */
 	unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
 			  unsigned long addr, unsigned len);
-};
+} __no_randomize_layout;
 
 
 struct pv_lazy_ops {
@@ -91,12 +91,12 @@ struct pv_lazy_ops {
 	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 */
@@ -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 {
 	/*
@@ -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);
@@ -301,7 +301,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
@@ -318,7 +318,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
@@ -330,7 +330,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;
diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
index c862cd4583cc..a23a373d8707 100644
--- a/drivers/misc/sgi-xp/xp.h
+++ b/drivers/misc/sgi-xp/xp.h
@@ -288,7 +288,7 @@ struct xpc_interface {
 					xpc_notify_func, void *);
 	void (*received) (short, int, void *);
 	enum xp_retval (*partid_to_nasids) (short, void *);
-};
+} __no_randomize_layout;
 
 extern struct xpc_interface xpc_interface;
 
-- 
2.7.4

  parent reply	other threads:[~2017-04-06 21:18 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-06 21:18 [kernel-hardening] [PATCH 00/18] Introduce struct layout randomization plugin Kees Cook
2017-04-06 21:18 ` [kernel-hardening] [PATCH 01/18] gcc-plugins: Add the randstruct plugin Kees Cook
2017-04-12 22:12   ` [kernel-hardening] " Kees Cook
2017-04-17  5:30     ` Jessica Yu
2017-04-17 15:23       ` Kees Cook
2017-05-12  6:37         ` Loganaden Velvindron
2017-05-12 19:36           ` Kees Cook
2017-04-06 21:18 ` [kernel-hardening] [PATCH 02/18] compiler: Add __designated_init annotation Kees Cook
2017-04-06 21:18 ` [kernel-hardening] [PATCH 03/18] randstruct: Set designated_init attribute Kees Cook
2017-04-06 21:18 ` [kernel-hardening] [PATCH 04/18] randstruct: Differentiate bad cast warnings Kees Cook
2017-04-06 21:18 ` [kernel-hardening] [PATCH 05/18] af_unix: Use designated initializers Kees Cook
2017-04-06 21:18 ` [kernel-hardening] [PATCH 06/18] NFS: Avoid cross-structure casting Kees Cook
2017-04-06 21:18 ` [kernel-hardening] [PATCH 07/18] randstruct: Whitelist struct security_hook_heads cast Kees Cook
2017-04-06 21:18 ` [kernel-hardening] [PATCH 08/18] randstruct: Whitelist UNIXCB cast Kees Cook
2017-04-06 21:18 ` [kernel-hardening] [PATCH 09/18] randstruct: Mark various structs for randomization Kees Cook
2017-04-06 21:18 ` [kernel-hardening] [PATCH 10/18] scsi/bfa: use designated initializers Kees Cook
2017-04-06 21:18 ` [kernel-hardening] [PATCH 11/18] scsi: qedi,qedf: Use " Kees Cook
2017-04-06 21:18 ` [kernel-hardening] [PATCH 12/18] ovl: " Kees Cook
2017-04-06 21:18 ` Kees Cook [this message]
2017-04-06 21:18 ` [kernel-hardening] [PATCH 14/18] randstruct: Disable randomization of ACPICA structs Kees Cook
2017-04-06 21:18 ` [kernel-hardening] [PATCH 15/18] randstruct: Enable function pointer struct detection Kees Cook
2017-04-06 21:18 ` [kernel-hardening] [PATCH 16/18] task_struct: Allow randomized layout Kees Cook
2017-04-07 16:25   ` Rik van Riel
2017-04-07 20:43     ` Kees Cook
2017-04-06 21:18 ` [kernel-hardening] [PATCH 17/18] sgi-xp: Use designated initializers Kees Cook
2017-04-06 21:18 ` [kernel-hardening] [PATCH 18/18] ACPICA: " Kees Cook
2017-04-06 21:54 ` [kernel-hardening] [PATCH 00/18] Introduce struct layout randomization plugin James Morris
2017-04-06 22:32   ` Rik van Riel
2017-04-06 22:51     ` Kees Cook
2017-04-13 23:39 ` Laura Abbott
2017-04-15 18:50   ` Kees Cook
2017-04-18 17:15     ` Laura Abbott
2017-04-18 17:20       ` Kees Cook
2017-04-18 16:54 ` Laura Abbott

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1491513513-84351-14-git-send-email-keescook@chromium.org \
    --to=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=michael.leibowitz@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.