hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/tools/objtool/check.c
....@@ -168,6 +168,7 @@
168168 "panic",
169169 "do_exit",
170170 "do_task_dead",
171
+ "make_task_dead",
171172 "__module_put_and_exit",
172173 "complete_and_exit",
173174 "__reiserfs_panic",
....@@ -175,10 +176,11 @@
175176 "fortify_panic",
176177 "usercopy_abort",
177178 "machine_real_restart",
178
- "rewind_stack_do_exit",
179
+ "rewind_stack_and_make_dead",
179180 "kunit_try_catch_throw",
180181 "xen_start_kernel",
181182 "cpu_bringup_and_idle",
183
+ "stop_this_cpu",
182184 };
183185
184186 if (!func)
....@@ -196,7 +198,7 @@
196198 return false;
197199
198200 insn = find_insn(file, func->sec, func->offset);
199
- if (!insn->func)
201
+ if (!insn || !insn->func)
200202 return false;
201203
202204 func_for_each_insn(file, func, insn) {
....@@ -367,7 +369,7 @@
367369
368370 if (!strcmp(sec->name, ".noinstr.text") ||
369371 !strcmp(sec->name, ".entry.text") ||
370
- !strncmp(sec->name, ".text.__x86.", 12))
372
+ !strncmp(sec->name, ".text..__x86.", 13))
371373 sec->noinstr = true;
372374
373375 for (offset = 0; offset < sec->len; offset += insn->len) {
....@@ -570,6 +572,7 @@
570572 if (strncmp(key_name, STATIC_CALL_TRAMP_PREFIX_STR,
571573 STATIC_CALL_TRAMP_PREFIX_LEN)) {
572574 WARN("static_call: trampoline name malformed: %s", key_name);
575
+ free(key_name);
573576 return -1;
574577 }
575578 tmp = key_name + STATIC_CALL_TRAMP_PREFIX_LEN - STATIC_CALL_KEY_PREFIX_LEN;
....@@ -579,6 +582,7 @@
579582 if (!key_sym) {
580583 if (!module) {
581584 WARN("static_call: can't find static_call_key symbol: %s", tmp);
585
+ free(key_name);
582586 return -1;
583587 }
584588
....@@ -845,6 +849,16 @@
845849 "__tsan_read_write4",
846850 "__tsan_read_write8",
847851 "__tsan_read_write16",
852
+ "__tsan_volatile_read1",
853
+ "__tsan_volatile_read2",
854
+ "__tsan_volatile_read4",
855
+ "__tsan_volatile_read8",
856
+ "__tsan_volatile_read16",
857
+ "__tsan_volatile_write1",
858
+ "__tsan_volatile_write2",
859
+ "__tsan_volatile_write4",
860
+ "__tsan_volatile_write8",
861
+ "__tsan_volatile_write16",
848862 "__tsan_atomic8_load",
849863 "__tsan_atomic16_load",
850864 "__tsan_atomic32_load",
....@@ -895,6 +909,8 @@
895909 "__tsan_atomic64_compare_exchange_val",
896910 "__tsan_atomic_thread_fence",
897911 "__tsan_atomic_signal_fence",
912
+ "__tsan_unaligned_read16",
913
+ "__tsan_unaligned_write16",
898914 /* KCOV */
899915 "write_comp_data",
900916 "check_kcov_mode",
....@@ -973,12 +989,29 @@
973989 return 0;
974990 }
975991
992
+/*
993
+ * Symbols that replace INSN_CALL_DYNAMIC, every (tail) call to such a symbol
994
+ * will be added to the .retpoline_sites section.
995
+ */
976996 __weak bool arch_is_retpoline(struct symbol *sym)
977997 {
978998 return false;
979999 }
9801000
1001
+/*
1002
+ * Symbols that replace INSN_RETURN, every (tail) call to such a symbol
1003
+ * will be added to the .return_sites section.
1004
+ */
9811005 __weak bool arch_is_rethunk(struct symbol *sym)
1006
+{
1007
+ return false;
1008
+}
1009
+
1010
+/*
1011
+ * Symbols that are embedded inside other instructions, because sometimes crazy
1012
+ * code exists. These are mostly ignored for validation purposes.
1013
+ */
1014
+__weak bool arch_is_embedded_insn(struct symbol *sym)
9821015 {
9831016 return false;
9841017 }
....@@ -1230,14 +1263,14 @@
12301263 continue;
12311264
12321265 /*
1233
- * This is a special case for zen_untrain_ret().
1266
+ * This is a special case for retbleed_untrain_ret().
12341267 * It jumps to __x86_return_thunk(), but objtool
12351268 * can't find the thunk's starting RET
12361269 * instruction, because the RET is also in the
12371270 * middle of another instruction. Objtool only
12381271 * knows about the outer instruction.
12391272 */
1240
- if (sym && sym->return_thunk) {
1273
+ if (sym && sym->embedded_insn) {
12411274 add_return_call(file, insn, false);
12421275 continue;
12431276 }
....@@ -2039,6 +2072,9 @@
20392072 if (arch_is_rethunk(func))
20402073 func->return_thunk = true;
20412074
2075
+ if (arch_is_embedded_insn(func))
2076
+ func->embedded_insn = true;
2077
+
20422078 if (!strcmp(func->name, "__fentry__"))
20432079 func->fentry = true;
20442080
....@@ -2148,12 +2184,17 @@
21482184 return 0;
21492185 }
21502186
2151
-static bool is_fentry_call(struct instruction *insn)
2187
+static bool is_special_call(struct instruction *insn)
21522188 {
2153
- if (insn->type == INSN_CALL &&
2154
- insn->call_dest &&
2155
- insn->call_dest->fentry)
2156
- return true;
2189
+ if (insn->type == INSN_CALL) {
2190
+ struct symbol *dest = insn->call_dest;
2191
+
2192
+ if (!dest)
2193
+ return false;
2194
+
2195
+ if (dest->fentry)
2196
+ return true;
2197
+ }
21572198
21582199 return false;
21592200 }
....@@ -3027,7 +3068,7 @@
30273068 if (ret)
30283069 return ret;
30293070
3030
- if (!no_fp && func && !is_fentry_call(insn) &&
3071
+ if (!no_fp && func && !is_special_call(insn) &&
30313072 !has_valid_stack_frame(&state)) {
30323073 WARN_FUNC("call without frame pointer save/setup",
30333074 sec, insn->offset);