Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp969369pxb; Fri, 22 Apr 2022 15:35:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEX/nzvXjq5MkBeBywHydjSDwMtXdNkawvCHjgvbmbl9Ng1/2r2y/1vYo7gQRcS59JCvJN X-Received: by 2002:a17:902:e88a:b0:15a:3463:4dce with SMTP id w10-20020a170902e88a00b0015a34634dcemr6743118plg.120.1650666951901; Fri, 22 Apr 2022 15:35:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650666951; cv=none; d=google.com; s=arc-20160816; b=rZ8H/j6NC7IindKZbwpUo6NvMN1g6oQq+fN4OzDxqrBaPy/ztqU+LgUTh147+uNL8D et3xhOGyN9wrDZZyqIAAyfB/VhL83FGkxr983dAvObBpNy+fwIFeW2mEjvf57igegd00 eR+49BgBZAARd2ve07Ab2eIRm1T6tSrl+0TTpdDBQiB3CwfoXxFGlqNdEAVkf0bDjx0e QyTtLCskenKRssq5HzjmAjyoTqYhit0J1QMmD4fco17Q9ohViOTwWobkUp+K4H4YkBfe ahGB9g2Ll3XJS56/qjARiHtW/kG2cqwYpWG1eBHEfJMSeYYB33OTJ0H0TFZnpxsc4Res SKow== 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=en69GFd9iczJ4gyNRpggGpgmwF2q02BdIIrmygJXxio=; b=kADIb8lvUmOJeJ6iUX8GXt9XY9rVrzWw9A4LtS7u+PUopdxxMVNoJMm07+PUj6FZTT DUZ0HcPzKTr+Qi381XVTpfkId7yZWyu5//TD0n7XKs94zAbc6LCzKkP5GP4VADsmHqx2 3jsb2puYnl3Rye502eLDbHvNf0Ivqa7muBoIoXOz4xqXPOqqNrVEOwpABWGIb7SnzcNO PGF/VkDuPbA8aFDqMoquqb1KW0eWE+w6BTsy8QzrBgNgtQXVKTO4AupWLZiU2ZOHuGq1 4P4xA/6u/5ih8ENPB6dG52luY32GL9lq0g1KyquBmynNnVdNm5blZ0OY+VJ8wa2dRBRQ kRDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HqlH9sQg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d21-20020a634f15000000b003aa5717df5fsi9350470pgb.723.2022.04.22.15.35.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 15:35:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HqlH9sQg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3121E1A61CC; Fri, 22 Apr 2022 13:23:17 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345407AbiDUQyg (ORCPT + 99 others); Thu, 21 Apr 2022 12:54:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231127AbiDUQyf (ORCPT ); Thu, 21 Apr 2022 12:54:35 -0400 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7CC54888F; Thu, 21 Apr 2022 09:51:45 -0700 (PDT) Received: by mail-io1-xd29.google.com with SMTP id q22so5961350iod.2; Thu, 21 Apr 2022 09:51:45 -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=en69GFd9iczJ4gyNRpggGpgmwF2q02BdIIrmygJXxio=; b=HqlH9sQg9iF7Rm6lFopsgjkthxqycYLJzmHErBCezKfJFSekJOe2Tubb4y2u1IqTKF EMfCRqQ+/69CbaMGV9b9FPVKd2OjUVx0rk7ubWAizit7lrIRRVPF+McZnt5rNwrqg6ew eyy3vqHoxcYDAcixdnwKnufrq/LC5rpO0ScyRaahwxhfiiBEpE+ouBlFrORqhyp6cUj/ tt41TmYc9x2lE0Ep2jui0GP/WX1vErkJPO1sxLDyoortbMnF0KLAaqBOTbD8CODVR7zV G5zPg20G+5sqRoVAqUZqxAPIr0hRt6G3xzYtGZmJXPPK/pMWd+EFHWcVM66xm0WokJvx NcHA== 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=en69GFd9iczJ4gyNRpggGpgmwF2q02BdIIrmygJXxio=; b=bhC86yNzkZJZsCH3U17aTRLyC6JMDPQzgBXdfWMk5BZC0Yl+WbarO8asfB0vgQo8oF I8GQMcm7R6ADJZzgqyGS3mPWnufgeRtZZ1BCwU550fTjOcLOrCRVb8ZdHQEGS7gOmXhs C5KkmC92dOwmmmSjptmYQ32XKI0k664oQyE1iZ2oKeJa/crcpxC6gSNc2VGcPEoNSIxP An0MNXjkUZqFB6Pg5boPj6Uw0doFVAbRDeGTg9fT7JHSggv5juqccfZKMdSZ4MibuWab 9HowNjWBgh0boyuUuODpj8lFsK82SHHcOeodiskBSdnLm5gsGLcQ3OPoS27AC1rg4LT2 IIpg== X-Gm-Message-State: AOAM532E9cMSzUZZ+WqlzSzIu77esogy7Vt8kexcqNRFtaivuQZB4pD5 C6UQsFIMGgxVjIWSWKrnYNWw6OtS8GBnlQ90Trg= X-Received: by 2002:a5d:9f4e:0:b0:652:2323:2eb8 with SMTP id u14-20020a5d9f4e000000b0065223232eb8mr285329iot.79.1650559905250; Thu, 21 Apr 2022 09:51:45 -0700 (PDT) MIME-Version: 1.0 References: <20220421132317.1583867-1-asavkov@redhat.com> In-Reply-To: <20220421132317.1583867-1-asavkov@redhat.com> From: Andrii Nakryiko Date: Thu, 21 Apr 2022 09:51:34 -0700 Message-ID: Subject: Re: [PATCH bpf-next] selftests/bpf: fix prog_tests/uprobe_autoattach compilation error To: Artem Savkov Cc: Alan Maguire , Alexei Starovoitov , Daniel Borkmann , 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=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE autolearn=no 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 6:23 AM Artem Savkov wrote: > > I am getting the following compilation error for prog_tests/uprobe_autoat= tach.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 a= fter =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 r= ight > away. Move free(mem) after the assert block. The memory is not used, we only compare the value of the pointer itself, we don't dereference. So the compiler is being paranoid here. But while initial version relied on free() to happen before all the ASSERTs, now we don't, so moving free after asserts is fine. > > Fixes: 1717e248014c ("selftests/bpf: Uprobe tests should verify param/ret= urn 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); > } > -- > 2.35.1 >