Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp426350lqo; Fri, 10 May 2024 04:24:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXwaIim5DlpiaLULhrx3RKxWjz8/0Tei0423lmuqIDJ8oO/f0jmZbEyXUi3WPq5sDX4Z0PeH5grKEnTtnn6vP3bDdnWqYCzFjfTQM9hsQ== X-Google-Smtp-Source: AGHT+IEn8jUKRRshkr/AhbcGXl+DczjkFMnyXvKDIbvsADYgE/QdzVOxNwli483nV/evfrJ2plXh X-Received: by 2002:a17:902:cecd:b0:1e2:a61e:47fa with SMTP id d9443c01a7336-1ef42f7306emr38997365ad.15.1715340285944; Fri, 10 May 2024 04:24:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715340285; cv=pass; d=google.com; s=arc-20160816; b=bUtyI7JEPPVtYseFHtAcxxnYuteTFmxTUiwabwpEB3+YrkAC6XS3ppEPm/Y9JG2jV4 QN3TUx+EoAHAC2bwmN30E8mNoD4XNOgndYl8mCbC8S6vH8Z6WVl8sMv7f1TT0wt1ZEfL lbOD1trGppjV0HprDukqfmhdZydsPvRZYOVpyA+lxd4H2+2hXjjQUqH6lyGzOCwUY5IT m9DfzybnPtEAXOQnKR+XrRSsYiFVFaJRODcWvakIeJ5PsYVbpWPYdwu7leGgMLIIYG1f dt3cb60uYRkAy9RTzgrjFtq8dKEOeV+6wL5OyAT0sMzLJsywf1sh8K3g/ZKyXyCNXfTI wQ3A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:cc:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=LcAiN28i9ZXiu5PYUZ1XA0zzfLL/Tfd4apFVJ1ZfW4Y=; fh=Icz9E8DXite47jto1J5FDKj9WwOAR7K0spywDAVWNP8=; b=gXwkpQ1/LPWFeqLgRKfwxzm/Rjbj9bUpafAqplNOTEEscZ/QFraHgBq7xxfkMDOwdE 3PhSeeN6PiA/bLRS6yK2GfRC95/5gWllC8Ser1r8/9U4hjeuGMSn7N3zkuDoW1pbYzJl dRTUKw8kFjt58TfI7kHH4mW0TDTscxkTqo50qNkQ81tnLrrXzqwqKgs6sBsigVrRQLdT WEE2W4ww6QmJ96Zt+Diz/QLUfcsWfLi/YbeIBfeShWpLXEzH+WSAmezrsmIAbd2ql1j/ 7z/Z9JVTWve1IYT8U5Atq7NR1MRW/+fNr0sabXp6FUtmtEg4RhD0NpOs6lJOVo2YfW5C O8rg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=c60wX5yT; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-175652-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175652-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0c26a435si35528485ad.612.2024.05.10.04.24.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 04:24:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-175652-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=c60wX5yT; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-175652-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175652-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 1A87FB21504 for ; Fri, 10 May 2024 11:23:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6857116F27C; Fri, 10 May 2024 11:23:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="c60wX5yT" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (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 6758E16F26F; Fri, 10 May 2024 11:23:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715340198; cv=none; b=MYzXV2qlBHjytXZtw9WGm0ONeGN0MfBmBynoeaKpbIJIICX+8Nq7fkJJK4heUJUwvW8GGkLTE+uAREKpBTp9PUBHVs9HD5mpL/F1ySwUp03277AqB80vpIj3Sa7asNkaeDaPPue37ZyWozc7Xpvr1VUfiwzblalpcjj9QHwhV18= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715340198; c=relaxed/simple; bh=anqqfbe9MJN6ZwLFFJ7e1cXgGip46rgzku8Ub8NGudg=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=TVlzv/yGEy7CRAzTDkORs++pCQBaUzuHrggJGE1jmzEggzp6CojA8TPzuSAUTZqJyDdzZ1wgpbM/BzJy7rORrdW1YfDTBEPpPFdmcpqTFG+XdYw9yWgx0USDPkAy2ielxJAKxeK26svcvWRA440Bi6Pd6I1LfBCPhf+j7ojrc58= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=c60wX5yT; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1715340184; bh=anqqfbe9MJN6ZwLFFJ7e1cXgGip46rgzku8Ub8NGudg=; h=Date:Cc:Subject:To:References:From:In-Reply-To:From; b=c60wX5yTRPr3H8fCfHrc0qyQ/4n4HLSAG9/JAuRXeYOl+1LUdCrUtFopC/j9dtJjb 1HEQYl+IdXGEQLDAu9eOSiwEwNUUI/tfHzBVbnvsvXN6XeGW0jhdzCHP12F3k+ZUfN 5bR/Odls4m4VmNMXILcnuES9O39Mqj0w5igORyyQmrSRMYjwTsl5gFAJZ6QK8TO6q3 3vpMQ9VvyAlB1XheQ5Rk2mvQVBLHTn9Bd25NRd0lBlAqt+tm/H95Bjue3DTBGPR70k mso7uR+yAA7egGhWFnkZxYOgUBkwHazFZiiJrM3NXlMOSmYqq+aeiQlef+/0MZIJL0 cSflf8UCoppLg== Received: from [10.193.1.1] (broslavsky.collaboradmins.com [68.183.210.73]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: usama.anjum) by madrid.collaboradmins.com (Postfix) with ESMTPSA id C429F3782185; Fri, 10 May 2024 11:22:59 +0000 (UTC) Message-ID: <8020398d-497c-48fa-a733-4edc391838ac@collabora.com> Date: Fri, 10 May 2024 16:23:22 +0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: Muhammad Usama Anjum , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Kunwu Chan Subject: Re: [PATCH bpf-next v2 3/4] selftests/bpf: Add a null pointer check for the load_btf_spec To: kunwu.chan@linux.dev, 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 References: <20240510095803.472840-1-kunwu.chan@linux.dev> <20240510095803.472840-4-kunwu.chan@linux.dev> Content-Language: en-US From: Muhammad Usama Anjum In-Reply-To: <20240510095803.472840-4-kunwu.chan@linux.dev> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 5/10/24 2:58 PM, kunwu.chan@linux.dev wrote: > 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 LGTM Reviewed-by: Muhammad Usama Anjum > --- > 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)); -- BR, Muhammad Usama Anjum