Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp416859rwi; Mon, 10 Oct 2022 02:12:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7b7I3/Eh3dwKbxFGt966tFjye4qdT8XfcxD1GsLgndagFw0AmZZ0FJDUxpQ5HrowMZKhjy X-Received: by 2002:a50:9991:0:b0:458:a612:bf5a with SMTP id m17-20020a509991000000b00458a612bf5amr17298674edb.22.1665393141870; Mon, 10 Oct 2022 02:12:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665393141; cv=none; d=google.com; s=arc-20160816; b=PRoyR/LPpwd07HQ+MERVRIqNxrQGUvVoijf8UfQT78r4Apeu+HMCzsXibuRDzhCCks 94aGzbGLmOr0cgIX9Q9HUIAyBNXGSTrkvwE4a3+hrCZ5ENcEo0PZoaBpSZ1PYZOlbgeN lpdnkM2IeW+As9bwBQyMCYfXy+3I951xoPBpcpBw56Lpyd96qoIlp9GM2vzlrGiLRvsE 8FtDgSnMjmKyYv+ALa/zifkDx//Em03qH0wag0rcEy5wPniFDxxIkVLDQuFj2L5uB03A JPhwVoV1kihhQkJ2/tkPDMtstSG2RvV2pjJcbge4vzJvL55gcath6+ilOlt1r3DfE5NT k+yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:date:from:dkim-signature; bh=+y7bAJPsrwUBLd8lS99Vl4DRojpEn+2LcBi7aYBpm8I=; b=pDJjp4nDPSsNceGo90UY5IJ1vIFtVJp/bQ82XJTWgcqpT8q3bEEJ9xvTOyUbtWBorl Hy7vr4xaGLyMPuemWPMcS2Yt6c5mjaagvwKToVaXkBVLamZ6qB9iV44LlNGqV7eEjQgN oNvVcLl6t187S1eS3FYBcfw5yot5otBxkPJTMuqeX16QZvN2Uz5gT5eg+5kMqYBQjBBx vsQjN53fbr1sGNlpFHc0x74u3fZ0G2I5al3qlY16O1R3oWsCaX59g58y9O9ObShXsQQL +8C2dKFkh/lya9pQjD2U8JwXb8y7g5jHdYB7kW/9j1wbJ97e6mIJ2GFeOJxuwVC4u3Bo ngSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZNeBW7oC; 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 ae8-20020a17090725c800b0074171cca419si10698941ejc.892.2022.10.10.02.11.55; Mon, 10 Oct 2022 02:12:21 -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=ZNeBW7oC; 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 S231567AbiJJJBb (ORCPT + 99 others); Mon, 10 Oct 2022 05:01:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231189AbiJJJB3 (ORCPT ); Mon, 10 Oct 2022 05:01:29 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EB981127; Mon, 10 Oct 2022 02:01:28 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id bv10so12437486wrb.4; Mon, 10 Oct 2022 02:01:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:from:to:cc:subject:date:message-id:reply-to; bh=+y7bAJPsrwUBLd8lS99Vl4DRojpEn+2LcBi7aYBpm8I=; b=ZNeBW7oC/NBRtw9xcqoobO8Sf2Hpd3hHAQSXcdNrdgDyfNtSZixn5MzoA9CaeAeA1G 0lex4dOAf61JCebm3hSj3AwBUnfh7IIT4hQmDO0VWq/hS4ekXjr8pLq30R7GHEifUTcb R2mjGyqRkppt9s5U8xI4pPgW0WCutKuE5EHGuJvGZTguE+4khI7EI/KlvMzhC6JUPMi+ MzYS3Zc6j788ok9c+PCuDGLhOETVttIbLCtNr9bDYe45TE/z7/vFb8SVsIJ1CByyIQCN +0+ZKhHUrOVk1+yem7sO2SN9JeGcuYM3Vw8tN0BRHfnwep7+ZnYjJUMnvGlN0w97AujX xdVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=+y7bAJPsrwUBLd8lS99Vl4DRojpEn+2LcBi7aYBpm8I=; b=32ahkabU0/5UXRTJhHllQUxlifrkOu+0j4y9JZq1qGnB9xMxyFir6SkL70qm7Xzupy Bs+8Q7MGsO5xdtQiF3C+YXNK1st0QhbJM8izswYXNHhfZ7yaMWCb0ysmvfe5o7Kt+uWx lK9lqKCTKfbvz8r1ccIbSbOqqM+IA1xbVVFFJVHPIwYRgNmjxZbSsJxvvBDH5OLC+NWP 7h3IVJraYFuzT/uF5C6A2hCDdW/svAtsXbiQCsvB2lvRyHap/srv23zjiz1XYCuxDUMp rZ89Nrf68/o8VYHhAm9b0keqTlbvC5BFNpFnnrEHLS7CvOZMgl6PGxEjVSJ8zMDuGBCH 3UTA== X-Gm-Message-State: ACrzQf0GeWBqMFBaGi14pSve8ammK556D28dbS762Rh6TQlmI6vD1ewl uSg56kW+qSuFEllzjr3qIRs= X-Received: by 2002:adf:f98e:0:b0:22e:393:8def with SMTP id f14-20020adff98e000000b0022e03938defmr11307683wrr.570.1665392486906; Mon, 10 Oct 2022 02:01:26 -0700 (PDT) Received: from krava ([193.85.244.190]) by smtp.gmail.com with ESMTPSA id n11-20020a05600c3b8b00b003a540fef440sm17165455wms.1.2022.10.10.02.01.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 02:01:26 -0700 (PDT) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Mon, 10 Oct 2022 11:01:23 +0200 To: Xu Kuohai Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Mykola Lysenko , Shuah Khan , "David S . Miller" , Jakub Kicinski , Jesper Dangaard Brouer , Hou Tao , Dmitrii Dolgov <9erthalion6@gmail.com>, Alan Maguire , Kui-Feng Lee , Kumar Kartikeya Dwivedi Subject: Re: [PATCH bpf-next 4/5] selftest/bpf: Fix memory leak in kprobe_multi_test Message-ID: References: <20221009131830.395569-1-xukuohai@huaweicloud.com> <20221009131830.395569-5-xukuohai@huaweicloud.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221009131830.395569-5-xukuohai@huaweicloud.com> 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 Sun, Oct 09, 2022 at 09:18:29AM -0400, Xu Kuohai wrote: > From: Xu Kuohai > > The get_syms() function in kprobe_multi_test.c does not free the string > memory allocated by sscanf correctly. Fix it. > > Signed-off-by: Xu Kuohai > --- > .../bpf/prog_tests/kprobe_multi_test.c | 17 ++++++++--------- > 1 file changed, 8 insertions(+), 9 deletions(-) > > diff --git a/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c b/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c > index d457a55ff408..07dd2c5b7f98 100644 > --- a/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c > +++ b/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c > @@ -360,15 +360,14 @@ static int get_syms(char ***symsp, size_t *cntp) > * to them. Filter out the current culprits - arch_cpu_idle > * and rcu_* functions. > */ > - if (!strcmp(name, "arch_cpu_idle")) > - continue; > - if (!strncmp(name, "rcu_", 4)) > - continue; > - if (!strcmp(name, "bpf_dispatcher_xdp_func")) > - continue; > - if (!strncmp(name, "__ftrace_invalid_address__", > - sizeof("__ftrace_invalid_address__") - 1)) > + if (!strcmp(name, "arch_cpu_idle") || > + !strncmp(name, "rcu_", 4) || > + !strcmp(name, "bpf_dispatcher_xdp_func") || > + !strncmp(name, "__ftrace_invalid_address__", > + sizeof("__ftrace_invalid_address__") - 1)) { > + free(name); > continue; > + } > err = hashmap__add(map, name, NULL); > if (err) { > free(name); > @@ -394,7 +393,7 @@ static int get_syms(char ***symsp, size_t *cntp) > hashmap__free(map); > if (err) { > for (i = 0; i < cnt; i++) > - free(syms[cnt]); > + free(syms[i]); mama mia.. nice catch! thanks Acked-by: Jiri Olsa jirka > free(syms); > } > return err; > -- > 2.25.1 >