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 D80FDC7EE43 for ; Thu, 8 Jun 2023 22:05:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236828AbjFHWFt (ORCPT ); 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> 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