Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp272509ybi; Wed, 29 May 2019 21:07:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqzu+xOPCGz16s7EvR7sXikkeZrme7DsypcIOJ7/YZ1lTVSsAGBuvWIxZwWpshNezb9cVCOH X-Received: by 2002:a62:6241:: with SMTP id w62mr1720536pfb.226.1559189235813; Wed, 29 May 2019 21:07:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559189235; cv=none; d=google.com; s=arc-20160816; b=quzTVZEK3KRecIlI4ncwpKGxF8pwsju8nqyvcjvSYnaBfDGlf5iBxIs99pG9cwFshI VzYH3mJqZtgKcmo5pLLaKHwNbgTrji41nm7RxN/3yoTTyeyJ281bkGzlDYObZdGMcKFB QRB+krlxmfb/YkpqZqUnmqLH772x+Bw9tx0h4Bza7TB7snd3J0VnmdpgH0LiPCtq8Exs yKcRpsf9UrZjx4I0+4JoYap+w2eHElidlvnk+HAJ+1L5vlLZhuCWdUWLlM6aUtN89Cke mIvB0uo7rJSkKPcA+ZIXi//m5Gvr9Pt0FlrWMycUbkokuRtJW3quWaT0G0PS5Lp1k+mw ME/Q== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/ofe/wDvCvTGU9Etay+bqy6lGczUd0MIR9dGuJeA3N4=; b=eyMen58p/m39taeksIMY2WPfPs+iJTnT86N97YeV9zQ+coejD/Ywv16yACsLnTL3aQ LZQ2AYyazdw2vz4JZEG2EQpK83BmQ61jGQGewFmlQ0Oo4jeMKN4+vKUc1B+iih+EIxS3 CRRMPN5d3wOsHfNRLiT8lAV/GmkuOL//IuJxeB5zOrMar5FsDenIsV1zMl/lxxtJQ1h0 dX1QzMwdORRnYoudMziU+hFxB2DYDsqwMGw1iM5+XIc9P5DI2qjOYRN3ROrJZtmKdaaB 6N5MS8PQwshXP2BDnzeiXBpXcfiHRSeFY++gBpzruZql7AiF8r+tj0EdSkc/6kRfBqCM jpNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MRIvhOc2; 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 q205si2261779pfc.151.2019.05.29.21.06.58; Wed, 29 May 2019 21:07:15 -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=@kernel.org header.s=default header.b=MRIvhOc2; 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 S1726830AbfE3EFw (ORCPT + 99 others); Thu, 30 May 2019 00:05:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:47936 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730354AbfE3DRj (ORCPT ); Wed, 29 May 2019 23:17:39 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (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 A586A2465C; Thu, 30 May 2019 03:17:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186258; bh=iN+ZevbI47rr7dBCWtilagq3hg+Z4snnLSYgPyCO8hg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MRIvhOc2MRUynSMm1ozNdHLMeVRkXeUv+t09BbDag/55PjPYO60TAeFaZh2ETyVBx 197C0b4PtomCT6VnCN1CSJ2OSAnBUCGi4dEbHs6BS2NsmkydseiVIutnNomB/pnelW szrxqmIkgphy2zX4kwCtuuBOu4sW1L1mBsq+GTyk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Daniel T. Lee" , Daniel Borkmann , Sasha Levin Subject: [PATCH 4.19 190/276] selftests/bpf: ksym_search wont check symbols exists Date: Wed, 29 May 2019 20:05:48 -0700 Message-Id: <20190530030537.066337512@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030523.133519668@linuxfoundation.org> References: <20190530030523.133519668@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 0979ff7992fb6f4eb837995b12f4071dcafebd2d ] Currently, ksym_search located at trace_helpers won't check symbols are existing or not. In ksym_search, when symbol is not found, it will return &syms[0](_stext). But when the kernel symbols are not loaded, it will return NULL, which is not a desired action. This commit will add verification logic whether symbols are loaded prior to the symbol search. Signed-off-by: Daniel T. Lee Signed-off-by: Daniel Borkmann Signed-off-by: Sasha Levin --- tools/testing/selftests/bpf/trace_helpers.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/testing/selftests/bpf/trace_helpers.c b/tools/testing/selftests/bpf/trace_helpers.c index cabe2a3a3b300..cf156b3536798 100644 --- a/tools/testing/selftests/bpf/trace_helpers.c +++ b/tools/testing/selftests/bpf/trace_helpers.c @@ -51,6 +51,10 @@ struct ksym *ksym_search(long key) int start = 0, end = sym_cnt; int result; + /* kallsyms not loaded. return NULL */ + if (sym_cnt <= 0) + return NULL; + while (start < end) { size_t mid = start + (end - start) / 2; -- 2.20.1