From: Miroslav Benes <mbenes@suse.cz>
To: Julien Thierry <jthierry@redhat.com>
Cc: linux-kernel@vger.kernel.org, jpoimboe@redhat.com,
peterz@infradead.org, raphael.gault@arm.com
Subject: Re: [PATCH v2 04/10] objtool: check: Ignore empty alternative groups
Date: Wed, 1 Apr 2020 15:48:20 +0200 (CEST) [thread overview]
Message-ID: <alpine.LSU.2.21.2004011545221.15809@pobox.suse.cz> (raw)
In-Reply-To: <1f53ee68-3bcc-7de9-beb9-df812b2e3613@redhat.com>
On Wed, 1 Apr 2020, Julien Thierry wrote:
>
>
> On 4/1/20 1:53 PM, Miroslav Benes wrote:
> > On Fri, 27 Mar 2020, Julien Thierry wrote:
> >
> >> Atlernative section can contain entries for alternatives with no
> >> instructions. Objtool will currently crash when handling such an entry.
> >>
> >> Just skip that entry, but still give a warning to discourage useless
> >> entries.
> >>
> >> Signed-off-by: Julien Thierry <jthierry@redhat.com>
> >> ---
> >> tools/objtool/check.c | 6 ++++++
> >> 1 file changed, 6 insertions(+)
> >>
> >> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> >> index 74353b2c39ce..5c03460f1f07 100644
> >> --- a/tools/objtool/check.c
> >> +++ b/tools/objtool/check.c
> >> @@ -904,6 +904,12 @@ static int add_special_section_alts(struct
> >> objtool_file *file)
> >> }
> >>
> >> if (special_alt->group) {
> >> + if (!special_alt->orig_len) {
> >> + WARN_FUNC("empty alternative entry",
> >> + orig_insn->sec, orig_insn->offset);
> >> + continue;
> >> + }
> >> +
> >> ret = handle_group_alt(file, special_alt, orig_insn,
> >> &new_insn);
> >> if (ret)
> >
> > Probably the first time I am looking at alternatives handling in objtool,
> > so I must be missing something, but is this even possible now? I mean
> > get_alt_entry() in special.c sets alt->orig_len when alt->group is true
> > (which means .alternatives section) to something which cannot be zero.
> >
>
> What I see is:
>
> if (alt->group) {
> alt->orig_len = *(unsigned char *)(sec->data->d_buf + offset +
> entry->orig_len);
> alt->new_len = *(unsigned char *)(sec->data->d_buf + offset +
> entry->new_len);
> }
Now that you copy-pasted the code here, I see that I completely missed
there is dereference (for obvious reasons) right before the type cast, so
all is fine. My mistake, I need more tea.
> And as far as I can tell, "alt->orig_len" can be 0 if the entry in the
> .altinstructions section of the .o file has the length set to 0.
Yes
> I don't know how the alternative section generation works on x86, but on arm64
> it's just a computed assembly offset which can be 0.
>
> > Is this a preparatory patch for arm64, where this could happen? If yes, it
> > would be better to mention it in the changelog.
> >
>
> It used to happen on arm64, but the fix [1] was picked.
>
> I can add that link to the commit if necessary.
No, I think the check makes sense on its own.
Thanks
Miroslav
next prev parent reply other threads:[~2020-04-01 13:48 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-27 15:28 [PATCH v2 00/10] Objtool updates for easier portability Julien Thierry
2020-03-27 15:28 ` [PATCH v2 01/10] objtool: Move header sync-check ealier in build Julien Thierry
2020-04-01 12:32 ` Miroslav Benes
2020-04-01 12:44 ` Julien Thierry
2020-04-01 12:55 ` Miroslav Benes
2020-04-02 17:12 ` Josh Poimboeuf
2020-04-02 17:17 ` Josh Poimboeuf
2020-03-27 15:28 ` [PATCH v2 02/10] objtool: check: Remove redundant checks on operand type Julien Thierry
2020-03-27 15:28 ` [PATCH v2 03/10] objtool: check: Clean instruction state before each function validation Julien Thierry
2020-03-27 15:28 ` [PATCH v2 04/10] objtool: check: Ignore empty alternative groups Julien Thierry
2020-04-01 12:53 ` Miroslav Benes
2020-04-01 13:43 ` Julien Thierry
2020-04-01 13:48 ` Miroslav Benes [this message]
2020-03-27 15:28 ` [PATCH v2 05/10] objtool: check: Remove check preventing branches within alternative Julien Thierry
2020-05-01 18:22 ` [tip: objtool/core] objtool: " tip-bot2 for Julien Thierry
2020-03-27 15:28 ` [PATCH v2 06/10] objtool: check: Use arch specific values in restore_reg() Julien Thierry
2020-03-27 15:28 ` [PATCH v2 07/10] objtool: check: Allow save/restore hint in non standard function symbols Julien Thierry
2020-04-01 13:54 ` Miroslav Benes
2020-04-01 14:06 ` Julien Thierry
2020-03-27 15:28 ` [PATCH v2 08/10] objtool: Add abstraction for computation of symbols offsets Julien Thierry
2020-03-27 15:28 ` [PATCH v2 09/10] objtool: Split generic and arch specific CFI definitions Julien Thierry
2020-03-27 15:28 ` [PATCH v2 10/10] objtool: Support multiple stack_op per instruction Julien Thierry
2020-04-02 17:54 ` Josh Poimboeuf
2020-04-02 18:25 ` Peter Zijlstra
2020-04-03 8:01 ` Julien Thierry
2020-04-03 14:55 ` Josh Poimboeuf
2020-04-22 22:24 ` [tip: objtool/core] " tip-bot2 for Julien Thierry
2020-04-23 7:49 ` tip-bot2 for Julien Thierry
2020-04-23 11:15 ` Peter Zijlstra
2020-04-02 17:58 ` [PATCH v2 00/10] Objtool updates for easier portability Josh Poimboeuf
2020-04-02 18:30 ` Peter Zijlstra
2020-04-03 7:17 ` Miroslav Benes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LSU.2.21.2004011545221.15809@pobox.suse.cz \
--to=mbenes@suse.cz \
--cc=jpoimboe@redhat.com \
--cc=jthierry@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=raphael.gault@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).