Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1860453rwd; Tue, 13 Jun 2023 15:39:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6jZo05jgbeLY53bBJyNfAchfhNRJt+GmZGIPZq2L/ck/cLAyF2j8VMQdhCfJxT/pF7o0X/ X-Received: by 2002:a17:907:d1b:b0:953:8249:1834 with SMTP id gn27-20020a1709070d1b00b0095382491834mr17547629ejc.16.1686695991789; Tue, 13 Jun 2023 15:39:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686695991; cv=none; d=google.com; s=arc-20160816; b=gqUDi1cxhtrS6j1vYWjTHN7njD3LZLygmMtqlNf+bK9feNbPAngTPA/s8yr7miuNZE +QejaxA95v5tKT1Uk91TQ1uM0GxR7Br6vFW3pUq24JfXFqqUsl2LrRHm+Jwl+TEKKDfA MJKhpoQCwgP+p2dHpi41CpGtWtfjdwxzRslqkM/6cM3ksVfENsw/ZDQimWqhEi9uKyet evUecLzONPuFAKeHMsPWe8xSYZU6NGoyzix1hsTx9ZHCTl/MEMet44V+PsQJpQveG8Jq r2yprd6pEd25iIHVeC/aWLy+zPZh7J3anyuAWys5TWvij+Eu73meUNG1MJYZodR+p/1B qGjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=NYeMigch2qnrSoGYhm73AILcfdoJpBTi7JKRyKYYyCk=; b=vPwWdDWegv3Vmgl495oL+UtSlIqlTe9g+/xswmJIWqSzKIlGG56gLgyKMzqjpiN/3u 2w6o2muPPB6Zclm/zPRXQHWVxIxjo7lzTzi9eCuWxbgPbdzz7qoeh9HtSD3IhWb4zO9C wqP4iLe4RNaozO41DQ1NNOoANW8Ewa0XF8ISmrLE46q/UDK4LoKAotBCAGOKQzfMeHvf BtAniWs6zzqCtQiK/MBbrxJnct4mvX+YQ+P9zNW+zH3X4x0uvRu4KqFqFEnw25dC2ZqP 9nedPc7wWKD5j/j14t4p0O1C16vSd0QjkShL6zzOPRebdTQRpiaQjOwakSyO/OkVS2a1 sjtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=PZCesWE4; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p18-20020a170906141200b00977d02fd72fsi4190252ejc.722.2023.06.13.15.39.26; Tue, 13 Jun 2023 15:39:51 -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=pass header.i=@gmail.com header.s=20221208 header.b=PZCesWE4; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234663AbjFMWUY (ORCPT + 99 others); Tue, 13 Jun 2023 18:20:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235279AbjFMWUS (ORCPT ); Tue, 13 Jun 2023 18:20:18 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3E8E1FCE; Tue, 13 Jun 2023 15:20:06 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2b1ac373c9eso344491fa.0; Tue, 13 Jun 2023 15:20:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686694805; x=1689286805; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=NYeMigch2qnrSoGYhm73AILcfdoJpBTi7JKRyKYYyCk=; b=PZCesWE4DaYOP18PmGDorKj9OLJ3ApomZcQzCge4oFExlX8JTrnjBV/KTYwd05NoAP KKeVhguMor5LJsM2yCCJ8PUW2w1Dq/yqjioNmhkUQmOpcCZTnk1K48r8I5LomoRpIThu Xwl/7j4WMhEbZfouIdiGnJyrEcwY6bdiYCWD9fymCGPiIoMCSEEKaldqqdeCNp99UvEi CaeFH1WLWuiAe9q+MF5bWzUj4+3CXjwAg6x1poUjQ3aWf6qcW2Pnu0aUGeWN+lf8OVYU ANUfZokY/ed1pKKYBkkS0bELeIcZOSFnH2ly0YthjYXw+Qn/XHkA9c+pOrM4zT1UVB3y kfog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686694805; x=1689286805; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NYeMigch2qnrSoGYhm73AILcfdoJpBTi7JKRyKYYyCk=; b=eUR/LM7BfjkjEn/WgUgYNoLa6YPrSB4mpLyN4YghA/bkEyxpw7L/lohEr2A2ZZ7M8n 1bTDRKEa3mr3wzUjxPfRu+qfu2ho9pk/vBobSWoGaU9lElV1hgCqvI9Z+VdPHr7BO+wN o7Onkrs/EQ4Y+kLrKNUKF2r3dcoQiTXKJrNwaDTWtjTjmJcQzkCy3mysEPy1f/mjFkI/ hnIoQLcv1rBJrzQPoT8zLMIJ7YRcBjQ8/KXFxPMzGTHbiPw1zbg2oFHsA+1TAqkC36AK S68BoCvm8tW9Yzt/tDEGjkAyK2nz/KOUkEWi6Jr15KNcBHzWyimswMqqdGvD8S+NDNnF Cr4A== X-Gm-Message-State: AC+VfDwIAjuddBIIqlLEZHbFvfmtbNn4p524GTL+J2GEbA2G3xJXUIAt oUrzgWa0VEqCPhMhysMmjntW04WkGh3r4exM/iv+Nxrt X-Received: by 2002:a2e:a0ce:0:b0:2af:1dd5:b068 with SMTP id f14-20020a2ea0ce000000b002af1dd5b068mr5939374ljm.48.1686694804634; Tue, 13 Jun 2023 15:20:04 -0700 (PDT) MIME-Version: 1.0 References: <6de9b2f4b4724ef56efbb0339daaa66c8b68b1e7.1686616663.git.kjlx@templeofstupid.com> In-Reply-To: <6de9b2f4b4724ef56efbb0339daaa66c8b68b1e7.1686616663.git.kjlx@templeofstupid.com> From: Alexei Starovoitov Date: Tue, 13 Jun 2023 15:19:52 -0700 Message-ID: Subject: Re: [PATCH bpf v5 1/2] bpf: ensure main program has an extable To: Krister Johansen Cc: bpf , 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 , Ilya Leoshkevich , LKML , "open list:KERNEL SELFTEST FRAMEWORK" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 12, 2023 at 5:44=E2=80=AFPM Krister Johansen wrote: > > When 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. > Additionally, ensure that the copy of the main program in func[0] is not > added to the bpf_prog_kallsyms table. Instead, let the main program get > added later in bpf_prog_load(). This ensures there is only a single > copy of the main program in the kallsyms table, and that its tag matches > the tag observed by tooling like bpftool. > > Cc: stable@vger.kernel.org > Fixes: 1c2a088a6626 ("bpf: x64: add JIT support for multi-function progra= ms") > Signed-off-by: Krister Johansen > Acked-by: Yonghong Song > Acked-by: Ilya Leoshkevich > Tested-by: Ilya Leoshkevich Applied. Thanks