@@ -28,6 +28,15 @@ Objtool has the following features:
2828 sites, enabling the kernel to patch them inline, to prevent "thunk
2929 funneling" for both security and performance reasons
3030
31+ - Return thunk validation -- validates return thunks are used for
32+ certain CPU mitigations including Retbleed and SRSO
33+
34+ - Return thunk annotation -- annotates all return thunk sites so kernel
35+ can patch them inline, depending on enabled mitigations
36+
37+ - Return thunk training valiation -- validate that all entry paths
38+ untrain a "safe return" before the first return (or call)
39+
3140- Non-instrumentation validation -- validates non-instrumentable
3241 ("noinstr") code rules, preventing instrumentation in low-level C
3342 entry code
@@ -53,6 +62,9 @@ Objtool has the following features:
5362- Function entry annotation -- annotates function entries, enabling
5463 kernel function tracing
5564
65+ - Function preamble (prefix) annotation and/or symbol generation -- used
66+ for FineIBT and call depth tracking
67+
5668- Other toolchain hacks which will go unmentioned at this time...
5769
5870Each feature can be enabled individually or in combination using the
@@ -197,19 +209,17 @@ To achieve the validation, objtool enforces the following rules:
197209
1982101. Each callable function must be annotated as such with the ELF
199211 function type. In asm code, this is typically done using the
200- ENTRY/ENDPROC macros. If objtool finds a return instruction
212+ SYM_FUNC_{START,END} macros. If objtool finds a return instruction
201213 outside of a function, it flags an error since that usually indicates
202214 callable code which should be annotated accordingly.
203215
204216 This rule is needed so that objtool can properly identify each
205217 callable function in order to analyze its stack metadata.
206218
207- 2. Conversely, each section of code which is *not* callable should *not*
208- be annotated as an ELF function. The ENDPROC macro shouldn't be used
209- in this case.
210-
211- This rule is needed so that objtool can ignore non-callable code.
212- Such code doesn't have to follow any of the other rules.
219+ 2. Conversely, each section of code which is *not* callable, or is
220+ otherwise doing funny things with the stack or registers, should
221+ *not* be annotated as an ELF function. Rather, SYM_CODE_{START,END}
222+ should be used along with unwind hints.
213223
2142243. Each callable function which calls another function must have the
215225 correct frame pointer logic, if required by CONFIG_FRAME_POINTER or
@@ -221,7 +231,7 @@ To achieve the validation, objtool enforces the following rules:
221231 function B, the _caller_ of function A will be skipped on the stack
222232 trace.
223233
224- 4. Dynamic jumps and jumps to undefined symbols are only allowed if:
234+ 4. Indirect jumps and jumps to undefined symbols are only allowed if:
225235
226236 a) the jump is part of a switch statement; or
227237
@@ -304,20 +314,21 @@ the objtool maintainers.
304314 001e 2823e: 80 ce 02 or $0x2,%dh
305315 ...
306316
317+
3073182. file.o: warning: objtool: .text+0x53: unreachable instruction
308319
309320 Objtool couldn't find a code path to reach the instruction.
310321
311322 If the error is for an asm file, and the instruction is inside (or
312323 reachable from) a callable function, the function should be annotated
313- with the ENTRY/ENDPROC macros (ENDPROC is the important one).
314- Otherwise, the code should probably be annotated with the unwind hint
315- macros in asm/unwind_hints.h so objtool and the unwinder can know the
316- stack state associated with the code.
324+ with the SYM_FUNC_START and SYM_FUNC_END macros.
325+
326+ Otherwise, SYM_CODE_START can be used. In that case the code needs
327+ to be annotated with unwind hint macros.
328+
329+ If you're sure the code won't affect the reliability of runtime stack
330+ traces and want objtool to ignore it, see "Adding exceptions" below.
317331
318- If you're 100% sure the code won't affect stack traces, or if you're
319- a just a bad person, you can tell objtool to ignore it. See the
320- "Adding exceptions" section below.
321332
3223333. file.o: warning: objtool: foo+0x48c: bar() missing __noreturn in .c/.h or NORETURN() in noreturns.h
323334
@@ -326,6 +337,7 @@ the objtool maintainers.
326337 declaration and its definition, and must have a NORETURN() annotation
327338 in tools/objtool/noreturns.h.
328339
340+
3293414. file.o: warning: objtool: func(): can't find starting instruction
330342 or
331343 file.o: warning: objtool: func()+0x11dd: can't decode instruction
@@ -339,23 +351,21 @@ the objtool maintainers.
339351
340352 This is a kernel entry/exit instruction like sysenter or iret. Such
341353 instructions aren't allowed in a callable function, and are most
342- likely part of the kernel entry code. They should usually not have
343- the callable function annotation (ENDPROC) and should always be
344- annotated with the unwind hint macros in asm/unwind_hints.h.
354+ likely part of the kernel entry code. Such code should probably be
355+ placed in a SYM_FUNC_CODE block with unwind hints.
345356
346357
3473586. file.o: warning: objtool: func()+0x26: sibling call from callable instruction with modified stack frame
348359
349- This is a dynamic jump or a jump to an undefined symbol. Objtool
350- assumed it's a sibling call and detected that the frame pointer
351- wasn't first restored to its original state.
360+ This is a branch to an UNDEF symbol. Objtool assumed it's a
361+ sibling call and detected that the stack wasn't first restored to its
362+ original state.
352363
353- If it's not really a sibling call, you may need to move the
354- destination code to the local file.
364+ If it's not really a sibling call, you may need to use unwind hints
365+ and/or move the destination code to the local file.
355366
356367 If the instruction is not actually in a callable function (e.g.
357- kernel entry code), change ENDPROC to END and annotate manually with
358- the unwind hint macros in asm/unwind_hints.h.
368+ kernel entry code), use SYM_CODE_{START,END} and unwind hints.
359369
360370
3613717. file: warning: objtool: func()+0x5c: stack state mismatch
@@ -371,8 +381,8 @@ the objtool maintainers.
371381
372382 Another possibility is that the code has some asm or inline asm which
373383 does some unusual things to the stack or the frame pointer. In such
374- cases it's probably appropriate to use the unwind hint macros in
375- asm/unwind_hints.h .
384+ cases it's probably appropriate to use SYM_FUNC_CODE with unwind
385+ hints .
376386
377387
3783888. file.o: warning: objtool: funcA() falls through to next function funcB()
@@ -382,17 +392,16 @@ the objtool maintainers.
382392 can fall through into the next function. There could be different
383393 reasons for this:
384394
385- 1 ) funcA()'s last instruction is a call to a "noreturn" function like
395+ a ) funcA()'s last instruction is a call to a "noreturn" function like
386396 panic(). In this case the noreturn function needs to be added to
387397 objtool's hard-coded global_noreturns array. Feel free to bug the
388398 objtool maintainer, or you can submit a patch.
389399
390- 2 ) funcA() uses the unreachable() annotation in a section of code
400+ b ) funcA() uses the unreachable() annotation in a section of code
391401 that is actually reachable.
392402
393- 3) If funcA() calls an inline function, the object code for funcA()
394- might be corrupt due to a gcc bug. For more details, see:
395- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70646
403+ c) Some undefined behavior like divide by zero.
404+
396405
3974069. file.o: warning: objtool: funcA() call to funcB() with UACCESS enabled
398407
@@ -430,24 +439,26 @@ the objtool maintainers.
430439 This limitation can be overcome by massaging the alternatives with
431440 NOPs to shift the stack changes around so they no longer conflict.
432441
442+
43344311. file.o: warning: unannotated intra-function call
434444
435- This warning means that a direct call is done to a destination which
436- is not at the beginning of a function. If this is a legit call, you
437- can remove this warning by putting the ANNOTATE_INTRA_FUNCTION_CALL
438- directive right before the call.
445+ This warning means that a direct call is done to a destination which
446+ is not at the beginning of a function. If this is a legit call, you
447+ can remove this warning by putting the ANNOTATE_INTRA_FUNCTION_CALL
448+ directive right before the call.
449+
439450
44045112. file.o: warning: func(): not an indirect call target
441452
442- This means that objtool is running with --ibt and a function expected
443- to be an indirect call target is not. In particular, this happens for
444- init_module() or cleanup_module() if a module relies on these special
445- names and does not use module_init() / module_exit() macros to create
446- them.
453+ This means that objtool is running with --ibt and a function
454+ expected to be an indirect call target is not. In particular, this
455+ happens for init_module() or cleanup_module() if a module relies on
456+ these special names and does not use module_init() / module_exit()
457+ macros to create them.
447458
448459
449460If the error doesn't seem to make sense, it could be a bug in objtool.
450- Feel free to ask the objtool maintainer for help.
461+ Feel free to ask objtool maintainers for help.
451462
452463
453464Adding exceptions
0 commit comments