backports.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
To: backports@vger.kernel.org
Subject: [PATCH] headers: backport IBT / CFI support
Date: Mon, 11 Jul 2022 17:11:30 +0100	[thread overview]
Message-ID: <20220711161130.529294-1-dimitri.ledkov@canonical.com> (raw)

Kernels that support IBT on x86 require module_init/exit() functions
to have cfi protection included. Backport __CFI_ADDRESSABLE changes
from upstream linux/module.h into backports version of module.h
header.

This results in backported modules correctly pick up CFI protection
only when building against IBT enabled kernels.

Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
---
 backport/backport-include/linux/module.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/backport/backport-include/linux/module.h b/backport/backport-include/linux/module.h
index cd342e0d2fdd..efe970f174ed 100644
--- a/backport/backport-include/linux/module.h
+++ b/backport/backport-include/linux/module.h
@@ -3,6 +3,10 @@
 #include_next <linux/module.h>
 #include <linux/rcupdate.h>
 
+#ifndef __CFI_ADDRESSABLE
+#define __CFI_ADDRESSABLE(fn, __attr)
+#endif
+
 /*
  * The define overwriting module_init is based on the original module_init
  * which looks like this:
@@ -34,6 +38,7 @@ extern void backport_dependency_symbol(void);
 		return initfn();					\
 	}								\
 	int init_module(void) __attribute__((cold,alias("__init_backport")));\
+	__CFI_ADDRESSABLE(init_module, __initdata); \
 	BACKPORT_MOD_VERSIONS
 
 /*
@@ -58,7 +63,8 @@ extern void backport_dependency_symbol(void);
 		exitfn();						\
 		rcu_barrier();						\
 	}								\
-	void cleanup_module(void) __attribute__((cold,alias("__exit_compat")));
+	void cleanup_module(void) __attribute__((cold,alias("__exit_compat"))); \
+	__CFI_ADDRESSABLE(cleanup_module, __exitdata);
 #endif
 
 #endif /* __BACKPORT_LINUX_MODULE_H */
-- 
2.32.0

--
To unsubscribe from this list: send the line "unsubscribe backports" in

             reply	other threads:[~2022-07-11 16:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-11 16:11 Dimitri John Ledkov [this message]
2022-07-31 15:56 ` [PATCH] headers: backport IBT / CFI support Hauke Mehrtens

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=20220711161130.529294-1-dimitri.ledkov@canonical.com \
    --to=dimitri.ledkov@canonical.com \
    --cc=backports@vger.kernel.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).