Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp150332lqd; Tue, 23 Apr 2024 19:06:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXcBeNnYniCy9tddsjYy+0gbZqWLxEt1SbofJQ94qj3yEKXwbLkyxt3QEVbh2Xe2jC2UuH+BgB0VqTf8XY4ViWLf7nszC0cZsrla2dKBA== X-Google-Smtp-Source: AGHT+IGPLmOOUTDnc/gAe802KOfSpLbvLfTegKcEZUeQclqy8ByDDZ7C6+zEdetk97oCfSYgHn+i X-Received: by 2002:ac8:7d12:0:b0:435:c390:6d4b with SMTP id g18-20020ac87d12000000b00435c3906d4bmr1262924qtb.64.1713924366722; Tue, 23 Apr 2024 19:06:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713924366; cv=pass; d=google.com; s=arc-20160816; b=NH8rwnH8WFpSXrOPn6OchHYS3u2ZugJsvwGnZaF/T82pLg2lo1IHWNNRF+vc/gGrGN JhfQfjSpcDBPEA5d/SP8WALZZLOqwGh1sUaU0FKcO0QGl8S4W1CsbpcfYEEGc+C38yDm o1Qe5AxztJRqNcHwrCh+nZRb6MohhNs93yU2CeZJxFAYMRTjufLg2WH8w5a+9RjfHFMo yIbCl/GH5yJ6Qycy+TdxjbsWioQ+1T7BPtrsyMK3OW4mcpiS7UnJhZf+Z5yyyr5PadaE IYlKE7fk4z7qB7messU+6rKBzWr+6yCktoYVOkjSKGICcF/ZT/TWgOrdXLyzrQnEX1Fp OXAw== 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; bh=8HK1fmFu4Y7M51277rn2aG56sBWsZmlRqyOBUCSGoe4=; fh=lPKFJvVb52pC2FZAsmTs3X0iL2A14rZznWkIdxXku7w=; b=i85SMtBnXL6yKfldyPOS5UQKzrND/FUzcYKO9HXMDnqrdFwgfSoy2tHVkm7v1Q7wac DzHQyMa+wyAEEarn+CoHq39M8r8f57wtg6QI9+qz7lqDS0gr5LkYc8nVbQMrTc3n6vph uQY5E6Etwj2DDlmV//+W5L5QcK/30JJLbsaIbCvmsNvmjsAI/L+Vt8tymtUd1soQVFBx YJVFma1Kyj9WfybaSSz83rMPlTg/Hn0ft+6su4YYRuF4FW/0bpaLRd6vzJi4H+y2rC+A i8///ZRtGPD+dy6BUFW/UOVwk6eRSmCzCS7WndYwPGH42mp9qDom51w94fZC6G94CRvk QSmg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=kylinos.cn); spf=pass (google.com: domain of linux-kernel+bounces-156119-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156119-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6-20020ac85906000000b004372fae938bsi14038847qty.208.2024.04.23.19.06.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 19:06:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-156119-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; arc=pass (i=1 spf=pass spfdomain=kylinos.cn); spf=pass (google.com: domain of linux-kernel+bounces-156119-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156119-linux.lists.archive=gmail.com@vger.kernel.org" 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 753E01C2245E for ; Wed, 24 Apr 2024 02:06:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 391991E89A; Wed, 24 Apr 2024 02:05:21 +0000 (UTC) Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 BFE111A29A; Wed, 24 Apr 2024 02:05:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713924320; cv=none; b=RkgaVpEsES4o24+0xorzCALROqNRZHrg1VQHm2OlnARjmAUkHGIVAdW+SiuoDkBejnZOkOkkvpKVj/yOObr9CKjaYPtMJ4qkkGJZo3j9iWTAkPvVE+8+24yjw/cxWoWjhnQikUKWtdcY4wOCOOoqHPIR5o3OgTzZ5mFLUt6fzww= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713924320; c=relaxed/simple; bh=ACgsItn8OBoe+YbzAGxCaUt5pzTAl9TfLFs6OvA0SL0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VOV0CTSpDf4saBKlWJQFw2qQDcFdlLN/tA1R9dfaZZLUAscFqTYrHK3utHpt2nmem8ZLKPi1NalUvBH84spwzGlFLH6r51fqE1xUKmovOj00zIz5jL0+3aQ01ycPVNDQh/GeBYEHx3lG7QJ/IJthtr3Xzw0EjnVqwLR1poNPgDI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 15347db201df11ef9305a59a3cc225df-20240424 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.37,REQID:85785f5e-63af-4590-bb1f-d09fd9974604,IP:10, URL:0,TC:0,Content:0,EDM:0,RT:0,SF:-9,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:1 X-CID-INFO: VERSION:1.1.37,REQID:85785f5e-63af-4590-bb1f-d09fd9974604,IP:10,UR L:0,TC:0,Content:0,EDM:0,RT:0,SF:-9,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:1 X-CID-META: VersionHash:6f543d0,CLOUDID:4620fbdcf84b357a5ff4bb413a22bc27,BulkI D:240424100512622X49TE,BulkQuantity:0,Recheck:0,SF:66|38|24|17|19|43|74|10 2,TC:nil,Content:0,EDM:-3,IP:-2,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC: nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_FAS,TF_CID_SPAM_FSD,TF_CID_SPAM_FSI X-UUID: 15347db201df11ef9305a59a3cc225df-20240424 Received: from mail.kylinos.cn [(39.156.73.10)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 1552464066; Wed, 24 Apr 2024 10:05:11 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 2FF86E000EB9; Wed, 24 Apr 2024 10:05:11 +0800 (CST) X-ns-mid: postfix-662868D6-985344373 Received: from kernel.. (unknown [10.42.12.206]) by mail.kylinos.cn (NSMail) with ESMTPA id E134CE000EBB; Wed, 24 Apr 2024 10:05:09 +0800 (CST) From: Kunwu Chan 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 3/4] selftests/bpf: Add a null pointer check for the load_btf_spec Date: Wed, 24 Apr 2024 10:04:43 +0800 Message-Id: <20240424020444.2375773-4-chentao@kylinos.cn> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240424020444.2375773-1-chentao@kylinos.cn> References: <20240424020444.2375773-1-chentao@kylinos.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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, ); =20 raw_btf =3D malloc(sizeof(hdr) + types_len + strings_len); + if (!raw_btf) + return -ENOMEM; =20 ptr =3D raw_btf; memcpy(ptr, &hdr, sizeof(hdr)); --=20 2.40.1