Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp701548ybb; Wed, 1 Apr 2020 08:06:55 -0700 (PDT) X-Google-Smtp-Source: ADFU+vv8zrFvnLeUn4rBgXgMbw7Lajwp4s2JXbg2vKzxm/wKvF5qlbwNwicwpSm5V39EKDFEoEMX X-Received: by 2002:a4a:7555:: with SMTP id g21mr17359411oof.46.1585753614714; Wed, 01 Apr 2020 08:06:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585753614; cv=none; d=google.com; s=arc-20160816; b=sw24Uur9J6/ot0s3W+vgdMVoCoCL0pVshxipmc3ptnV5fHobVL8Es+2rjV4A4buWN7 U9QWL48zfJoVQr8e5QcuUANDPRWVdXgOjzcHwapvxXFp/Ew3I7M8Qu3xmopGrvl8y2Lm qYZckjDj4YqEzRxyeejqfC0HNPcD5L9bwmu0IdAMz6uaVyoHg9cuAdk2Ry4MRivEcraO ADaWjY7FWSLXQAMHID8JHKWssXay41XAzTdj4XZOn/kpY6tWJohSwcxzC4CsbEs2eWdp SC9nnnp2vQRfhkiAJ6554R8n1oE0InV27w/1ccwAs4afLYJB4BsKsC26W1D5/6XOaS9h 5qPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=+w9GADqfPhe5LHmsE0JLl8jTWzKlTpgkpUMmF78YlLs=; b=j0QMADgsSRZfM7BahGjQpQPH/BbBQxVwGarErRu9sCMp/ik4ci9HZh6iDvvKmJvEIz EEJ8NYI6Bv5lrew19nUJ6xH2P5fCIV1ECbh+AXKo/rKbPZomaI/gJ5y04N/YJSmdRL6Q tC6W8NMWD4fNEcDl3mDDPc1hJH2MQ37h18OSB1FRwZGK7uuAHy7oShlyxVkz401FMYOu PhwQ5jefIN1v/oD4HqMWBTN7uD6tnbi3DeZLRsrif/d2e5iQwkkSnjADu/S02diYPGkP +pHypywGicGDSgfOCy/JBynSG2rkf0ugjbwjOuYME3ZQ3StjYXXQ/SNNwpQXRxJhPbxN 29Zg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 4si1003427otu.74.2020.04.01.08.06.24; Wed, 01 Apr 2020 08:06:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732687AbgDANsX (ORCPT + 99 others); Wed, 1 Apr 2020 09:48:23 -0400 Received: from mx2.suse.de ([195.135.220.15]:45556 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732289AbgDANsX (ORCPT ); Wed, 1 Apr 2020 09:48:23 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 5B314AE4D; Wed, 1 Apr 2020 13:48:21 +0000 (UTC) Date: Wed, 1 Apr 2020 15:48:20 +0200 (CEST) From: Miroslav Benes To: Julien Thierry 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 In-Reply-To: <1f53ee68-3bcc-7de9-beb9-df812b2e3613@redhat.com> Message-ID: References: <20200327152847.15294-1-jthierry@redhat.com> <20200327152847.15294-5-jthierry@redhat.com> <1f53ee68-3bcc-7de9-beb9-df812b2e3613@redhat.com> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > >> --- > >> 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