From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751650AbcFWCHg (ORCPT ); Wed, 22 Jun 2016 22:07:36 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:11854 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751133AbcFWCHf (ORCPT ); Wed, 22 Jun 2016 22:07:35 -0400 Subject: Re: [PATCH 5/5] perf tools: Fix NULL pointer deference when vdso not found To: He Kuang , , , , , , , , , , , , , , , , References: <1466578626-92406-1-git-send-email-hekuang@huawei.com> <1466578626-92406-6-git-send-email-hekuang@huawei.com> CC: From: "Wangnan (F)" Message-ID: <576B433F.4080202@huawei.com> Date: Thu, 23 Jun 2016 10:02:39 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <1466578626-92406-6-git-send-email-hekuang@huawei.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.111.66.109] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090203.576B4358.00BD,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 014f538b4db1d53886c4d5741bb3530e Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, This patch fixes a real crash problem when we do 'perf report' on an arm64 platform with arm32 program. It is introduced by commit f9b2bdf228 ("perf tools: Find vdso with the consider of cross-platform"). From dmesg report, perf crashes in dso__type() because dso is NULL. Still don't know why on x86 it never crash, but it is obviously that we need to check the return vaule from __dso__find(): it can be NULL. So please consider pulling. Thank you. On 2016/6/22 14:57, He Kuang wrote: > We should check if 'dso' is a null pointer before passing it to the > function dso__type(), otherwise a segfault will be raised in > dso__data_get_fd(). In function machine__find_vdso(), the return value > checking of 'dso' is missed and this patch fixes this issue. > > Signed-off-by: He Kuang > --- > tools/perf/util/vdso.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/perf/util/vdso.c b/tools/perf/util/vdso.c > index 8f81c41..7bdcad4 100644 > --- a/tools/perf/util/vdso.c > +++ b/tools/perf/util/vdso.c > @@ -296,7 +296,7 @@ static struct dso *machine__find_vdso(struct machine *machine, > if (!dso) { > dso = __dsos__find(&machine->dsos, DSO__NAME_VDSO, > true); > - if (dso_type != dso__type(dso, machine)) > + if (dso && dso_type != dso__type(dso, machine)) > dso = NULL; > } > break;