Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1872508lqm; Fri, 3 May 2024 08:48:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX+zbZODkMHECH12QS1x97BdRE8/8SAH3OTUo65SLKIqgPxsr2tpfZaJkINEb0rGroqiNN9vifodTeJQkvT0nbzv+qJPXZ6CYU2CTiY2g== X-Google-Smtp-Source: AGHT+IGg7hn6N5Z65Ajaelgepl0eRfycGxmwzSsFlvHPR47JUFSKZ2/6/YeS0P3SIiQhiEZvalBJ X-Received: by 2002:a05:6214:1cce:b0:6a0:6bf1:446f with SMTP id g14-20020a0562141cce00b006a06bf1446fmr3388438qvd.48.1714751302066; Fri, 03 May 2024 08:48:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714751302; cv=pass; d=google.com; s=arc-20160816; b=XBYOU4DNU5Gu2KR3TUHm0iJolaU56e9RubjbdGImlP/WiSArAppDEQXLW8kF/1sTIZ TSSC5ewrcGLEcmdc95PywXXdbNFGSG8HuGYjb9rNkQubRN83IXod+kqmDj4bkCdBieKR xtwWDJFYFJSw79YK/EbAbydacPyOl0JMGqh3o7NBmma0tEhXZ8MjvFYKOl8VOvvfCCq7 ehigNxV3bZQNp3LGOYN10pg4wfAUlUauIBLHG0NgZpBmoNyR9ags+XC1lnwEElkTHbb0 ZoCZmccXdo3FB8nkvzc17YD6HTTTrgCLbKfbpICoJH8XdtGhj8g41QA5fdxmLVwJe+M+ 1SFg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=1Mms1nJYekqnIQG20iD+aIhue9+zCOecetn66x4QcBQ=; fh=ZYc6zRCCvY0qh2r5+TkI4mzufxdOfZVyNzFOnOHtm2Y=; b=NlqVT9SmX6fXUYsD2Pu2QSemF3wF2lG02Vx+B6FvB+QheAMq71aCflzy/Cp/0JP8vu ElrA4TlSDosxHzcAWaYS07TOHSGd/NOYToy05B2MbEJhtjZI/WBlQKvgV1i+A1dyV+MU wEih9iUMQc6rV5txHJBvr77jGD+w4NqVJvQpJd1TEwg+923gYO8bqWs6lkRAmdUH8LY5 h6oYXKdH3fRIXz3vm1vgU6mMWnqWtrCRnnYbV5LRaZlUXDHheMkodGlCwkpByfA3gRTd NmYvAv3Ml8q6I65Uiqgkz3IDzWhkOUiT/84WMrB1+SzGT4zL5w3YoPlOol27q/Wi7kA9 tNnA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@iogearbox.net header.s=default2302 header.b=Lb9f9vCE; arc=pass (i=1 spf=pass spfdomain=iogearbox.net dkim=pass dkdomain=iogearbox.net dmarc=pass fromdomain=iogearbox.net); spf=pass (google.com: domain of linux-kernel+bounces-167854-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167854-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=iogearbox.net Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id b41-20020a05620a272900b00790a45f2bfcsi3807603qkp.653.2024.05.03.08.48.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 08:48:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-167854-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@iogearbox.net header.s=default2302 header.b=Lb9f9vCE; arc=pass (i=1 spf=pass spfdomain=iogearbox.net dkim=pass dkdomain=iogearbox.net dmarc=pass fromdomain=iogearbox.net); spf=pass (google.com: domain of linux-kernel+bounces-167854-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167854-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=iogearbox.net Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id AABFE1C22620 for ; Fri, 3 May 2024 15:48:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F13511552FE; Fri, 3 May 2024 15:48:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=iogearbox.net header.i=@iogearbox.net header.b="Lb9f9vCE" Received: from www62.your-server.de (www62.your-server.de [213.133.104.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F81C153BD2; Fri, 3 May 2024 15:48:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.133.104.62 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714751293; cv=none; b=ezflZhv9Rmko6z5my0cQ0auDt9U4ye++jc924TSm9DPcOJqmEumjzvgheS7Ho8NQQC7P/t7dwhUcSZqAtCJVjKq3snr28lhgAuvta4k8oc8lAxr8EiLVjuI+I3US8Qp9ww0R/nGtsCSPEX/cIHVMAdtJAqXpnUM85qBweSuIoSg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714751293; c=relaxed/simple; bh=Gi57PnaSyxj86AO7nfWeJDnXmY0LCGAjn3DvnN/WWVk=; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=lfF0U2tL6icsxfmWSFNu6MCj64KTiFYLw4Qa+E4FhW6ZXrTaAzaHvXPpOr/+kyBqPCBSH/McIfeyrIxKZ776JPCkVPYwr58nzk5TQn6T16blyvZAp7odzFmroNlfYAdKjFfo3GUpQekf7xeMmu1sKBzpdwBhg9m4gia56OSqe+U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=iogearbox.net; spf=pass smtp.mailfrom=iogearbox.net; dkim=pass (2048-bit key) header.d=iogearbox.net header.i=@iogearbox.net header.b=Lb9f9vCE; arc=none smtp.client-ip=213.133.104.62 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=iogearbox.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iogearbox.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=iogearbox.net; s=default2302; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=1Mms1nJYekqnIQG20iD+aIhue9+zCOecetn66x4QcBQ=; b=Lb9f9vCE6m+/eqCCO1fEr9PmjU p6wRQEOrA04SblKdyydwNzKv5HdE5h+4ErxYxulFkG6Q56DuIt7wzrDwgaC+ouOh4w5ep9RDnLPXL jlfoS1qNWp4JADAyPXv/j501H4peMwDA0DW50RCdEXFwcLug02R6zTm/SsxqWUdmKnWMEenAqMMW1 PqIPsU9SYeLoPgtXQK7F/bDkfeDzQKVNFZVdmY2h6+3Qx+xk/JkGxnOQUTDk3JfehgzrpdaBfdZ+D Po0HMTAT+wXhIknDOCTah0JZcQ/LiwceH4/pq8S4XS/ORjjFQHzRpumoNMapkh706nvk1pLC23KBm /KXK46jw==; Received: from sslproxy04.your-server.de ([78.46.152.42]) by www62.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s2v7f-000IQM-0M; Fri, 03 May 2024 17:47:32 +0200 Received: from [178.197.249.41] (helo=linux.home) by sslproxy04.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1s2v8F-0006tI-2S; Fri, 03 May 2024 17:47:31 +0200 Subject: Re: [PATCH bpf-next 4/4] selftests/bpf: Add a null pointer check for the serial_test_tp_attach_query To: Kunwu Chan , ast@kernel.org, andrii@kernel.org, martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org, yonghong.song@linux.dev, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, mykolal@fb.com, shuah@kernel.org, kunwu.chan@hotmail.com Cc: bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240424020444.2375773-1-chentao@kylinos.cn> <20240424020444.2375773-5-chentao@kylinos.cn> From: Daniel Borkmann Message-ID: <79df3541-5557-05fa-a81e-84728d509bfc@iogearbox.net> Date: Fri, 3 May 2024 17:47:30 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <20240424020444.2375773-5-chentao@kylinos.cn> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.103.10/27264/Fri May 3 10:24:33 2024) On 4/24/24 4:04 AM, Kunwu Chan wrote: > There is a 'malloc' call, which can be unsuccessful. > Add the malloc failure checking to avoid possible null > dereference. > > Signed-off-by: Kunwu Chan > --- > tools/testing/selftests/bpf/prog_tests/tp_attach_query.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/tools/testing/selftests/bpf/prog_tests/tp_attach_query.c b/tools/testing/selftests/bpf/prog_tests/tp_attach_query.c > index 655d69f0ff0b..302b25408a53 100644 > --- a/tools/testing/selftests/bpf/prog_tests/tp_attach_query.c > +++ b/tools/testing/selftests/bpf/prog_tests/tp_attach_query.c > @@ -39,6 +39,9 @@ void serial_test_tp_attach_query(void) > attr.wakeup_events = 1; > > query = malloc(sizeof(*query) + sizeof(__u32) * num_progs); > + if (CHECK(!query, "malloc()", "error:%s\n", strerror(errno))) Series looks reasonable, small nit on CHECK() : Lets use ASSERT*() macros given they are preferred over the latter : if (!ASSERT_OK_PTR(buf, "malloc")) > + return; > + > for (i = 0; i < num_progs; i++) { > err = bpf_prog_test_load(file, BPF_PROG_TYPE_TRACEPOINT, &obj[i], > &prog_fd[i]); >