From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DAC5AC33C9B for ; Tue, 7 Jan 2020 19:30:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B5A6B206DB for ; Tue, 7 Jan 2020 19:30:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728801AbgAGTa5 (ORCPT ); Tue, 7 Jan 2020 14:30:57 -0500 Received: from www62.your-server.de ([213.133.104.62]:47852 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728702AbgAGTaq (ORCPT ); Tue, 7 Jan 2020 14:30:46 -0500 Received: from sslproxy02.your-server.de ([78.47.166.47]) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1iouYs-0007tt-62; Tue, 07 Jan 2020 20:30:42 +0100 Received: from [178.197.249.51] (helo=pc-9.home) by sslproxy02.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iouYr-000DeW-Nz; Tue, 07 Jan 2020 20:30:41 +0100 Subject: Re: [PATCH 5/5] bpf: Allow to resolve bpf trampoline in unwind To: Jiri Olsa Cc: Alexei Starovoitov , Jiri Olsa , Alexei Starovoitov , netdev@vger.kernel.org, bpf@vger.kernel.org, Andrii Nakryiko , Yonghong Song , Martin KaFai Lau , Jakub Kicinski , David Miller , bjorn.topel@intel.com References: <20191229143740.29143-1-jolsa@kernel.org> <20191229143740.29143-6-jolsa@kernel.org> <20200106234639.fo2ctgkb5vumayyl@ast-mbp> <20200107131554.GJ290055@krava> From: Daniel Borkmann Message-ID: <5a0fbe29-a9ec-a917-b52f-c81c96672ae8@iogearbox.net> Date: Tue, 7 Jan 2020 20:30:40 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20200107131554.GJ290055@krava> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.101.4/25687/Tue Jan 7 10:56:22 2020) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 1/7/20 2:15 PM, Jiri Olsa wrote: > On Tue, Jan 07, 2020 at 09:30:12AM +0100, Daniel Borkmann wrote: >> On 1/7/20 12:46 AM, Alexei Starovoitov wrote: >>> On Sun, Dec 29, 2019 at 03:37:40PM +0100, Jiri Olsa wrote: >>>> When unwinding the stack we need to identify each >>>> address to successfully continue. Adding latch tree >>>> to keep trampolines for quick lookup during the >>>> unwind. >>>> >>>> Signed-off-by: Jiri Olsa >>> ... >>>> +bool is_bpf_trampoline(void *addr) >>>> +{ >>>> + return latch_tree_find(addr, &tree, &tree_ops) != NULL; >>>> +} >>>> + >>>> struct bpf_trampoline *bpf_trampoline_lookup(u64 key) >>>> { >>>> struct bpf_trampoline *tr; >>>> @@ -65,6 +98,7 @@ struct bpf_trampoline *bpf_trampoline_lookup(u64 key) >>>> for (i = 0; i < BPF_TRAMP_MAX; i++) >>>> INIT_HLIST_HEAD(&tr->progs_hlist[i]); >>>> tr->image = image; >>>> + latch_tree_insert(&tr->tnode, &tree, &tree_ops); >>> >>> Thanks for the fix. I was thinking to apply it, but then realized that bpf >>> dispatcher logic has the same issue. >>> Could you generalize the fix for both? >>> May be bpf_jit_alloc_exec_page() can do latch_tree_insert() ? >>> and new version of bpf_jit_free_exec() is needed that will do latch_tree_erase(). >>> Wdyt? >> >> Also this patch is buggy since your latch lookup happens under RCU, but >> I don't see anything that waits a grace period once you remove from the >> tree. Instead you free the trampoline right away. > > thanks, did not think of that.. will (try to) fix ;-) > >> On a different question, given we have all the kallsym infrastructure >> for BPF already in place, did you look into whether it's feasible to >> make it a bit more generic to also cover JITed buffers from trampolines? > > hum, it did not occur to me that we want to see it in kallsyms, > but sure.. how about: bpf_trampoline_ ? > > key would be taken from bpf_trampoline::key as function's BTF id Yeap, I think bpf_trampoline_ would make sense here. Thanks, Daniel