Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp53287pxb; Thu, 21 Apr 2022 16:49:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJym6f2jLK+mFvpsbE7xs1bjthiOgxOQDn5SLoTOnqJrbaFk50ySW1BWtBf7DR4N76Yr+nE7 X-Received: by 2002:a17:90b:4f91:b0:1cd:3a73:3a5d with SMTP id qe17-20020a17090b4f9100b001cd3a733a5dmr2235274pjb.98.1650584994007; Thu, 21 Apr 2022 16:49:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650584993; cv=none; d=google.com; s=arc-20160816; b=tEwCbpAKDstfOW7j7KQmSTfqGR2BltLUQWp1asC9Yd85KF67T8Yk8RMMIwBQa3nGkX 8Ry9334jvns7BhriX3jPaUvynnQ/U3GhWgNYJnJazgkxeXFqdGj6P1CRDdc15BB2wkAW dBdpWveAjApkA1pREWsg+zls0HLkMywqeFpVu6/N232NQ8TPqu2KTlPzy3nQn/K8TXBA Ggnk0/qaSxyQXTw2Fe4ZK0suysOw3ecvb4GWGeVgxhm1JHdGkdn/UsF6seFqy7CF3Dpj bJOM3S+6+oWHyLa1hBu2sOmExOBLtfholg5VXk/OlqEQWcRgz0cuNQlDwtD2xJ5itDcJ vXpg== 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=JOWG99CezT9lByIP5QyzIlz0ytuTThPln72bC4jEuqQ=; b=OXKlKbC9wGcL8p3fVuA2eQANME0BnA4XXOvZNwRo4ytpQA5GT2fQj/rVc6t/aSzbv2 /PItpJ5DV3mX/fGw85f9OLITZS7K5yWahpolCPsNaGDSVgH7Uog1i3kJFtycLRjM68gF vAwTHWgU13JVR6/zvBvDtJKmVdXcXhQ4CQzQTeTzeb8GuukTQ1ApMGZehLKZN1jxHUKb pBv1uKyfdiZ7IqKBOYO2vUF4+ygvcTnlUpRZnREva17w3BHZPGQb8upBJ8rkihE2iSMk 6swO8P7MkE3p+FDd4IKs6NOstq1q8ekoGaFFkbqL4dVISbNYTXFnpMM3aouqfkD4T4Wc IjoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LdSOVOjY; 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 x70-20020a638649000000b003aa663b1956si5889319pgd.699.2022.04.21.16.49.38; Thu, 21 Apr 2022 16:49:53 -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=20210112 header.b=LdSOVOjY; 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 S232055AbiDURAd (ORCPT + 99 others); Thu, 21 Apr 2022 13:00:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232622AbiDURAb (ORCPT ); Thu, 21 Apr 2022 13:00:31 -0400 Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03B1449CA3; Thu, 21 Apr 2022 09:57:40 -0700 (PDT) Received: by mail-il1-x12a.google.com with SMTP id f5so3433064ilj.13; Thu, 21 Apr 2022 09:57:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=JOWG99CezT9lByIP5QyzIlz0ytuTThPln72bC4jEuqQ=; b=LdSOVOjYpqZZ7kql6UX/EFKoFk95WADsdCGCV8z4YJRTwEpcRLUrYcXIrunkDDhDKA l1aI8R9Va8PtUj26rWEyrLaPYRx+A0XhZNxi/MR0UDwg0rp4S3uRALguzRxGNm/lPrfH hmGVkeNiZoYPEJCiNCkQjyg6Omewj5P3bxrv/rlYxeXZzUa15mmB2VrT7wgsTmitk4lH Atuer9/68NRqZEgTiSDm7AuXA6pgrrfs6cU812oMs8IyaR6CKHz4bJQqPjeOUl0C+PGS 0GoZ9EcVuvy55r0n51mvgq38nuXTlXdNzalNEQ+Op6ZOr6m1FSdVWotFphjL4EU0iT0o tlRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=JOWG99CezT9lByIP5QyzIlz0ytuTThPln72bC4jEuqQ=; b=ZbqF1ivtnr8tGJWyH5T5rNSWg6LzV5bt9NpBIQBVQBaXsaOSmcW1cbD3F+Z7KucuVn hUqtmZXGEeJlRVQ1MKwL3y2dS0SC+QmucLK7dD35DDSC62aGd5iWtAVaVMoW1BWHPKlz OF2bwK90nAyV+lv+veJfvGyJpe6wYrpBcQ7L2Mr9ExPdYO4njNqqpfg0KXUmJmFN+irX WjRD0yYVDuU5hE014kDOM8CTGo4OSLfUOzmUTr+UuZgrrVBekjqiwy+gf5D0rPO/fKCm wKTHDrgoZsEn2uCQtmMvKYCW86NvF/8Rj47RbLRgV7z8ZplCNJbUTtpyW4h2eMEn9mZ9 +DnQ== X-Gm-Message-State: AOAM53033wKWd9CB5MGSTwcZkr65wQj6thhuOwQhoiB8+tSmjQ6OQAH8 ok6iNlorHd7LYWjbmWoMZZw9l/30zV6DLzhpTZk= X-Received: by 2002:a92:c247:0:b0:2cc:1798:74fe with SMTP id k7-20020a92c247000000b002cc179874femr284940ilo.239.1650560260212; Thu, 21 Apr 2022 09:57:40 -0700 (PDT) MIME-Version: 1.0 References: <20220421132317.1583867-1-asavkov@redhat.com> In-Reply-To: From: Andrii Nakryiko Date: Thu, 21 Apr 2022 09:57:29 -0700 Message-ID: Subject: Re: [PATCH bpf-next] selftests/bpf: fix prog_tests/uprobe_autoattach compilation error To: Daniel Borkmann Cc: Artem Savkov , Alan Maguire , Alexei Starovoitov , Andrii Nakryiko , bpf , Networking , open list , "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 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 Thu, Apr 21, 2022 at 9:53 AM Daniel Borkmann wrot= e: > > On 4/21/22 3:23 PM, Artem Savkov wrote: > > I am getting the following compilation error for prog_tests/uprobe_auto= attach.c > > > > tools/testing/selftests/bpf/prog_tests/uprobe_autoattach.c: In function= =E2=80=98test_uprobe_autoattach=E2=80=99: > > ./test_progs.h:209:26: error: pointer =E2=80=98mem=E2=80=99 may be used= after =E2=80=98free=E2=80=99 [-Werror=3Duse-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 pos= itive given we > only compare the addresses but don't deref mem, which the compiler might = not be able to > follow in this case. > Great, thanks Daniel! > https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?= id=3D6a12b8e20d7e72386594a9dbe7bf2d7fae3b3aa6 > > Thanks, > Daniel > > > Fixes: 1717e248014c ("selftests/bpf: Uprobe tests should verify param/r= eturn 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 nam= e */ > > mem =3D malloc(malloc_sz); > > - free(mem); > > > > ASSERT_EQ(skel->bss->uprobe_byname_parm1, trigger_val, "check_upr= obe_byname_parm1"); > > ASSERT_EQ(skel->bss->uprobe_byname_ran, 1, "check_uprobe_byname_r= an"); > > @@ -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_b= yname2_ran"); > > + > > + free(mem); > > cleanup: > > test_uprobe_autoattach__destroy(skel); > > } > > >