]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
objtool: skip non-text sections when adding return-thunk sites
authorThadeu Lima de Souza Cascardo <cascardo@canonical.com>
Fri, 1 Jul 2022 12:00:45 +0000 (09:00 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@canonical.com>
Tue, 19 Jul 2022 19:17:35 +0000 (16:17 -0300)
The .discard.text section is added in order to reserve BRK, with a
temporary function just so it can give it a size. This adds a relocation to
the return thunk, which objtool will add to the .return_sites section.
Linking will then fail as there are references to the .discard.text
section.

Do not add instructions from non-text sections to the list of return thunk
calls, avoiding the reference to .discard.text.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
CVE-2022-29900
CVE-2022-29901
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
tools/objtool/check.c

index 41d111c69620d6e1e6d9584e83a494b259acc237..d80c54809a91de08baac989465871beb4711c9ff 100644 (file)
@@ -1153,7 +1153,9 @@ static void add_return_call(struct objtool_file *file, struct instruction *insn)
        insn->type = INSN_RETURN;
        insn->retpoline_safe = true;
 
-       list_add_tail(&insn->call_node, &file->return_thunk_list);
+       /* Skip the non-text sections, specially .discard ones */
+       if (insn->sec->text)
+               list_add_tail(&insn->call_node, &file->return_thunk_list);
 }
 
 /*