summaryrefslogtreecommitdiffstats
path: root/patches/0021-rh_taint-don-t-dereference-struct-module-without-CON.patch
blob: 01ff8703fd1f4eeb505961cb3ba96aa4421627e5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
From b5108aaf36105894a1412f73788afc3bfedd3071 Mon Sep 17 00:00:00 2001
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
Date: Sun, 24 May 2020 19:28:07 -0600
Subject: [PATCH 21/34] rh_taint: don't dereference struct module without
 CONFIG_MODULE

This structure isn't defined for !CONFIG_MODULE, so don't try to use it.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 include/linux/moduleloader.h | 2 ++
 kernel/rh_taint.c            | 4 ++++
 2 files changed, 6 insertions(+)

diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
index 560ca53a75f..3425b352eac 100644
--- a/include/linux/moduleloader.h
+++ b/include/linux/moduleloader.h
@@ -45,7 +45,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
 				 unsigned int relsec,
 				 struct module *me)
 {
+#ifdef CONFIG_MODULE
 	printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
+#endif
 	return -ENOEXEC;
 }
 #endif
diff --git a/kernel/rh_taint.c b/kernel/rh_taint.c
index 22f032431c9..bbd7f8a1ab2 100644
--- a/kernel/rh_taint.c
+++ b/kernel/rh_taint.c
@@ -61,14 +61,18 @@ void mark_tech_preview(const char *msg, struct module *mod)
 
 	if (msg)
 		str = msg;
+#ifdef CONFIG_MODULE
 	else if (mod && mod->name)
 		str = mod->name;
+#endif
 
 	pr_warn("TECH PREVIEW: %s may not be fully supported.\n"
 		"Please review provided documentation for limitations.\n",
 		(str ? str : "kernel"));
 	add_taint(TAINT_TECH_PREVIEW, LOCKDEP_STILL_OK);
+#ifdef CONFIG_MODULE
 	if (mod)
 		mod->taints |= (1U << TAINT_TECH_PREVIEW);
+#endif
 }
 EXPORT_SYMBOL(mark_tech_preview);
-- 
2.29.1