Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp121300lqp; Thu, 4 Apr 2024 08:32:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUElmqI3Io5EuKBh2J6fXKNrZANY++hFe6YH8Tw5VbYf72GzevmRxwObrQ0D8OzQ/W70jg7WXLSTj0suZkBaDxepolpMzNjR/93bi5RXA== X-Google-Smtp-Source: AGHT+IE/r8GFCxvS6xtPVZGKIvbzJSiohVUz6aanGA382pxbnAs2XrJaOTYfQDCla+jmz+qkgjot X-Received: by 2002:a05:6a20:3d92:b0:1a5:7307:e342 with SMTP id s18-20020a056a203d9200b001a57307e342mr8613214pzi.4.1712244766261; Thu, 04 Apr 2024 08:32:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712244766; cv=pass; d=google.com; s=arc-20160816; b=FR7z76lWBP3IvXxKZ9PCEa2Gt2kSV0l1z5WooB8Toflm0YFgsmhWvJmHnooW8O5D5v Pec653ByuQYFpuDDKGrOg7sQrkdwTi/clPesRHkva+CWi/9zHh2lxwN65lRxEyvFnqbR AphnGJHvwGXtA3OU7tsvemEiMqeIV2ikvgzvkAXuQ90Xr6V+0u2L7eHQHS6ZFcGuzLYz TD+d2zxdonKsIumMM7FTLMzBSk/J6u6MC/h0k/tMv+w6q/y1Zi1o90ltl7Dauwl7Ps7v a5f1XpoitFSF2Wypy0YUjEDey4XATjNR3yHLfMa97aWvMPRbkzIEjzGfkCYrAJHky6pR mv/g== 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:references:cc:to :content-language:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature:message-id; bh=TbWKY4Vy0ejvQPnz3t0enxrmTjveEZaqpYoGRQFRIm8=; fh=hqfTfxOqALdrc5YlD1lT+uAi27asMmhesCumT/D3vgE=; b=flydXoDbdmTz3lJGMH3JVlzDoPqcwkhByt2mg3SbEk6TOePAmd83SrGcCICILyAsyS kSzFxOkIoe8Eysc7iVjsT/hSQeZjLa9GmxdmK+LyQW6X1Nvo4qD4I8//HBgjuvtvh390 8vHo1enAuMbLTgZNsABiXshb2AG7LUEMXVZ/poy+chTB96wOP5MiLqO6AzDcPxosJGx0 2ZYaHMJ23hRd+Azw7pFaOICy0qbmiuSZyhUEWH9mHIaiXZVXvgUTNkBKeOy+Wfb5LH3E g8mop0Dm0GVOTh8arxhMx8sUyTUYhzV6lyWuq3Bl4+Nwqwl0lPYWk30UdCbo24A3D/ka cn9A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=ZYB1soOt; 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-131726-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131726-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. [139.178.88.99]) by mx.google.com with ESMTPS id n10-20020a62970a000000b006e8f7973e28si15070853pfe.81.2024.04.04.08.32.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 08:32:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-131726-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=ZYB1soOt; 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-131726-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131726-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 E9C1D28A4AE for ; Thu, 4 Apr 2024 15:32:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2DDAF1C2BD; Thu, 4 Apr 2024 15:32:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="ZYB1soOt" Received: from out-171.mta1.migadu.com (out-171.mta1.migadu.com [95.215.58.171]) (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 948E2823D0 for ; Thu, 4 Apr 2024 15:32:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712244759; cv=none; b=NRajkMUbJN865b7rsm0T/KHeikzswr5cizdewgeXAW3QYbrqW3i7blLvpDDcaSXIQvyY0Jkh+u/BJ+DlOopkmzGPNsc/vwpClCV0vTpYd0j9RTiPEsTDXvhYNWTW1GUGAU6cV+UMJiH767xTTM10Ja9qY0frobjbpdWWzh4tjk4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712244759; c=relaxed/simple; bh=TbWKY4Vy0ejvQPnz3t0enxrmTjveEZaqpYoGRQFRIm8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=eTmhcXfFzz091GGuX0emaqIZHcEcJNKfMzEGiYneyNhsp9RV8svwOSiMdc2l3F/xl00Ss3trC8lMeTy9LJYyybfit3+K/cMoJ2YgawQSmoN7jC1YBeqbYWrfjz/PYXJr/L1w+CEknhPV3iESzwLbRe4WUcbGPH0jM6PlLER+bTw= 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=ZYB1soOt; arc=none smtp.client-ip=95.215.58.171 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 Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1712244755; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TbWKY4Vy0ejvQPnz3t0enxrmTjveEZaqpYoGRQFRIm8=; b=ZYB1soOtHTtumDOiZdM3uwyHGbGNDa+hwEvjQd2iLoVoUJIzjxUzeTDQhltVGMU8ZkYGcx F0qiJ5rrVItcmimx14lYAYAaipvldrSc+LngQyaEY2km9s98kvva4WuzWO7EPVhbWMSc1f 4/em2Ysci/Ut6kty1nnEkrPUJPOa0hU= Date: Thu, 4 Apr 2024 08:32:27 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH bpf-next 1/2] bpf: Allow invoking kfuncs from BPF_PROG_TYPE_SYSCALL progs Content-Language: en-GB To: David Vernet , bpf@vger.kernel.org Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, linux-kernel@vger.kernel.org, kernel-team@meta.com References: <20240404010308.334604-1-void@manifault.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Yonghong Song In-Reply-To: <20240404010308.334604-1-void@manifault.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 4/3/24 6:03 PM, David Vernet wrote: > Currently, a set of core BPF kfuncs (e.g. bpf_task_*, bpf_cgroup_*, > bpf_cpumask_*, etc) cannot be invoked from BPF_PROG_TYPE_SYSCALL > programs. The whitelist approach taken for enabling kfuncs makes sense: > it not safe to call these kfuncs from every program type. For example, > it may not be safe to call bpf_task_acquire() in an fentry to > free_task(). > > BPF_PROG_TYPE_SYSCALL, on the other hand, is a perfectly safe program > type from which to invoke these kfuncs, as it's a very controlled > environment, and we should never be able to run into any of the typical > problems such as recursive invoations, acquiring references on freeing > kptrs, etc. Being able to invoke these kfuncs would be useful, as > BPF_PROG_TYPE_SYSCALL can be invoked with BPF_PROG_RUN, and would > therefore enable user space programs to synchronously call into BPF to > manipulate these kptrs. > > This patch therefore enables invoking the aforementioned core kfuncs > from BPF_PROG_TYPE_SYSCALL progs. > > Signed-off-by: David Vernet Acked-by: Yonghong Song