From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1AFDB1B142D; Thu, 23 Apr 2026 08:32:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776933156; cv=none; b=WJa7FooaZ/lidnNesEDe14Q0k9wDxlArr+fAuAdgts8OVSv2Rww1bYiZQcbcryR39eF8iDvPI2gYlrPO1/LTI5g06zwiUH/ZSWB2xuAG5OE5cuiJKNzk8vfGMQXZtNx/WIOX9v8W3pkuaXSb4MCmWOtfiPH9hLqlvJyfFl/LnKY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776933156; c=relaxed/simple; bh=uK00LG0iDpIMEjBQXm4byZgGPeE/DGU+c8Xl9e9qUVs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=KIReglL4wwgBb7btA5qoRMsbf1mwRUYBFBOj2ApaKLu6OkctBdgsYhY0TBGsucoC+cI5OW/13bdCs0PNmnxdyzy9tWROUdwBbXLWAcOGVSTlRBHxUy2dGaz+Bcu2NZ7vd40LAa7oOXtb6EME0hy4zxxH0F0Hb5bc1TFLzNWcJq8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=iZerBmu7; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="iZerBmu7" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=e/PUtRuyjXu+9h0XjZ2apQLxXIpOKsrznUMF9nTbE0Q=; b=iZerBmu7+PJ8hgxjahYqrbbN/F 82eyxOs2+bSHdpkOXRlY6+ku07UjA4L09k68N/4SkkCNarkHfums1689CoctrB9dudHycBpNkWs+k m9MlOyiRJX6xc2q/ewgi+9mBgbCIa+hHzpGz9jrxwoBVHdPzki/k2suc4HTKn4YLnq48Na0R6Zl61 jS/SUa5jh+MRrGIfqfoCSihSO/OXEEg9GRzJNCc2441bG1lDDui4WUVdwR280Lx6IaZCfcv9+90ls qL3d4OP9B6VdTvCiiICVtK8M7etryQycRjwWzWauN28of8C9hOrOkq7IKpmbGPG5R3JkUDCz+zI/H b3McTseA==; Received: from 2001-1c00-8d85-4b00-266e-96ff-fe07-7dcc.cable.dynamic.v6.ziggo.nl ([2001:1c00:8d85:4b00:266e:96ff:fe07:7dcc] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1wFpU7-0000000D7N9-3bJn; Thu, 23 Apr 2026 08:32:31 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 2E2773008E2; Thu, 23 Apr 2026 10:32:31 +0200 (CEST) Date: Thu, 23 Apr 2026 10:32:31 +0200 From: Peter Zijlstra To: Josh Poimboeuf Cc: x86@kernel.org, linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, Joe Lawrence , Song Liu , Miroslav Benes , Petr Mladek Subject: Re: [PATCH 17/48] objtool: Fix reloc hash collision in find_reloc_by_dest_range() Message-ID: <20260423083231.GS3126523@noisy.programming.kicks-ass.net> References: <09dab1995c4ba6ca29dd70b0a7472f1a2975fefd.1776916871.git.jpoimboe@kernel.org> Precedence: bulk X-Mailing-List: live-patching@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <09dab1995c4ba6ca29dd70b0a7472f1a2975fefd.1776916871.git.jpoimboe@kernel.org> On Wed, Apr 22, 2026 at 09:03:45PM -0700, Josh Poimboeuf wrote: > In find_reloc_by_dest_range(), hash collisions can cause a high-offset > relocation to appear when probing a low-offset hash bucket. > > Only return early when the best match found so far genuinely belongs to > the current bucket (its offset is within the bucket's stride range). > Otherwise, continue scanning later buckets which may contain > lower-offset matches. Maybe mention (and or add a comment to the function) that in case of multiple matches in the given range, it will return the lowest address one. Acked-by: Peter Zijlstra (Intel) > Fixes: 74b873e49d92 ("objtool: Optimize find_rela_by_dest_range()") > Signed-off-by: Josh Poimboeuf > --- > tools/objtool/elf.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c > index a5486e172e5c..c4cb371e72b2 100644 > --- a/tools/objtool/elf.c > +++ b/tools/objtool/elf.c > @@ -370,11 +370,11 @@ struct reloc *find_reloc_by_dest_range(const struct elf *elf, struct section *se > r = reloc; > } > } > - if (r) > + if (r && (reloc_offset(r) & OFFSET_STRIDE_MASK) == o) > return r; > } > > - return NULL; > + return r; > } > > struct reloc *find_reloc_by_dest(const struct elf *elf, struct section *sec, unsigned long offset) > -- > 2.53.0 >