From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754737AbcAYB5U (ORCPT ); Sun, 24 Jan 2016 20:57:20 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:14556 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754535AbcAYB5R (ORCPT ); Sun, 24 Jan 2016 20:57:17 -0500 Message-ID: <56A580CE.2070408@huawei.com> Date: Mon, 25 Jan 2016 09:56:30 +0800 From: "Wangnan (F)" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Alexei Starovoitov CC: , , , Arnaldo Carvalho de Melo , Daniel Borkmann , Li Zefan , Subject: Re: [PATCH 2/2] perf bpf: Check relocation target section References: <1453454841-232334-1-git-send-email-wangnan0@huawei.com> <1453454841-232334-3-git-send-email-wangnan0@huawei.com> <20160122171102.GB9608@ast-mbp.thefacebook.com> In-Reply-To: <20160122171102.GB9608@ast-mbp.thefacebook.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.0A090201.56A580E1.001E,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: 75adb77df497b35fa1d4bba8ca3d0041 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2016/1/23 1:11, Alexei Starovoitov wrote: > On Fri, Jan 22, 2016 at 09:27:21AM +0000, Wang Nan wrote: >> Libbpf should check target section before doing relocation to ensure >> the relocation is correct. If not, a bug in LLVM causes error. See [1]. >> Also, if an incorrect BPF script uses both global variable and >> map, global variable whould be treated as map and be relocated >> without error. >> >> This patch saves id of map section into obj->efile and compare >> target section of a relocation symbol against it during relocation. > ... >> [1] https://llvm.org/bugs/show_bug.cgi?id=26243 > ... >> Signed-off-by: Wang Nan >> >> + if (sym.st_shndx != maps_shndx) { >> + pr_warning("Program '%s' contains non-map related relo data pointing to section %u\n", >> + prog->section_name, sym.st_shndx); >> + return -LIBBPF_ERRNO__RELOC; >> + } > May be 'pr_err' instead of 'pr_warning', since such program will fail > to load by kernel anyway. Libbpf doesn't issue pr_error even in fatal exception because it doesn't define pr_err at all. It reports error code and let perf deal with error. Thank you. > Looks good otherwise. > Acked-by: Alexei Starovoitov >