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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EFC1C7EE25 for ; Thu, 8 Jun 2023 22:05:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236399AbjFHWFs (ORCPT ); Thu, 8 Jun 2023 18:05:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230095AbjFHWFr (ORCPT ); Thu, 8 Jun 2023 18:05:47 -0400 Received: from bee.birch.relay.mailchannels.net (bee.birch.relay.mailchannels.net [23.83.209.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A370D30CD for ; Thu, 8 Jun 2023 15:05:44 -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 B6328100FE8 for ; Thu, 8 Jun 2023 22:05:43 +0000 (UTC) Received: from pdx1-sub0-mail-a235.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 49969100C8D for ; Thu, 8 Jun 2023 22:05:43 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1686261943; a=rsa-sha256; cv=none; b=Etxo91sNX9yETiip/Qq3z42bZGkclwrttfdR6poRw2FiN4hqTjMuLJQofJpY1U10uu5gD/ HdmlcBHFAktezxgMUrmDUBTTblvQj0wP0Ahf7lR+d1dA5aboejk3fk8cbjGst6spDESZKU iDgzQCDWyULCJOsib3s4wS3ofcobz1rV1a3QY5hh2LdMl/TZto3D7cxcgbZ0UoCX/fKDNK cxzJdUl3ajVioJ755sTS/pS79qFuBWstFmGYBG2UuCriwuFnG2ikin9kBLZIcJYdhy5hpa 3/DEsQFRob4hzlsnXtZPk59lLIPp4enidnoF6ddQU7SLqymjIuScIggGQYZh5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1686261943; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=6VFcr740ClHDgfooQ+FLHb4V9tJxfdRe/N7zQ7funAE=; b=R/eu2UYbnNC4peOZJCqsMZ+CrN6OXtZJ141cA0+30q7cxMER/qq6qpYj0kZTCrv4Cmc6y+ aojBP7w7zpaG9O5H2A1FLPwq+rlOUODgxQJRnvT3KOVluB+w640lge1pD+X+QwnQIjTrsB /zXHN9fn5oGbDdhEbqU7bHLW3LabtTOPKZq5a7oSv/mRyD4rVy50Bd0Pybmaf6VOkof2Hq I9ayC1LO8GpqeDu3Qgoh13bkYZLrSP/N5ay/HJF/sAeTEoeNFtNgCphtjaHCkS7nWUrACe DFyQB2hkYlj3JlbA7LtAxD24I+LMrpFwT+hE8xqNF3HH1u1N+lMaam6kYFJ1cA== ARC-Authentication-Results: i=1; rspamd-6f5cfd578c-c6h9m; auth=pass smtp.auth=dreamhost smtp.mailfrom=kjlx@templeofstupid.com X-Sender-Id: dreamhost|x-authsender|kjlx@templeofstupid.com X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|kjlx@templeofstupid.com X-MailChannels-Auth-Id: dreamhost X-Tangy-Eyes: 105959cc68f969b7_1686261943525_2050693864 X-MC-Loop-Signature: 1686261943525:1992703612 X-MC-Ingress-Time: 1686261943524 Received: from pdx1-sub0-mail-a235.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.120.163.30 (trex/6.8.1); Thu, 08 Jun 2023 22:05:43 +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-a235.dreamhost.com (Postfix) with ESMTPSA id 4QcdZH0Ps2z76 for ; Thu, 8 Jun 2023 15:05:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=templeofstupid.com; s=dreamhost; t=1686261943; bh=6VFcr740ClHDgfooQ+FLHb4V9tJxfdRe/N7zQ7funAE=; h=Date:From:To:Cc:Subject:Content-Type; b=fcWyME1PTxbcYwVPtejuIEGcMXGEkL8T6ddygN281e8u+RFnlTxdv4vSPPJtIhu3G qx3B8C5XxtwKHUse6/Utr33nINbAXeENOMcXU5ZX2q3A0IQreZZomJupaWTqr5WrN/ LWi0PaiU7QyHVgI2H8zkDd6/3NWY8p2GZTFI67bo= Received: from johansen (uid 1000) (envelope-from kjlx@templeofstupid.com) id e0042 by kmjvbox (DragonFly Mail Agent v0.12); Thu, 08 Jun 2023 15:05:42 -0700 Date: Thu, 8 Jun 2023 15:05:42 -0700 From: Krister Johansen To: Yonghong Song Cc: bpf@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH bpf v2 2/2] bpf: ensure main program has an extable Message-ID: <20230608220542.GA2057@templeofstupid.com> References: <33c52b4c-2a16-7578-f782-51267deff750@meta.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <33c52b4c-2a16-7578-f782-51267deff750@meta.com> Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Thu, Jun 08, 2023 at 10:38:12AM -0700, Yonghong Song wrote: > > > On 6/7/23 2:04 PM, Krister Johansen wrote: > > When bpf subprograms are in use, the main program is not jit'd after the > > subprograms because jit_subprogs sets a value for prog->bpf_func upon > > success. Subsequent calls to the JIT are bypassed when this value is > > non-NULL. This leads to a situation where the main program and its > > func[0] counterpart are both in the bpf kallsyms tree, but only func[0] > > has an extable. Extables are only created during JIT. Now there are > > two nearly identical program ksym entries in the tree, but only one has > > an extable. Depending upon how the entries are placed, there's a chance > > that a fault will call search_extable on the aux with the NULL entry. > > > > Since jit_subprogs already copies state from func[0] to the main > > program, include the extable pointer in this state duplication. The > > alternative is to skip adding the main program to the bpf_kallsyms > > table, but that would mean adding a check for subprograms into the > > middle of bpf_prog_load. > > I think having two early identical program ksym entries is bad. > When people 'cat /proc/kallsyms | grep ', > they will find two programs with identical kernel address but different > hash value. This is just very confusing. I think removing the > duplicate in kallsyms is better from user's perspective. Thanks for all the feedback. In terms of resolving this confusion my inclination is to use the main program. That way users see in kallsyms the same tag that is reported by bpftool. On the other hand, the tag in kallsyms won't match the sha1 of that actual chunk of code. Is anything relying on the hash in the tag and the digest of the code agreeing? -K