Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6418141rwd; Mon, 5 Jun 2023 18:29:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5CthGG/0tjNlvLmBfIB9GBYJ5dA/Fr+oU/OcFRpVRnh8jYbdA/Q+HIV1rsznAv7BPZPXEj X-Received: by 2002:a05:620a:4b4b:b0:75e:cc28:2da8 with SMTP id su11-20020a05620a4b4b00b0075ecc282da8mr323499qkn.27.1686014992888; Mon, 05 Jun 2023 18:29:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686014992; cv=pass; d=google.com; s=arc-20160816; b=ZqGve9mXlccB7+LIEJIYL35ZtSqpZCZ+u8qyPE1RpmHXLHUtX+7WvLq6q9B+GndAhk 0puHZdtLavoKyG1HN0jcVi60h3vvWPIHw+IkjQSYWjm25zimH8Mb0BPqEDpeewU1jgY9 AxYLtBTSkQZf0izmAcEfWBrmFgekcoJ6mJ6wumHD8tUbYJdcZndyJGMuYZdjAvOyrF0t cQ31y1Ow3465zmxCQUB1HRqotBGvCEEhsoFdoAnzBp+zow7dUgWBEOMNVvp5AE3332As OKAEXY8l9pSZXI3Kj3gIFMtAtC7U8EA96SDYi3hgmpfxcMgx/rpofQm3GqBUnvQHhmG7 23gA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=30Pm4xz1UlaCRE7iqpDJat0fxdm1zNEZBrIPg1VFjPA=; b=jigeihjKfptvqCSqI53k+FiK8GKUQgOH3bHOBljyJIVbd3PBrjnLUUi01EJbV61Jbo 03H6L3slFbifNm/21tEiro45BlVPRmKuRO+vI/nBXIFEyvlX3oFMjfYTTL87KPQqJHFU evjA5vxNxz+cyhmc7+PBloHH5ICoLbSe0MjpLEL0eZfgIlke/q+BjYOTVgQ0u87tyvmn 270u4yshDyRiC9VsnqVUrpfv/WPPxwID1igAyMWJ6YYBfz/sxGErfI3BeFqRR0iXq922 RbJFeWYYnTbLbh250qdUJKLEqf7OftMmAUWexF75LwBPFqg5e2ktrHV0USxDr2YE8vru 6cXA== ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@templeofstupid.com header.s=dreamhost header.b="r3U3/n3U"; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o25-20020a05620a15d900b0075b3484f391si5014257qkm.426.2023.06.05.18.29.38; Mon, 05 Jun 2023 18:29:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@templeofstupid.com header.s=dreamhost header.b="r3U3/n3U"; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232320AbjFFBD7 (ORCPT + 99 others); Mon, 5 Jun 2023 21:03:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229681AbjFFBD4 (ORCPT ); Mon, 5 Jun 2023 21:03:56 -0400 X-Greylist: delayed 1023 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 05 Jun 2023 18:03:45 PDT Received: from cheetah.elm.relay.mailchannels.net (cheetah.elm.relay.mailchannels.net [23.83.212.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D90FA131 for ; Mon, 5 Jun 2023 18:03:45 -0700 (PDT) X-Sender-Id: dreamhost|x-authsender|kjlx@templeofstupid.com Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 0A7D5261A5E for ; Tue, 6 Jun 2023 00:46:42 +0000 (UTC) Received: from pdx1-sub0-mail-a232.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 9881A261E81 for ; Tue, 6 Jun 2023 00:46:41 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1686012401; a=rsa-sha256; cv=none; b=kfnxFT+SicQc8Z52f26H64ZYoJfWVMHFeLAUR5a51283Lq5oUXvUyQ14ZeFs5mU+5Ny1Lg yih0OZjGi+ByndZbld69/dXodBde6WjNH68sc5bHu6PceA8vdya6J4bm5TP3LmofZHnwpC d1Gxv1XBpjLhtLetYbGsrc4vTrGPrKd0lfhNy9QOjIEbBFH8V48pUysEkuYnFAFyZlDu57 /GeHMh/5FClYdbWdC2XvZNkKmZtc6xQJl2ZBhDLPpUYc8kPDpdvw8IMvEFwigqtAdrYd3R QuYLR5dok31eTkUIWmk9eKPec7Z8g89vHqYRJoyWLcHGRmwUqKSGdfH6Kz7RnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1686012401; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=30Pm4xz1UlaCRE7iqpDJat0fxdm1zNEZBrIPg1VFjPA=; b=HCXg9gw6tP83DcvIG7CHlaEBtzIru9t+UAnGUV4/vus7Bb3G4CneIZtHD2Uu7/7YO7armk tqQ+ZtnPARZYdZyP9XdT69+k3S6m7l9DdLLboUmytVkvYT+jFvQAVEr9hWQU1s8gQXi9xs R978uDRlr37+X/60tHYhyhr6mhBZo78SMh3Xbnk0uH+yKESuaofXOFzAAL6J6a8E3T+nNz aO5c+9XMy2d1QRNgBJh+BzorEJ7gSF0jza49KA1V18WDInn/JY/kmBLPsz+7nd0p+gmJaZ uM7QHrfJJ9RS7lamxLiplymG69J+MABLx/c95KTYT2pLneiIJTDEv3mGKZOl8w== ARC-Authentication-Results: i=1; rspamd-56648fb6f9-h5qjr; auth=pass smtp.auth=dreamhost smtp.mailfrom=kjlx@templeofstupid.com X-Sender-Id: dreamhost|x-authsender|kjlx@templeofstupid.com X-MC-Relay: Good X-MailChannels-SenderId: dreamhost|x-authsender|kjlx@templeofstupid.com X-MailChannels-Auth-Id: dreamhost X-Spot-Name: 4aa1acf52fae5fe5_1686012401843_141928237 X-MC-Loop-Signature: 1686012401842:1522777256 X-MC-Ingress-Time: 1686012401842 Received: from pdx1-sub0-mail-a232.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.119.120.24 (trex/6.8.1); Tue, 06 Jun 2023 00:46:41 +0000 Received: from kmjvbox (c-73-93-64-36.hsd1.ca.comcast.net [73.93.64.36]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kjlx@templeofstupid.com) by pdx1-sub0-mail-a232.dreamhost.com (Postfix) with ESMTPSA id 4QZsHN5b1sztD for ; Mon, 5 Jun 2023 17:46:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=templeofstupid.com; s=dreamhost; t=1686012400; bh=30Pm4xz1UlaCRE7iqpDJat0fxdm1zNEZBrIPg1VFjPA=; h=Date:From:To:Cc:Subject:Content-Type:Content-Transfer-Encoding; b=r3U3/n3Udn+774UyOUt2mmHnvq5ReXmfwZD6PALez0allvnBn1UEjLG2p0YjqHoj8 SZ0UaWb6wehWoeW7IXFQRhlHGXkWnWyNc2DFcFnE+khJ5Jh3T44nvEvt/i4zJSVyDa oeoxwkvByhPj7S5lRAypnCykFibWxPCz5hGWNCzU= Received: from johansen (uid 1000) (envelope-from kjlx@templeofstupid.com) id e0062 by kmjvbox (DragonFly Mail Agent v0.12); Mon, 05 Jun 2023 17:41:39 -0700 Date: Mon, 5 Jun 2023 17:41:39 -0700 From: Krister Johansen To: Alexei Starovoitov Cc: Krister Johansen , bpf , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer , Nathan Chancellor , Nick Desaulniers , Tom Rix , LKML , Network Development , clang-built-linux , stable Subject: Re: [PATCH bpf] bpf: search_bpf_extables should search subprogram extables Message-ID: <20230606004139.GE1977@templeofstupid.com> References: <20230605164955.GA1977@templeofstupid.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 05, 2023 at 04:30:29PM -0700, Alexei Starovoitov wrote: > On Mon, Jun 5, 2023 at 9:50 AM Krister Johansen wrote: > > + if (!aux->func[i]->aux->num_exentries || > > + aux->func[i]->aux->extable == NULL) > > + continue; > > + e = search_extable(aux->func[i]->aux->extable, > > + aux->func[i]->aux->num_exentries, addr); > > + } > > + } > > something odd here. > We do bpf_prog_kallsyms_add(func[i]); for each subprog. > So bpf_prog_ksym_find() in search_bpf_extables() > should be finding ksym and extable of the subprog > and not the main prog. > The bug is probably elsewhere. I have a kdump (or more) of this bug so if there's additional state you'd like me to share, let me know. With your comments in mind, I took another look at the ksym fields in the aux structs. I have this in the main program: ksym = { start = 18446744072638420852, end = 18446744072638423040, name = <...> lnode = { next = 0xffff88d9c1065168, prev = 0xffff88da91609168 }, tnode = { node = {{ __rb_parent_color = 18446613068361611640, rb_right = 0xffff88da91609178, rb_left = 0xffff88d9f0c5a578 }, { __rb_parent_color = 18446613068361611664, rb_right = 0xffff88da91609190, rb_left = 0xffff88d9f0c5a590 }} }, prog = true }, and this in the func[0] subprogram: ksym = { start = 18446744072638420852, end = 18446744072638423040, name = <...> lnode = { next = 0xffff88da91609168, prev = 0xffffffff981f8990 }, tnode = { node = {{ __rb_parent_color = 18446613068361606520, rb_right = 0x0, rb_left = 0x0 }, { __rb_parent_color = 18446613068361606544, rb_right = 0x0, rb_left = 0x0 }} }, prog = true }, That sure looks like func[0] is a leaf in the rbtree and the main program is an intermediate node with leaves. If that's the case, then bpf_prog_ksym_find may have found the main program instead of the subprogram. In that case, do you think it's better to skip the main program's call to bpf_prog_ksym_set_addr() if it has subprograms instead of searching for subprograms if the main program is found? -K