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 X-Spam-Level: X-Spam-Status: No, score=-2.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13659C433FE for ; Fri, 4 Dec 2020 19:32:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 80F3822C9C for ; Fri, 4 Dec 2020 19:32:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730513AbgLDTca (ORCPT ); Fri, 4 Dec 2020 14:32:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730182AbgLDTc3 (ORCPT ); Fri, 4 Dec 2020 14:32:29 -0500 Received: from mail-yb1-xb42.google.com (mail-yb1-xb42.google.com [IPv6:2607:f8b0:4864:20::b42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 722B8C0613D1; Fri, 4 Dec 2020 11:31:49 -0800 (PST) Received: by mail-yb1-xb42.google.com with SMTP id e81so6472580ybc.1; Fri, 04 Dec 2020 11:31:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=voQ5lfDVMzOYam6sMYIWBPLKZkkRpZtoYUdHJkVXnyo=; b=MgpaSnyZbEuVQ1tq48gkH3nTUILv5dbh+fQiN7sWvrAX68uet1w9mnhMN9cz6C50kr 9B+IgSJey1l97joP0fSN4mxjNgmrbp5FWvsfhQlKveVkGX+0cAdxVnsgwStgix5ZNrej r7NV16O/bHOu7yCaJ7RuJPFDMCtNGV8V3RNDuBBm5K7YFOrmywpNCD7d3T/NNsUxmY3u Q101YMgwA5Fs2KohhE4+T0tKNriGkSL3TvqGPVnA09l5PBLBnI2/3CKvBhyz6Oj0/OuW SJhzjlWvzpWyUkPDs4YJ8AqiCA/xbPKCZv+3/SNKjj1Ix21C/+Q4XMg/m8ePXEP8W+KV RuWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=voQ5lfDVMzOYam6sMYIWBPLKZkkRpZtoYUdHJkVXnyo=; b=qRP+rczwuRIxFn9kkamqpd6WfEWf7vPEDiXl/ev+17ImY+X1XEj2zY0QsG3XkaToAl XZdhCFyT/wd4A+DGlxzDbqZ8Pd/C/1Ki3B7qrfQw9yknTPOD0+WpyJVPmTLYCbeWdykX NiVG+2wINGi6c/lqJvYp8y3b7bpyK9AoRA4OTG+OqeT8oZYR2gONnVQi6CDRkwC1pzCq BT/Tde+kBvPXQRPlkpDDmvwgrbKAkNzTNA6hJEaL5q7NSyunHu8+JZg0q5imZdVV698X WfvnZQ+YCBD6N/Z1mB4eUQpB0dP02Du5GvtmbUet+lksOmeF9Tf+CDga7mliVR+E9f/h twNQ== X-Gm-Message-State: AOAM533edABcJ7vZHCHms8RuED4+ae0iHzEt4uA99qCUaBdh94a40M2X JNPE40Y3JK8CAa/2Fpgeq6DgKv9OYcupOJco1hMmdvDSgMU= X-Google-Smtp-Source: ABdhPJzfGL7HBGF2Eg+F+OK3y9ToHuBFF2CJytCQWCAM+So+BOR8xjeYlQSdcaqAnVom2SPnni0muXJlyLjALy3Dtjk= X-Received: by 2002:a25:6a05:: with SMTP id f5mr4486304ybc.459.1607110308781; Fri, 04 Dec 2020 11:31:48 -0800 (PST) MIME-Version: 1.0 References: <20201203204634.1325171-1-andrii@kernel.org> <20201203204634.1325171-11-andrii@kernel.org> <20201204015358.sk5zl5l73zmcu7t2@ast-mbp> In-Reply-To: <20201204015358.sk5zl5l73zmcu7t2@ast-mbp> From: Andrii Nakryiko Date: Fri, 4 Dec 2020 11:31:37 -0800 Message-ID: Subject: Re: [PATCH v6 bpf-next 10/14] bpf: allow to specify kernel module BTFs when attaching BPF programs To: Alexei Starovoitov Cc: Andrii Nakryiko , bpf , Networking , Alexei Starovoitov , Daniel Borkmann , Kernel Team Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Thu, Dec 3, 2020 at 5:54 PM Alexei Starovoitov wrote: > > On Thu, Dec 03, 2020 at 12:46:30PM -0800, Andrii Nakryiko wrote: > > + if (attr->attach_prog_fd) { > > + dst_prog = bpf_prog_get(attr->attach_prog_fd); > > + if (IS_ERR(dst_prog)) { > > + dst_prog = NULL; > > + attach_btf = btf_get_by_fd(attr->attach_btf_obj_fd); > > + if (IS_ERR(attach_btf)) > > + return -EINVAL; > > + if (!btf_is_kernel(attach_btf)) { > > + btf_put(attach_btf); > > + return -EINVAL; > > Applied, but please consider follow up with different err code here. > I think we might support this case in the future. > Specifying prog's BTF as a base and attach_btf_id within it might make > user space simpler in some cases. prog's btf covers the whole elf file. The problem is that there is no link from BTF to bpf_prog. And multiple instances of bpf_progs can re-use the same BTF object and the same BTF type ID. That would need to be resolved somehow. But keeping our options open is a good idea either way. So I'll send a patch to switch this to -EOPNOTSUPP (I think that's the one we need to use for user-space). > Where prog_fd is a specific prog. That narrow scope isn't really necessary. > So may be return ENOTSUPP here for now? With a hint that this might > work in the future?