Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp385679lqo; Fri, 10 May 2024 02:59:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX+95gMVj887lQfXFCSHQEarP46w0We//lvosqlCcvRNkAfWoCyC/USa6itCvtFaPeygJYJetdoqcFXypUv6ePVdgZeNf/nbAgg8O0FDA== X-Google-Smtp-Source: AGHT+IEmUbyFwWmKlY/PEMxuQE+Nb2Twqx5VSV8dtJP7W39huD8zHeT6Lcgkx6O4kA6hoLKZY04u X-Received: by 2002:ae9:c103:0:b0:78d:67aa:6a04 with SMTP id af79cd13be357-792c7597e3cmr206884085a.17.1715335178185; Fri, 10 May 2024 02:59:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715335178; cv=pass; d=google.com; s=arc-20160816; b=ib4DNBfiHkEcm4M/g7bq5p2UMhLM2bYN7yImGlkqU6jixUq5ML4h6lPi1vzH4GL9OJ wr1YNG1as/jyKCspaAWVFR20m0O04M1mHcVSkbgQHqES89yadcFfb3WaGEJ3IUHY4HLW Al7Uu6re2zA9ZD84yqxBUknafKLajYfsSGeg19fk46n/+gcsgspXTnCy1PoDJwHmy7wA O8uIN/auyrEiGFKMje1yr3rgrm6pepvpJeybSrkiyWw7RzuQquv0RkC6tJCJ+qb7lEIb xvaQOf9LUYVhr+VMxnDnvGsDTiPaYls7cFnoprKTXix/ZumWA9eW0WDBoDIMAJg6yLRL oZLg== 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=3nUhuTP23hsrziqOf8yd0GU1qZX9RbuetxzNfweNTAA=; fh=lPKFJvVb52pC2FZAsmTs3X0iL2A14rZznWkIdxXku7w=; b=HRMX7GiqDZIgCZPHmE3LFYhuDWMCFV71v1JeukN5ZwVZ1lpBiamHLA9qffa/bTz2Fh LyXRXvNMvn1z1HRk/9bZbypnwZJxzONzl2h1gqAN7rIWpRcN3cN6pOExdjKXIRgPi1qO A5RYzu7r3/R2YUPYilCpMTF3MU9mGzB7Q7NrQGkc6hcjxfWzJL+ItUnMPDn7P2LTh2Lt NOKzMuXXAr0UM/Jb00esoCZxJ2BITCBNbMACgDnEwJzA+JXaKYtQi/WRo55kE8tEKxPG V9e0Kw4rhCZiymjdVBr/H8e5Ks9zKyVOwoSWjMvlyIQQPG4fzdH6QJcsQkSZdYZa5iQy QRmg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=QC4d2x+U; 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-175559-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175559-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-792bf362744si350783785a.578.2024.05.10.02.59.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 02:59:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-175559-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=QC4d2x+U; 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-175559-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175559-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id E22281C20E23 for ; Fri, 10 May 2024 09:59:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 13CEC16E87D; Fri, 10 May 2024 09:58:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="QC4d2x+U" Received: from out-183.mta0.migadu.com (out-183.mta0.migadu.com [91.218.175.183]) (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 DB23D16E886 for ; Fri, 10 May 2024 09:58:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.183 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715335114; cv=none; b=VXJXChVSjOczCgh375VXnRLg2/DrcQdZm7FA5ZYkr+c9HxMkxLcG0cziF69ACafc+8bwBYPO9V0JPMUqYFdQZjnt9nzYJVEfeYzrGAYsXxD4VOjFXJx+lCI3PuC3f4hSfQhiumiFxt1md0vQmjF7dD3EjpWfh9IGAEbqEZ4/Fqs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715335114; c=relaxed/simple; bh=n56aSoeaesxhZLXjh7komGxYG9xTu0UlluiOU0myr0o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TXI/hLqoI2+IP8cVBH/EKcwRGqWQ+q0Ce/x5lBVh7zdf6g+/iem+p6EhY5sFm+J7vwR+FxwSewjdgSISRlEsHHErma5qvUuGRmkJMYj/9H5SzA1J0B5Q6H8AmUvS8/31+XJmAlT+917+PBQadLWBaVxZPbR6ybhRsfkZVjzQZ1o= 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=QC4d2x+U; arc=none smtp.client-ip=91.218.175.183 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=1715335111; 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=3nUhuTP23hsrziqOf8yd0GU1qZX9RbuetxzNfweNTAA=; b=QC4d2x+Uvb42OVN7atGAVYtug+FQ6KHIlk74Fp+4qQRTfZD5y9W9cKP+/1bCIje0Sg9xW6 /DOWweToYjAI014yjmDNMbdcZ2KaAQjh/PxdnETXBOWIyynRbnwMn8mdJ4mFp0GYyf2XjF e7PgIepQrPjCSDK9lkGbtseXH7HFWAk= 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 3/4] selftests/bpf: Add a null pointer check for the load_btf_spec Date: Fri, 10 May 2024 17:58:02 +0800 Message-Id: <20240510095803.472840-4-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 --- tools/testing/selftests/bpf/test_verifier.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c index df04bda1c927..9c80b2943418 100644 --- a/tools/testing/selftests/bpf/test_verifier.c +++ b/tools/testing/selftests/bpf/test_verifier.c @@ -762,6 +762,8 @@ static int load_btf_spec(__u32 *types, int types_len, ); raw_btf = malloc(sizeof(hdr) + types_len + strings_len); + if (!raw_btf) + return -ENOMEM; ptr = raw_btf; memcpy(ptr, &hdr, sizeof(hdr)); -- 2.40.1