Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp825535pxb; Fri, 22 Apr 2022 12:01:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBDOEj8l7nsXjSOeBKIC5xw9/qupp3xwPKQVfeqcRAZU+ameAhu8lxAOO1nITTwXgnjmY2 X-Received: by 2002:a17:902:d2c5:b0:158:f839:4d82 with SMTP id n5-20020a170902d2c500b00158f8394d82mr6029018plc.17.1650654074720; Fri, 22 Apr 2022 12:01:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650654074; cv=none; d=google.com; s=arc-20160816; b=YfBW7eUG7MWEgsoD8JVPHVsMFWip615e9crTEIsrpXFbSYw2A47zUhIOADXKHZ7XHH tra28USU4dzY84P1/W2mZhnWZ7TDMEKzvjBfLthAn3maL3C5sO7OcWz9uC3SPccJsvMB Ke1iETkWS8UJtrhUgiCQIMiWRIh2su3GQUpZr7UHPR2PPCGPdQ0EODxIGSAvhKSC+7tL VFCd8X9ff5X824dwVgxN+HQGNvE1uRnvN9Qrd+PI/awFwOeBFDUUupg45IgnXUuKWOIs 8e12VsD9gGZfU3n+GcGMHz8rHdaHLuHoQOu0lWt68qKz7IjcamZxLwdCIaFaj+wQFek3 h0mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=uOmCNn2QmzQiEmdcQ+YV/8Gbpn1RCGDJT6oY0QuTxXE=; b=xz3GwhA1CVJsNte0LeXTBT2ogtmf6pc+Hu+yxmkx4NgN0YDJcnljFMxKnp/tgWBtZs vYugsHJkqXrxoyImC0v6MbjXpeeSZ3pt6qrcL2gShzwYuuuEVCmEP/rsDdBCH446v+Lo 9Em7hSfbATqQmK6JQ3z4wzVRXrZpS9LAJb4l2Q36H9k1m5VWhgi9KfwfwXhnO9q78NI8 C3lZ4oJHWWvgJNemgv4yEy+5y53eiVs0vfdHGDpA2cw7716/PeprT/82h+jA94a2ABG8 TkAUke1KYWmySkpMeCA/It3jFEm3F4DPT6KDA3eJSTxtPn5PehtxMnPUV7DQqf0sJKK7 ePOA== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 33-20020a630e61000000b0039cb8fe4bddsi8554188pgo.259.2022.04.22.12.01.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 12:01:14 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 877411900AC; Fri, 22 Apr 2022 11:23:02 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359353AbiDUQ4T (ORCPT + 99 others); Thu, 21 Apr 2022 12:56:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231334AbiDUQ4S (ORCPT ); Thu, 21 Apr 2022 12:56:18 -0400 Received: from www62.your-server.de (www62.your-server.de [213.133.104.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 850E949907; Thu, 21 Apr 2022 09:53:28 -0700 (PDT) Received: from sslproxy01.your-server.de ([78.46.139.224]) by www62.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1nha3X-0008eV-6I; Thu, 21 Apr 2022 18:53:23 +0200 Received: from [85.1.206.226] (helo=linux.home) by sslproxy01.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nha3W-000O6u-TK; Thu, 21 Apr 2022 18:53:22 +0200 Subject: Re: [PATCH bpf-next] selftests/bpf: fix prog_tests/uprobe_autoattach compilation error To: Artem Savkov , Alan Maguire Cc: Alexei Starovoitov , Andrii Nakryiko , bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org References: <20220421132317.1583867-1-asavkov@redhat.com> From: Daniel Borkmann Message-ID: Date: Thu, 21 Apr 2022 18:53:22 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20220421132317.1583867-1-asavkov@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.103.5/26519/Thu Apr 21 10:23:36 2022) X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE autolearn=unavailable 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 4/21/22 3:23 PM, Artem Savkov wrote: > I am getting the following compilation error for prog_tests/uprobe_autoattach.c > > tools/testing/selftests/bpf/prog_tests/uprobe_autoattach.c: In function ‘test_uprobe_autoattach’: > ./test_progs.h:209:26: error: pointer ‘mem’ may be used after ‘free’ [-Werror=use-after-free] > > mem variable is now used in one of the asserts so it shouldn't be freed right > away. Move free(mem) after the assert block. Looks good, but I rephrased this a bit to avoid confusion. It's false positive given we only compare the addresses but don't deref mem, which the compiler might not be able to follow in this case. https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?id=6a12b8e20d7e72386594a9dbe7bf2d7fae3b3aa6 Thanks, Daniel > Fixes: 1717e248014c ("selftests/bpf: Uprobe tests should verify param/return values") > Signed-off-by: Artem Savkov > --- > tools/testing/selftests/bpf/prog_tests/uprobe_autoattach.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/bpf/prog_tests/uprobe_autoattach.c b/tools/testing/selftests/bpf/prog_tests/uprobe_autoattach.c > index d6003dc8cc99..35b87c7ba5be 100644 > --- a/tools/testing/selftests/bpf/prog_tests/uprobe_autoattach.c > +++ b/tools/testing/selftests/bpf/prog_tests/uprobe_autoattach.c > @@ -34,7 +34,6 @@ void test_uprobe_autoattach(void) > > /* trigger & validate shared library u[ret]probes attached by name */ > mem = malloc(malloc_sz); > - free(mem); > > ASSERT_EQ(skel->bss->uprobe_byname_parm1, trigger_val, "check_uprobe_byname_parm1"); > ASSERT_EQ(skel->bss->uprobe_byname_ran, 1, "check_uprobe_byname_ran"); > @@ -44,6 +43,8 @@ void test_uprobe_autoattach(void) > ASSERT_EQ(skel->bss->uprobe_byname2_ran, 3, "check_uprobe_byname2_ran"); > ASSERT_EQ(skel->bss->uretprobe_byname2_rc, mem, "check_uretprobe_byname2_rc"); > ASSERT_EQ(skel->bss->uretprobe_byname2_ran, 4, "check_uretprobe_byname2_ran"); > + > + free(mem); > cleanup: > test_uprobe_autoattach__destroy(skel); > } >