Thread (107 messages) 107 messages, 7 authors, 2020-04-08
STALE2245d
Revisions (25)
  1. v6 [diff vs current]
  2. v7 [diff vs current]
  3. v8 [diff vs current]
  4. v9 current
  5. v10 [diff vs current]
  6. v11 [diff vs current]
  7. v12 [diff vs current]
  8. v13 [diff vs current]
  9. v14 [diff vs current]
  10. v15 [diff vs current]
  11. v16 [diff vs current]
  12. v17 [diff vs current]
  13. v18 [diff vs current]
  14. v19 [diff vs current]
  15. v20 [diff vs current]
  16. v21 [diff vs current]
  17. v22 [diff vs current]
  18. v23 [diff vs current]
  19. v24 [diff vs current]
  20. v25 [diff vs current]
  21. v26 [diff vs current]
  22. v27 [diff vs current]
  23. v28 [diff vs current]
  24. v29 [diff vs current]
  25. v30 [diff vs current]

[RFC PATCH v9 23/27] ELF: Introduce arch_setup_elf_property()

From: Yu-cheng Yu <hidden>
Date: 2020-02-05 18:21:08
Also in: linux-api, linux-arch, linux-mm, lkml
Subsystem: exec & binfmt api, elf, filesystems (vfs and infrastructure), the rest · Maintainers: Kees Cook, Alexander Viro, Christian Brauner, Linus Torvalds

An ELF file's .note.gnu.property indicates architecture features of the
file.  These features are extracted earlier and stored in the struct
'arch_elf_state'.  Introduce arch_setup_elf_property() to setup and enable
these features.  The first use-case of this function is Shadow Stack and
Indirect Branch Tracking, which are introduced later.

Signed-off-by: Yu-cheng Yu <redacted>
---
 fs/binfmt_elf.c     | 4 ++++
 include/linux/elf.h | 6 ++++++
 2 files changed, 10 insertions(+)
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 054446f93442..56fe6cd437fe 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1213,6 +1213,10 @@ static int load_elf_binary(struct linux_binprm *bprm)
 
 	set_binfmt(&elf_format);
 
+	retval = arch_setup_elf_property(&arch_state);
+	if (retval < 0)
+		goto out;
+
 #ifdef ARCH_HAS_SETUP_ADDITIONAL_PAGES
 	retval = arch_setup_additional_pages(bprm, !!interpreter);
 	if (retval < 0)
diff --git a/include/linux/elf.h b/include/linux/elf.h
index 7bdc6da160c7..81f2161fa4a8 100644
--- a/include/linux/elf.h
+++ b/include/linux/elf.h
@@ -78,9 +78,15 @@ static inline int arch_parse_elf_property(u32 type, const void *data,
 {
 	return 0;
 }
+
+static inline int arch_setup_elf_property(struct arch_elf_state *arch)
+{
+	return 0;
+}
 #else
 extern int arch_parse_elf_property(u32 type, const void *data, size_t datasz,
 				   bool compat, struct arch_elf_state *arch);
+extern int arch_setup_elf_property(struct arch_elf_state *arch);
 #endif
 
 #endif /* _LINUX_ELF_H */
-- 
2.21.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help