From patchwork Thu Apr 6 21:18:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9668469 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 92173602B3 for ; Thu, 6 Apr 2017 21:21:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC7A7285CF for ; Thu, 6 Apr 2017 21:21:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF1BA285E9; Thu, 6 Apr 2017 21:21:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id B3E1C285E7 for ; Thu, 6 Apr 2017 21:21:18 +0000 (UTC) Received: (qmail 32710 invoked by uid 550); 6 Apr 2017 21:19:44 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 29882 invoked from network); 6 Apr 2017 21:19:23 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5ibAv8rFbDlShMYQjTY7AQ3FQHhMz3bx0lI4v1K55Mg=; b=Y9vZu3hX2InZDJDtdTJJupSnRjFi98B1oR7CfCmKyvj/zVxoTOqhjoXOo8WHc/2et1 B7e8vV9m0/cPr6HN9nyT+0pgGIBfAxHDQpPlBr3gc5UB14a8yx6drHZzFPtAWs5g2BwE WVDcxETu5oFPzd6yrw/JPdoDD/jO1lY4TDUk4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5ibAv8rFbDlShMYQjTY7AQ3FQHhMz3bx0lI4v1K55Mg=; b=XZqfrMvFtr5YnAZp7vSWzcWL3Xgoaw0ydbXm2bxlCtms20jTyRABcFNpMpeDEueLP7 vpPxA/aIg/gyJ2mMbrsHZcXIfPgOHbJsJZq3J9ull6+X3WU86Y3pYhhy3NrI/QnF7p1F 31IqfIbPKP2CIGncvinrNIRMABJtA1yo0XJ1GT+ANa3AsUFVF+K6Hj5TUMQI9O+cooLx Af+E6FieHYRttswFajvfqVOxRazfnutBjJ1hlPDZ6JKrb2Ez61/9iwPTUUZFdxAi5f8k gGmGIllOxsfe7KFjYGE2KRH8o9p4pKOZWml0da2KVSpCA53h3rMjCFQ2v58xoyQioZLS vbkg== X-Gm-Message-State: AFeK/H0sBQ/Y1H6v5/bH1SpkCwtfc4p276dKbvDmPcW1UEy8vyjUkg8YzHKjy4WFtQE68yOA X-Received: by 10.84.141.164 with SMTP id 33mr44960298plv.166.1491513551585; Thu, 06 Apr 2017 14:19:11 -0700 (PDT) From: Kees Cook To: kernel-hardening@lists.openwall.com Cc: Kees Cook , Michael Leibowitz Date: Thu, 6 Apr 2017 14:18:28 -0700 Message-Id: <1491513513-84351-14-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491513513-84351-1-git-send-email-keescook@chromium.org> References: <1491513513-84351-1-git-send-email-keescook@chromium.org> Subject: [kernel-hardening] [PATCH 13/18] randstruct: opt-out externally exposed function pointer structs X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;