Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1297493rwd; Thu, 8 Jun 2023 15:54:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5SbFZzXZb0ANy2pPchpwQKB129sAEr1z/W3qE3qh/wx5NSJ7t6Kv1YfqyjNLVvn/JNK/pV X-Received: by 2002:a05:6a20:1581:b0:110:b0ab:8798 with SMTP id h1-20020a056a20158100b00110b0ab8798mr6750427pzj.36.1686264879216; Thu, 08 Jun 2023 15:54:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686264879; cv=pass; d=google.com; s=arc-20160816; b=M6yxechBpJI9kI66Vl2mxQHsOCMDHTN97dXDAbpBWwHKgXHpAFnZ4M2dwQFevZXMoD 2mivJUw0EgjwxnwGxSmycEmbBTIlhZM6L/4P8RTUVssfVG8vjKxldR0XxSnaa1+1Ig9O 07iU73HN/L7CQm0nNYS++UmnqhwWaw+58Te1NE1uhdZWjeiofUGP97iaAz2vWZjiDzIu skvGE3Fqks6Zho/LXOZegYOyH6y3X/OsTz7NTUt0Odf95bL7ooDeD5Nc3ygIH+OkJrkq OOKAMiPV0gecDMKERcX+bn+R9AV5qQEjcxsSVlyAxYoJRJWV6R8KqBEr6Syq8GYAwIIZ tISQ== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=6VFcr740ClHDgfooQ+FLHb4V9tJxfdRe/N7zQ7funAE=; b=gg8nNc9EKEWzDZnFokJOTeIEsdDYeZFVUjQsU7MN/BbV3gKl7e0NG5l5task5cLzGO fBE/1Nm/YlUPIJGEtmKAS06KlRhEIZY+KrxvdaP+v7gTeISXIycREyPDKq0pN988dP+G hTjhMwSEfmCHecT3qRjRLxlW6L2xZwN1WAeyYhatMFiFN1zkTUxpmLMSzW/jZ112LT72 /q+QOdQW/hxc0VidenQ7fF0P3G2Cxtvgywg0EJ2L+lU3qMW/PAN5XzwhIvzHR/MIEzyR k0qRf4p1YIqISHE5XmBmu+Ur6JG05JNbzzAJQzv3PenxI1WQYU3lNOdRLbr0tEPfPCy6 f5zw== ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@templeofstupid.com header.s=dreamhost header.b=fcWyME1P; 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 85-20020a630258000000b0053f25281d15si1568470pgc.537.2023.06.08.15.54.25; Thu, 08 Jun 2023 15:54:39 -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=fcWyME1P; 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 S235685AbjFHWFt (ORCPT + 99 others); Thu, 8 Jun 2023 18:05:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236293AbjFHWFr (ORCPT ); Thu, 8 Jun 2023 18:05:47 -0400 Received: from bird.elm.relay.mailchannels.net (bird.elm.relay.mailchannels.net [23.83.212.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6E4C30D0 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 4324C5C14EB for ; Thu, 8 Jun 2023 22:05:44 +0000 (UTC) Received: from pdx1-sub0-mail-a278.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id DA22B5C11E9 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=v9mdr/1/jrsAJkdkq3lPLCQ9uAgk7RfgIrZwnNLZ5WvRonoDBmMHFmdpik7qXdLzymV33B zfH3Db/akEFGxPYFmoPLBecV+pi34wuxs//oGBzRpFh1DkZ9pCuJOF6DO1+4T4CnI91TD5 QQuLTPVZmYkC+auIKmPL8VcTu+29F+jwg0zNKvvx0Zrbhmjmf30NvbcS99Pu161PZ270eW ISS5raHEC6NG3aweOmkS0wGj0OUakz7V+I0fzK8mMyi6LPIZwckZiBpqy3hgZo4WG67RWp /SAIs2X+UAmtr1lhIvrNYBz8mBwZ6v3rieipN+j9+wAoSyDCcGGGY9k/pYlNmw== 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-fcb9f4dcf-8d4zj; 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-Name-Reign: 2d9a43d47d6fc1ad_1686261944115_1530243601 X-MC-Loop-Signature: 1686261944115:583706968 X-MC-Ingress-Time: 1686261944115 Received: from pdx1-sub0-mail-a278.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.123.193.172 (trex/6.8.1); Thu, 08 Jun 2023 22:05:44 +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-a278.dreamhost.com (Postfix) with ESMTPSA id 4QcdZH13Mbz1L4 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> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY 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 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