Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp615144ybb; Fri, 3 Apr 2020 08:44:52 -0700 (PDT) X-Google-Smtp-Source: APiQypLhJfclJdcOT12ogfvBhRdoYIb+oAEC+y+/JNauUWPt19wlvGFDPP3RWufIxAbOnxUYeq7y X-Received: by 2002:a9d:22e9:: with SMTP id y96mr6919814ota.217.1585928692318; Fri, 03 Apr 2020 08:44:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585928692; cv=none; d=google.com; s=arc-20160816; b=Xz0Oh2bbDq2HXEQG+n45T7D401Ga6/XqPhxcx0w3H438nbhrfBXawRApi6yx8phS4X zF8tj8FGrQ+lLCNDKIaZ6RXO6bt/jefWKl5FKAplkzG6ZCs9fO7VGuY7L/AJ+cWtImA8 13DrS0slGS4LY5/gHi/OoYgIhUwtZksUt7RpZh8LfvpmD3ScA9SN4rb1k/J9bsRusuQR DJYaOMr7ph5xx1AjfqDo1Oe5dmSXWXFITe5xmQq1AAw5+i7ITAN3dnA5CEr9Vvbw57Uf IblUboDkjqT+yYXoFgdz+PS/pRs2NtYhADQojpwv8wnKytGPbhcyfjIjyQggwlTCWzBf RWsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=iVuhW4T2nVV7nJd21PZ+m4iAMcpuBsAwHlOi0Sjvo/g=; b=eh+mEFi82fX/JTarSsJyvdhf+3x44XCAHULd9RdvVAAvBUveQrrieu/Ck6JZNUVy8V qJYWNWaNsc2lS+1WSBaFpMphKB+ks4n2wWF9mDqtqpKSTsz1IFrEoxIh3uonxsEiOOaJ 4RX7spdHXjrgWMfZX1DXxKLOkzmrQx38YbHEEv23kVDke30/SBQaoYxopnwIEOTP33w2 3Mwk4PPtYGJksA5dj0nWgv94P6cGKIenPkO/4wYYdJ397MTV4O8by1NsNCESvtsQofwH 6OsLyESOIlbYKKBonxE/oxb/jFXkoq9j78Bvfb+JVGh1z8OV6Dn0GrHvWtpbE95x+F0i ip3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZDVwphBf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t28si3896989ooc.16.2020.04.03.08.44.39; Fri, 03 Apr 2020 08:44:52 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZDVwphBf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391042AbgDCOuv (ORCPT + 99 others); Fri, 3 Apr 2020 10:50:51 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:57177 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727431AbgDCOuu (ORCPT ); Fri, 3 Apr 2020 10:50:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585925449; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=iVuhW4T2nVV7nJd21PZ+m4iAMcpuBsAwHlOi0Sjvo/g=; b=ZDVwphBfzKsjp4+PtJ5elEio6Ak8w4EVdQUBItFeIVU753RIzQPtdmHWEqDVypY7LrS/xV OnaeWQdzkeuYwkpRdvoTlxdIIXkE39CD374+PpMG2+0LQpt0wGwa+/6NoD1ispJI6Qav3H QXr9NidRmCoDdwLIuOWtXZhPWusWmI8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-480-nqkSTX6APm6YGq1UGAl9LA-1; Fri, 03 Apr 2020 10:50:48 -0400 X-MC-Unique: nqkSTX6APm6YGq1UGAl9LA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1CB288018A2; Fri, 3 Apr 2020 14:50:47 +0000 (UTC) Received: from treble (ovpn-118-100.rdu2.redhat.com [10.10.118.100]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 71C7850BEE; Fri, 3 Apr 2020 14:50:46 +0000 (UTC) Date: Fri, 3 Apr 2020 09:50:44 -0500 From: Josh Poimboeuf To: Julien Thierry Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, mbenes@suse.cz Subject: Re: [PATCH] objtool: Fix off-by-one in symbol_by_offset() Message-ID: <20200403145044.fzdrywxbs7k6sq7p@treble> References: <20200403131730.32618-1-jthierry@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200403131730.32618-1-jthierry@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 03, 2020 at 02:17:30PM +0100, Julien Thierry wrote: > Sometimes, WARN_FUNC() and other users of symbol_by_offset() will > associate the first instruction of a symbol with the symbol preceding > it. > This is because symbol->offset + symbol->len is already outside of the > symbol's range. > > Signed-off-by: Julien Thierry > --- > tools/objtool/elf.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c > index 09ddc8f1def3..c4857fa3f1d1 100644 > --- a/tools/objtool/elf.c > +++ b/tools/objtool/elf.c > @@ -105,7 +105,7 @@ static int symbol_by_offset(const void *key, const struct rb_node *node) > > if (*o < s->offset) > return -1; > - if (*o > s->offset + s->len) > + if (*o >= s->offset + s->len) > return 1; > > return 0; Thanks - looks like this fixes 2a362ecc3ec9 ("objtool: Optimize find_symbol_*() and read_symbols()"). -- Josh