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 2794AC433EF for ; Wed, 1 Jun 2022 04:11:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231685AbiFAELR (ORCPT ); Wed, 1 Jun 2022 00:11:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229447AbiFAELO (ORCPT ); Wed, 1 Jun 2022 00:11:14 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7950E90CE1 for ; Tue, 31 May 2022 21:11:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 35887B815FB for ; Wed, 1 Jun 2022 04:11:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4795C36AE3 for ; Wed, 1 Jun 2022 04:11:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654056670; bh=OyBxYFh4f/71XBJUEuQEiIIvQazODRG3fkYzsjVuQ2g=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=K8mGaQXNqnMVShFGchDDCi/hiv5zsXPviwbPvQZD7O6+elAaLkWRARqGQIzYR1KDP teLVoQpEnDkvaZ2av29y+SZFAUm6q5kVCL446l0YLl1UGlbZ2pRjxRr8IMwL9FXq3v jb5kKDvxT+5GjfrpKJuGYrPShAvmUoN/9sAwZXusdGDYwNPMOyyxAoikeo5HcJUX+P 4rhvAe3o8fo9SVYPN5oQPUN+51wJzf/bQBhlQh/L3+GH3bXaKmwDRUeza/9rh4lCWa ERpPhMCoLaGChbJzHKg/Weunmw1fy+OodPI7WZ7uZq8ltrC9KGW6TMRi91T0FPUiQg M9xGncPMDjMoQ== Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-306b5b452b1so5690547b3.1 for ; Tue, 31 May 2022 21:11:10 -0700 (PDT) X-Gm-Message-State: AOAM531lm2X3uG6l68nCUn/LjfVle/7226KnNoLUBLI/zW2Z1VqmAwiu 6rMdKU4OVHy3/4IZFxEpernUwlZTA/qbc7PAh2U= X-Google-Smtp-Source: ABdhPJxVD0KN8f7qQWalEeuDUpvQuBoSFJma4sKlcnDu28cj/aO8fncUrHvRX9Y4oleKzwW8Zqrh9oZqWX/72ri1lzE= X-Received: by 2002:a0d:eb4d:0:b0:30c:9849:27a1 with SMTP id u74-20020a0deb4d000000b0030c984927a1mr9505602ywe.472.1654056669852; Tue, 31 May 2022 21:11:09 -0700 (PDT) MIME-Version: 1.0 References: <20220529223646.862464-1-eddyz87@gmail.com> <20220529223646.862464-3-eddyz87@gmail.com> In-Reply-To: From: Song Liu Date: Tue, 31 May 2022 21:10:59 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH bpf-next v2 2/3] selftests/bpf: allow BTF specs and func infos in test_verifier tests To: Eduard Zingerman Cc: bpf , Alexei Starovoitov , Andrii Nakryiko , Daniel Borkmann , Kernel Team Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Tue, May 31, 2022 at 4:20 PM Eduard Zingerman wrote: > > > On Tue, 2022-05-31 at 13:52 -0700, Song Liu wrote: > > Hi Song, > > Thanks a lot for the review, I'll apply the suggested changes and > provide the v3 in one or two days. My only objection is below. > > > > { > > > - int fd_prog, expected_ret, alignment_prevented_execution; > > > + int fd_prog, btf_fd, expected_ret, alignment_prevented_execution; > > > int prog_len, prog_type = test->prog_type; > > > struct bpf_insn *prog = test->insns; > > > LIBBPF_OPTS(bpf_prog_load_opts, opts); __u32 pflags; > > > int i, err; > > > > > > + fd_prog = -1; > > > > This is not really necessary. > > Actually this one is necessary to avoid compiler warning, note the > following fragment of the do_test_single function below: > > static void do_test_single(...) > { > ... > if (...) { > btf_fd = load_btf_for_test(...); > if (btf_fd < 0) > goto fail_log; > opts.prog_btf_fd = btf_fd; > } > ... > fd_prog = bpf_prog_load(..., &opts); > ... > close_fds: > ... > close(fd_prog); > close(btf_fd); > ... > return; > fail_log: > ... > goto close_fds; > } > > If load_btf_for_test fails the goto fail_log would eventually jump to > close_fds, where fd_prog would be in an uninitialised state. Got it. Thanks for the explanation! Song