linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Andrew Morton <akpm@linux-foundation.org>,
	"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	Helge Deller <deller@gmx.de>, Arnd Bergmann <arnd@arndb.de>,
	Kees Cook <keescook@chromium.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-arch@vger.kernel.org, linux-ia64@vger.kernel.org,
	linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, Nicholas Piggin <npiggin@gmail.com>,
	linuxppc-dev@lists.ozlabs.org
Subject: [PATCH v4 05/13] powerpc: Prepare func_desc_t for refactorisation
Date: Tue, 15 Feb 2022 13:41:00 +0100	[thread overview]
Message-ID: <5c36105e08b27b98450535bff48d71b690c19739.1644928018.git.christophe.leroy@csgroup.eu> (raw)
In-Reply-To: <cover.1644928018.git.christophe.leroy@csgroup.eu>

In preparation of making func_desc_t generic, change the ELFv2
version to a struct containing 'addr' element.

This allows using single helpers common to ELFv1 and ELFv2 and
reduces the amount of #ifdef's

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Acked-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
---
 arch/powerpc/kernel/module_64.c | 36 ++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
index 46e8eeb7c432..ff93ef4cb5a2 100644
--- a/arch/powerpc/kernel/module_64.c
+++ b/arch/powerpc/kernel/module_64.c
@@ -33,19 +33,17 @@
 #ifdef PPC64_ELF_ABI_v2
 
 /* An address is simply the address of the function. */
-typedef unsigned long func_desc_t;
+typedef struct {
+	unsigned long addr;
+} func_desc_t;
 
 static func_desc_t func_desc(unsigned long addr)
 {
-	return addr;
-}
-static unsigned long func_addr(unsigned long addr)
-{
-	return addr;
-}
-static unsigned long stub_func_addr(func_desc_t func)
-{
-	return func;
+	func_desc_t desc = {
+		.addr = addr,
+	};
+
+	return desc;
 }
 
 /* PowerPC64 specific values for the Elf64_Sym st_other field.  */
@@ -70,14 +68,6 @@ static func_desc_t func_desc(unsigned long addr)
 {
 	return *(struct func_desc *)addr;
 }
-static unsigned long func_addr(unsigned long addr)
-{
-	return func_desc(addr).addr;
-}
-static unsigned long stub_func_addr(func_desc_t func)
-{
-	return func.addr;
-}
 static unsigned int local_entry_offset(const Elf64_Sym *sym)
 {
 	return 0;
@@ -93,6 +83,16 @@ void *dereference_module_function_descriptor(struct module *mod, void *ptr)
 }
 #endif
 
+static unsigned long func_addr(unsigned long addr)
+{
+	return func_desc(addr).addr;
+}
+
+static unsigned long stub_func_addr(func_desc_t func)
+{
+	return func.addr;
+}
+
 #define STUB_MAGIC 0x73747562 /* stub */
 
 /* Like PPC32, we need little trampolines to do > 24-bit jumps (into
-- 
2.34.1


  parent reply	other threads:[~2022-02-15 12:47 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-15 12:40 [PATCH v4 00/13] Fix LKDTM for PPC64/IA64/PARISC v4 Christophe Leroy
2022-02-15 12:40 ` [PATCH v4 01/13] powerpc: Fix 'sparse' checking on PPC64le Christophe Leroy
2022-02-15 16:06   ` Kees Cook
2022-02-15 12:40 ` [PATCH v4 02/13] powerpc: Move and rename func_descr_t Christophe Leroy
2022-02-15 12:40 ` [PATCH v4 03/13] powerpc: Use 'struct func_desc' instead of 'struct ppc64_opd_entry' Christophe Leroy
2022-02-15 12:40 ` [PATCH v4 04/13] powerpc: Remove " Christophe Leroy
2022-02-15 12:41 ` Christophe Leroy [this message]
2022-02-15 12:41 ` [PATCH v4 06/13] ia64: Rename 'ip' to 'addr' in 'struct fdesc' Christophe Leroy
2022-02-15 12:41 ` [PATCH v4 07/13] asm-generic: Define CONFIG_HAVE_FUNCTION_DESCRIPTORS Christophe Leroy
2022-02-15 12:41 ` [PATCH v4 08/13] asm-generic: Define 'func_desc_t' to commonly describe function descriptors Christophe Leroy
2022-02-15 12:41 ` [PATCH v4 09/13] asm-generic: Refactor dereference_[kernel]_function_descriptor() Christophe Leroy
2022-02-15 12:41 ` [PATCH v4 10/13] lkdtm: Force do_nothing() out of line Christophe Leroy
2022-02-15 12:41 ` [PATCH v4 11/13] lkdtm: Really write into kernel text in WRITE_KERN Christophe Leroy
2022-02-15 12:41 ` [PATCH v4 12/13] lkdtm: Fix execute_[user]_location() Christophe Leroy
2022-02-15 12:41 ` [PATCH v4 13/13] lkdtm: Add a test for function descriptors protection Christophe Leroy
2022-02-15 16:07 ` [PATCH v4 00/13] Fix LKDTM for PPC64/IA64/PARISC v4 Kees Cook
2022-02-16 12:22   ` Michael Ellerman
2022-02-16 16:20     ` Kees Cook
2022-02-16 13:26   ` Helge Deller
2022-02-16 12:25 ` John Paul Adrian Glaubitz
2022-02-21 20:06   ` John Paul Adrian Glaubitz
2022-03-08 12:07 ` Michael Ellerman
2022-03-09  1:37   ` Michael Ellerman
2022-03-09 16:30     ` Kees Cook

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=5c36105e08b27b98450535bff48d71b690c19739.1644928018.git.christophe.leroy@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=benh@kernel.crashing.org \
    --cc=deller@gmx.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=keescook@chromium.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-ia64@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=paulus@samba.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).