Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1008977ybh; Tue, 10 Mar 2020 12:39:56 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvJXBJJyI/VXlBevqhbFtGrVMQQuryA+HR2qc4tUasXA8xoLcFtX2a+L1qmZYZNKTYPRZFc X-Received: by 2002:aca:ebca:: with SMTP id j193mr2313170oih.124.1583869196091; Tue, 10 Mar 2020 12:39:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583869196; cv=none; d=google.com; s=arc-20160816; b=yBpqwIh55xYjPGmyLvVr7RQSvFYBR+gwDGlYcvUQ2mqCuBj1nLycS5Km71Mg+mmMA9 IDdEjGvWeb76pd4yoHjUF8PAB/Utel+QQOtz7CYCprdw6JERJXCeVWaVPI7pMeGvInvN PQ/HT5TK8R3Z21mKDqutEJcSQryJQeInLgWWWFp13DpMe8y2pByoAgoYI3x/d9k8wdR+ /VCR+AeNk109S8kODNZZV2+DUB9RHhsN4hyebWXT4oPLAoyrRj190k+z5c+m8P+iMxdj tbfLoTQvnkJbAUxpXZMTwWs/2RFk8uQLDEdyiFjBdgHBVIGTpe6CdJdEiNLp1D34ExiG xSoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=3YFIf04BrW8+Bo/jQGrNoKlxOXvbpj/GKs6iSMIzVfo=; b=qHV7j0frKZJl4PM28djpkj6OS1HSjV8XcNFEg4J8uSeiZgp8iBMFH9trMAaA/RKmOm xc1VGyAcDe6wa2WhbCP18/KVu8ipSpEaRQaCqL5rnRsKWBwn+BPZ+OnOKyMNvsFQdMjZ DLkYEwH0kBylH9ry/TeCCqcABTvA9JhpWJi9/nXyfVNFyGLVqhKPge3h18ILesu+u4Qa uhnu61/5e64GHH4/wQt0PQl4i9g2/YXgLJMV7s964dD/LM79ZAsXhz1kX9cTW9ydEeVR 0YKYt4BqYnhkkwCKoj35Xzoh6uXb0mcnFOP1UZXBtvXqASXu6hRlzoSuYVW13Tv0LyNJ 7e9w== 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 d23si2864775oig.118.2020.03.10.12.39.39; Tue, 10 Mar 2020 12:39:56 -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 S1727540AbgCJTiX (ORCPT + 99 others); Tue, 10 Mar 2020 15:38:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:35214 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726729AbgCJTiW (ORCPT ); Tue, 10 Mar 2020 15:38:22 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EA3C3208E4; Tue, 10 Mar 2020 19:38:21 +0000 (UTC) Date: Tue, 10 Mar 2020 15:38:20 -0400 From: Steven Rostedt To: Artem Savkov Cc: linux-kernel@vger.kernel.org, live-patching@vger.kernel.org Subject: Re: [PATCH v2] ftrace: return first found result in lookup_rec() Message-ID: <20200310153820.436a8583@gandalf.local.home> In-Reply-To: <20200306174317.21699-1-asavkov@redhat.com> References: <20200306121246.5dac2573@gandalf.local.home> <20200306174317.21699-1-asavkov@redhat.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 6 Mar 2020 18:43:17 +0100 Artem Savkov wrote: > It appears that ip ranges can overlap so. In that case lookup_rec() > returns whatever results it got last even if it found nothing in last > searched page. > > This breaks an obscure livepatch late module patching usecase: > - load livepatch > - load the patched module > - unload livepatch > - try to load livepatch again > > To fix this return from lookup_rec() as soon as it found the record > containing searched-for ip. This used to be this way prior lookup_rec() > introduction. > > v2: break instead of two returns Thanks Artem, I applied your patch. But just an FYI, it's best to place the "v2" statement below the three dashes "---" so that it doesn't get pulled into the git commit when this patch is applied via a script. -- Steve > > Fixes: 7e16f581a817 ("ftrace: Separate out functionality from ftrace_location_range()") > Signed-off-by: Artem Savkov > --- > kernel/trace/ftrace.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c > index 3f7ee102868a..fd81c7de77a7 100644 > --- a/kernel/trace/ftrace.c > +++ b/kernel/trace/ftrace.c > @@ -1547,6 +1547,8 @@ static struct dyn_ftrace *lookup_rec(unsigned long start, unsigned long end) > rec = bsearch(&key, pg->records, pg->index, > sizeof(struct dyn_ftrace), > ftrace_cmp_recs); > + if (rec) > + break; > } > return rec; > }