Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp385779lqo; Fri, 10 May 2024 02:59:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXU+ASAUrrqOQwo3lPHILZVL1BvEIRQLjgu25oG1EfI659QmrVs3leCnnbxjHvOAPLrsLK2SIFJJwR3J1Vyn7K+V2cBf3GM1arcZta1YA== X-Google-Smtp-Source: AGHT+IHNHXaowe1XR0jJkoW2a34hblMdTubRbGLLxeG95/ufFdVKneKYogw665G+Yif1NsLwlRSM X-Received: by 2002:a17:90a:c256:b0:2b2:a1a0:4b51 with SMTP id 98e67ed59e1d1-2b6cc777f53mr1873759a91.19.1715335194754; Fri, 10 May 2024 02:59:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715335194; cv=pass; d=google.com; s=arc-20160816; b=W8cPATIgY6j3I+jJg8o45cAzcJT2WSnIQ9GchuojMcjpvHkAyjmzeIbzWd406YsecU t7t1lKbUo371/UxsSpvowO6aKWV6pJxPGqlz6rP7AHGqZuQ6KBpaUuI0kKIFUZ8sl6pr pkISOeH+Byf10/zpJPPu2xXXWNCDS9UZIY61cQ6ixkg6TYH5VaV5WKRlkDhmXyJ9J2Se x2sCQkZZCeESOm51h9Eff4dadCPRSm1SltR4CR5fwtvFr1QQwWpEqC8NcYYJOPLszM6v CkMcVdBIA8qgZ+5O47dHNe6p/+NdOOItNXEfLtkGvof1XAlG2PbisdYQGfCCnUPAboHV iSIg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=/aJZjrayVmmqLyz6Ky6ChcOrC6sjpvX/LIO1l69Ryr8=; fh=lPKFJvVb52pC2FZAsmTs3X0iL2A14rZznWkIdxXku7w=; b=QMxzqObXwd7Pkd+qFjwUaJBDZE59clSVaLWNXZSZV/63BtOAotg38yY64uEdEQmGxe 69+hXuDTVpgX7oNRUbsHC6e98Hjd8sZCEfIooCUxjc25yaVzPnlVuckM/ZSS8fudPFov rA2t8hebZX5RgIYbJ7rX/jz/aEavmPp/CXm7YGVKKipk3NRJxK+2bpYwwZp/siVEOCCX FzKB0Lp41DID+Bs+vKSYEyQUE1fhlsnMKoAt22MxUmnGRL2ZZS1w4Lr4EsQEN+XpVfpx rQTFPXzG30btMWPxUCwr4/eC99pAbE5fpAIfI2W+1JXd/6D1c45JEq37zpkVLN/x7pOS /cTg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="N/iODyYK"; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-175560-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175560-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b671689eddsi3420875a91.164.2024.05.10.02.59.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 02:59:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-175560-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="N/iODyYK"; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-175560-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175560-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 61F242826C1 for ; Fri, 10 May 2024 09:59:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E2222168AE0; Fri, 10 May 2024 09:58:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="N/iODyYK" Received: from out-184.mta0.migadu.com (out-184.mta0.migadu.com [91.218.175.184]) (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 ADDEE16F0C9 for ; Fri, 10 May 2024 09:58:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.184 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715335119; cv=none; b=qmtWi7K3sCdAh7et2byl+B3dG79y6a1czaYgIx/L6Ad3ShkGEaoPqKlPLgFoJV05B9z0iVDISJ2w9j19uwJY85koZWgiylZkEKVvBcOZUY3/OhDH6M9SgSHjCslMbJWtfc85Or1CYLRVr9MSGPgGSV+m1IUTyhfCCLWLTgISnUI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715335119; c=relaxed/simple; bh=bB491r35n9N4uzXZc1q70gTMtCa6mqt+ofgDXjFs3MQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ks5BWZ/5l4ew9cdo/Pb3gj7jQwP7hVaDx+B2+J+JhNLlCctQdv7+d58scFUHNQ2BfboCPiWiSHpiAdgZLT6SSSXvmKiWuuOzR4dj82IYet09FC4ILAB9J78fSBX4vyHhnJjAcmlBG6HX6zJdW7tUpo1BykIW+pCJ6A1xipamWhw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=N/iODyYK; arc=none smtp.client-ip=91.218.175.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1715335115; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/aJZjrayVmmqLyz6Ky6ChcOrC6sjpvX/LIO1l69Ryr8=; b=N/iODyYKTv6xAF8+nPjTOJa6CAmoLouxAjoxhfoA0TJudge6lBicKGj1CddBCibuFK0//A WrbwYOijJKVMh5OMczOZkwoy2FwZGhdyHnUbXIub8GhOgAOASpC0t2jP1GGbVH0T2DX41t yQpNIwfOH6cFfPCqsKNKSD+hZ4eIQ04= From: kunwu.chan@linux.dev To: ast@kernel.org, daniel@iogearbox.net, 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, Kunwu Chan Subject: [PATCH bpf-next v2 4/4] selftests/bpf: Add a null pointer check for the serial_test_tp_attach_query Date: Fri, 10 May 2024 17:58:03 +0800 Message-Id: <20240510095803.472840-5-kunwu.chan@linux.dev> In-Reply-To: <20240510095803.472840-1-kunwu.chan@linux.dev> References: <20240510095803.472840-1-kunwu.chan@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT From: Kunwu Chan There is a 'malloc' call, which can be unsuccessful. Add the malloc failure checking to avoid possible null dereference. Signed-off-by: Kunwu Chan Suggested-by: Daniel Borkmann --- Changes in v2: - Use ASSERT* instead of CHECK - Add suggested-by tag --- 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..a5ebfc172ad8 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 (!ASSERT_OK_PTR(query, "malloc")) + return; + for (i = 0; i < num_progs; i++) { err = bpf_prog_test_load(file, BPF_PROG_TYPE_TRACEPOINT, &obj[i], &prog_fd[i]); -- 2.40.1