Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1552063rwd; Thu, 8 Jun 2023 21:25:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6/CVQZZCTfEgCrV/3EsmH8jmGxyBlezBfuNYuXLKmOvH9zeNOpSu5Q0tUPyCWXDTSNEeGS X-Received: by 2002:a17:90a:f186:b0:256:31f3:1f03 with SMTP id bv6-20020a17090af18600b0025631f31f03mr182926pjb.21.1686284727714; Thu, 08 Jun 2023 21:25:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686284727; cv=pass; d=google.com; s=arc-20160816; b=EEGPhpD8HkOGjXFo/RkanOIDq2b/FuIbXOhVEWCjYyLfflWLzM7XLXljhlBkC8GhDK s9CO/l3pSJV39ZTJwSNuDMY6+X8Svz0Gwnj0kTiPBE7dKlwybKU7MJAi7cu8C29vkoe1 +FH5lYi3kbNLPUZhcrCt9c+tveBJoVN4pDXV0XuO84xc1G4FmQNSIrvbTqH7cn5MrUcd XONYm8hH5crMFaXfStQ4AUWgX88NId0wSziTPw7tDCKk+67ZPJiuNSjYvZT8qfC0mrTn lZ+QhZKmhrrXmTYGel5CmiHWOc+KTfM/hywaiSLaEHUd7sdb11zkmBkPbue0SsBEftMm q1YQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:content-language:references:cc:to:subject :user-agent:date:message-id:dkim-signature; bh=6WSk4IqRsEke7poHBd3pWAOel+mOSK4EQm9knUDIsI0=; b=Srfgv0CBSV2+1oT/P2dNhDobAtDHvncNmTWOf7Wp9VnOi0/OBJMUinIjz8Jc5zUU7G fEPBRR97aVPHyTf09iH0gWB57DG50KAiX54KSCHty4mWC/JZFy6ISus9sYqN81tIbUhZ xRYTt8AcOXdNlS0umuIw0Z2vwpVTMYrH14hM1Fuv9CAYRnYvdElnvZfLU4mtmJ9rMTH3 VL/nrTdLtNtH5lFI+5tSDXrXTlhUaLqho/jGeX64Sx8SdUAvdAC9EEgVvin08JCBKo45 +4eBS7+OQMZPNI1BWOR2VEzXRUic52/wPzplAQjWDqhdwKpzPUv08zRQpHExzLPbco3o QAKQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@meta.com header.s=s2048-2021-q4 header.b=OabZoJsq; arc=pass (i=1 spf=pass spfdomain=meta.com dkim=pass dkdomain=meta.com dmarc=pass fromdomain=meta.com); 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=REJECT sp=REJECT dis=NONE) header.from=meta.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pf15-20020a17090b1d8f00b00258ee17486bsi2078363pjb.160.2023.06.08.21.25.15; Thu, 08 Jun 2023 21:25:27 -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=@meta.com header.s=s2048-2021-q4 header.b=OabZoJsq; arc=pass (i=1 spf=pass spfdomain=meta.com dkim=pass dkdomain=meta.com dmarc=pass fromdomain=meta.com); 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=REJECT sp=REJECT dis=NONE) header.from=meta.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238001AbjFIDeZ (ORCPT + 99 others); Thu, 8 Jun 2023 23:34:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229619AbjFIDeX (ORCPT ); Thu, 8 Jun 2023 23:34:23 -0400 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C245230F0; Thu, 8 Jun 2023 20:34:21 -0700 (PDT) Received: from pps.filterd (m0044012.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3591WENn023449; Thu, 8 Jun 2023 20:34:02 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meta.com; h=message-id : date : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding : mime-version; s=s2048-2021-q4; bh=6WSk4IqRsEke7poHBd3pWAOel+mOSK4EQm9knUDIsI0=; b=OabZoJsqpLTMRJ3RN3soUxe98EeQrPI6ypmxTD5HPXRE4pJ81Bg4DUKWGiA5vy/gLGSf 5LEANb1LzwI/7bl1WBYjLrwnychnbVGwwrSk0yGVRGSPJAxMk6Ued1xtgA1+30y6WrLk FyBcNuiNYuRlaiYee2ARRCMqcZ4lD1pgjrop1biy9Cmu/5S3gci6nuBxMgbgUTpkPzad sv78IoXNpVsExpgslQRPPi9x0ctLCe2si0Y9Ayn5zS2kDQjaqOk6fghebLFt3nN2XoHY 7SETE9l6ht5kZLtLuGWeeI/3Rw6/lZTDSf3+Q4FBKMqluogGJwxW8NJMtNm6I/10+2rc uw== Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2169.outbound.protection.outlook.com [104.47.55.169]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3r3fd6nn7q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 08 Jun 2023 20:34:01 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BPn+roYDwA0/tBlQL5ielWdPq0uDnvOkNZu7JDy1/KFgiNNV+JHJFMpv3nDpQXYCDdDsNfvxqOUPpzKdD0UbxSOFQB3ayjvsDTRhXpP7gB5AhWynOzypPBD+Gp76mQZFKMbeMN6UcK3vvGqLRv1dAHSd+Mz7XttczOw+SiDC2uGLs2VNSCZZdS9gzKAK4vAeGbTX0tqjzCdZs/Anr4ruSFhKCqBHOBvRwmJY0PtIRsa2veh+JJInqhZ71TlAFuPiQm4yq0AiYg1kDxJ2KJHjg/C3EHewREAzTfuHptPJrTQnOSwjS1nAd447rWNGXCEug/UiZZJVqziqM3HOp7zprQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6WSk4IqRsEke7poHBd3pWAOel+mOSK4EQm9knUDIsI0=; b=MyU6uwIfJ670ZUawdBPKLu6V/wFWD36RmaL5UEhta66yy8BWpOLrFghF2r/KGS6VuO7EdtI/imAHN9wbLYeQ8ePwgCyeEoWZcpXYteqllOtVTUVa+sOnHsbC0GKf18KSs9YH5PDPhrsCQgaSxPdnR18tuhGheQTbkKz0kdeMCYhPsFM9BUioXNWHImW9GK/mymM+GdMv6J19TLabowOGJF3QErKFa1mVRdjTNt9QzQRimChQlaghwDYY2AtAUl5ReyjmqvbWht/DjrgMrWjDuFnz6JlD0pkFw0qCbJU6t3UDIDU+/AK8AJgGkMQW2KAIgH7Fj5Sax1WglJK19yKbFg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=meta.com; dmarc=pass action=none header.from=meta.com; dkim=pass header.d=meta.com; arc=none Received: from SN6PR1501MB2064.namprd15.prod.outlook.com (2603:10b6:805:d::27) by BL1PR15MB5339.namprd15.prod.outlook.com (2603:10b6:208:386::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Fri, 9 Jun 2023 03:33:59 +0000 Received: from SN6PR1501MB2064.namprd15.prod.outlook.com ([fe80::bf7d:a453:b8d9:cf0]) by SN6PR1501MB2064.namprd15.prod.outlook.com ([fe80::bf7d:a453:b8d9:cf0%6]) with mapi id 15.20.6455.030; Fri, 9 Jun 2023 03:33:59 +0000 Message-ID: Date: Thu, 8 Jun 2023 20:33:55 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.11.2 Subject: Re: [PATCH bpf v3 1/2] bpf: ensure main program has an extable To: Krister Johansen , bpf@vger.kernel.org Cc: 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 References: Content-Language: en-US From: Yonghong Song In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: SJ2PR07CA0012.namprd07.prod.outlook.com (2603:10b6:a03:505::13) To SN6PR1501MB2064.namprd15.prod.outlook.com (2603:10b6:805:d::27) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN6PR1501MB2064:EE_|BL1PR15MB5339:EE_ X-MS-Office365-Filtering-Correlation-Id: 6736274e-d23d-4b87-34c6-08db689a5c67 X-FB-Source: Internal X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fYy45wVQr5k/XcAKVrIZhIgtZJeUCyzP6tmWQ5zdK8pQ7Lgx+YtjdeA/i2JJcRIXuWljbmFvBhUYk/IVvXPvptXylj4wellJYRnQpFV+LKjjCeiH4vgHM3Qj//iKTLonCn5RpQT0URKCOcRY3aDTU4hQSlRRtW2yA+SSiW2JjWEzaRagbUCJ31wYpvQ1PWFqt+DJw0JR3dIydsQeheP1y9OyTo3P5WMveFi1Q2BgejFUbjEUYwpql3HciTd4qh7W2w882ecyfo2qUVA1gUxLGfWPOKJC1oixTZfQJYVbI6aMgDb50iGJFJmPFhc1tPt3lIcc0U+ETbs0U5cj/9dbo/vko+pwqOjmwyq96eUgbq2QQx3JKBKxXl0rSVefHHZKHvKcMgJoaq7zGTPf0FVHVqhtEQHT6lpMkvptjUF8NgVPqrNSv4BWOcvJQ9jKJg/NJ1eLvmfMU6GBux/XHGoKVQT2zFax5FdQEoGCII4eFb5ctIKbHnBTE6qG2L17SoNVRUkrulrAVykofQUOqQVJE4Krb9uh0WBS/a4ns+klbkwTkLSTABm0o0FdWnZfB6WidY9aWfKDS+u4bGiWWM/u5Lg5f+v8dB9F6TdHVEwRaRI3ZQe1tOYKiIdS1FXtArhgAQESB3eni02QdgkfgBREcA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR1501MB2064.namprd15.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(136003)(346002)(396003)(39860400002)(366004)(376002)(451199021)(31696002)(54906003)(4326008)(38100700002)(66476007)(478600001)(66946007)(6486002)(66556008)(6666004)(5660300002)(186003)(2906002)(36756003)(2616005)(41300700001)(8676002)(316002)(8936002)(86362001)(7416002)(31686004)(6512007)(53546011)(6506007)(45980500001)(43740500002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Nk1RVDV0ekttZ2hUTzFKOWZPLzRJcTkrWDlQdWZYL0NvUm14NXYwN1Z1QjJ2?= =?utf-8?B?SVViQy92UU8rbUh1S1Z5bTZGT0FsS2NvTWdoN0Y1a055TENBKzMwVm4yUFp0?= =?utf-8?B?V3l5ZTdOY0lBUGFRdmoxVkJzVEU4RWUzT1VZdE5TTEFLaVdURlpPS0JHYUgz?= =?utf-8?B?NDIxaVhuNHhwL1N4YXJQb2NI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8?B?MTZEMjdlODVBZkNJYmJUYWF5UHJLd1NHcE9ZM2xOWkEwTG5scjN3S3lSc294?= =?utf-8?B?UytMcGgwM2ZMMG50TU5NY2hqOXNSOXpCZWZnMVRzaDVOOXZaOXkrbnRRbXUz?= =?utf-8?B?cDFadGIvRFdjemZpbmhnMnNCQVFaUlM2V2d5Mk9wdjRhRVlHQm1mSkNGVXRF?= =?utf-8?B?eUE9PQ==?= X-OriginatorOrg: meta.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6736274e-d23d-4b87-34c6-08db689a5c67 X-MS-Exchange-CrossTenant-AuthSource: SN6PR1501MB2064.namprd15.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2023 03:33:58.9331 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: u8JuHWrsjX8AY5VbuogrP0JKrZQHHAr4VMSsp9esdBRx7Kex/up2g6V3ixG1zZM3 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR15MB5339 X-Proofpoint-GUID: 10ldEj-AH0pgZ7XdSn9mmXbaTPynS1kr X-Proofpoint-ORIG-GUID: 10ldEj-AH0pgZ7XdSn9mmXbaTPynS1kr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-09_01,2023-06-08_01,2023-05-22_02 X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 6/8/23 5:10 PM, 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 programs") > Signed-off-by: Krister Johansen Acked-by: Yonghong Song