Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2364147lqt; Mon, 22 Apr 2024 08:44:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVItuPKdOuRE+zSnpKTRTQC6BY5vc3gly0aIKDecTDOVXuffx2UFI+GC2ir8kmaR+E6iJRoMzgbznw4NcLGY5XL+tPlxbKf7V3imh5pqg== X-Google-Smtp-Source: AGHT+IHLmPRC7zJ3jQ/LoD09xH+Wi/Lkx15n1m3IryFot4nd2Hh7E4YVI4BxfPutXbn/gjCfwSqr X-Received: by 2002:a17:906:198b:b0:a57:e2d0:5d6a with SMTP id g11-20020a170906198b00b00a57e2d05d6amr920078ejd.5.1713800692170; Mon, 22 Apr 2024 08:44:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713800692; cv=pass; d=google.com; s=arc-20160816; b=AYFzxoFl6CDjnamIrdS5gaM3P5pwBPyI0IMbDM8J9Ub5IMJVp4WtVdqvyT6oyytcxz E7oVXIsP8QeAOvttxo++46BhxX9DG3RInteB+iiF4kss062VgHkBu6vYiR0XLsPHcLcA Pzj3itNL+HX/pWnpgLO2mf82/BhvtIEbzUHaHAO5BfLCcd7b7Q7KamS/21Iqq+7bThtH NKI9ICxBPA6AAp1+kihzV31YuYd3Z4X3RoAby1Wexx7YOwC7P2zr8CwQtm+OKfZ5pOR/ Yf4204zQjGBfHX19CzvZFVUdV2bP5/o1KDbWLyDQKMJvqujGOkB/TpRCiudU4+vY0vxD cl7Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=e2lT5/1rajezrWimLTKtgygjXyrCQCa/wvH4yM38h4w=; fh=ZFi3rLELxl1eJOZF0TBK6iGa6ZymkdQeJx3Z0gBLhZo=; b=FdfgthB0uG23QE6ZlZcte49h4q8dwJbbriInWmOhCWTHhc+70BuaI087PI+CkXx0/j spbPqZw7Snq6SU335om+Pa9uVo7rs9GVvFcDMbpfCipTqokkh1J8XzMMUj2Z3ekacz5o wiilZnK7k6j5nEYoPoSfogcgkRaR1b6fM7NQUI9sFKmaAeTz0iLKZk9BY9imjjvYD1uF F528gtYtYXxIJx1/+6EkPdMVtbCA1ZuwkjzKUXM+EcTJZ98bxwlcnFJUJK/62bjhkXf8 8PadRUq/IN+VwYCVK5wZyxa4J2HSjOJSAXbt+o9X6WJIDWj/UyCB9bN+q9PM0JubxdgO b3RQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@iogearbox.net header.s=default2302 header.b=D5ZO+q3J; arc=pass (i=1 spf=pass spfdomain=iogearbox.net dkim=pass dkdomain=iogearbox.net dmarc=pass fromdomain=iogearbox.net); spf=pass (google.com: domain of linux-kernel+bounces-153650-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153650-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=iogearbox.net Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id gv23-20020a170906f11700b00a52450cfb88si6117632ejb.619.2024.04.22.08.44.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 08:44:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-153650-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@iogearbox.net header.s=default2302 header.b=D5ZO+q3J; arc=pass (i=1 spf=pass spfdomain=iogearbox.net dkim=pass dkdomain=iogearbox.net dmarc=pass fromdomain=iogearbox.net); spf=pass (google.com: domain of linux-kernel+bounces-153650-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153650-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=iogearbox.net 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 am.mirrors.kernel.org (Postfix) with ESMTPS id B96861F2308E for ; Mon, 22 Apr 2024 15:44:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6F046153515; Mon, 22 Apr 2024 15:44:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=iogearbox.net header.i=@iogearbox.net header.b="D5ZO+q3J" Received: from www62.your-server.de (www62.your-server.de [213.133.104.62]) (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 8DBA9502A8; Mon, 22 Apr 2024 15:44:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.133.104.62 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713800683; cv=none; b=emtNONyYZ1hMc6nfvluhYjsyHJmm6Jl9lFUKFwU3PAwkylQdm8BzAE7CkODOZUE7Pkw2rPzp1Str+eUSv/jZC64zwr3liIwzqL6pTu9HgDKJPcdVKr+BzQFW3J1iA2w8WDR3xcHP1SyOO6F2Fz+uPFxx2M+M4j35VR2LNz7NJOQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713800683; c=relaxed/simple; bh=l7rKs3ixCXKoOcLYDLGrz2HItxbwWthaFHvLrLBduNU=; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=BOVzY7DeGt3YUTHT6sHsqYGgIKKPKmDv4ZSaZ76x2LOhn/vEn56vYS69jiC34IrDXrk5DUeMoPIv+2yTO3syZHYBiUG+oVJSQwM5Q1sS/MibMkoOY6SBpfjhEf3sq/0USLoxnGs9kmiZg9ihfatnx7ShdAMVb+C2Z7MruWJZzEM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=iogearbox.net; spf=pass smtp.mailfrom=iogearbox.net; dkim=pass (2048-bit key) header.d=iogearbox.net header.i=@iogearbox.net header.b=D5ZO+q3J; arc=none smtp.client-ip=213.133.104.62 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=iogearbox.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iogearbox.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=iogearbox.net; s=default2302; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=e2lT5/1rajezrWimLTKtgygjXyrCQCa/wvH4yM38h4w=; b=D5ZO+q3JfddXpR/n0E4yEf686f UMvNuV5qbGRKT3s4w9jIkx2DIkUO0bUSK52NWa/XKL0Eb24J+DPCFeFlO6HmVTdT7ih0Y2HzQXCdZ HWVO+ymTTCpWLi4LGl2KcXMF9EJYtHJkBBbFuQZMEOn4ytEG8k7uHHMSqe6JGrmMx2fbSNedNsA18 4GOyroYcVXr49KJQXMpvRGILktAOu46K1rTq4rFssJV2BanYYQWPOYT0+JZ06l0MHj1g4D1cYC04b bCSI7BZpoWP09gc4M7x369Xts+D9bPKd16l82ULyG4nJn2o994JrLU26HPiQ0jw0347W0aS+YUW79 x/Af/gKw==; Received: from sslproxy05.your-server.de ([78.46.172.2]) by www62.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ryvqE-000CQk-99; Mon, 22 Apr 2024 17:44:26 +0200 Received: from [178.197.248.40] (helo=linux.home) by sslproxy05.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1ryvqD-000AeN-0p; Mon, 22 Apr 2024 17:44:25 +0200 Subject: Re: [PATCH] bpf: verifier: allow arrays of progs to be used in sleepable context To: Benjamin Tissoires , Alexei Starovoitov , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240422-sleepable_array_progs-v1-1-7c46ccbaa6e2@kernel.org> From: Daniel Borkmann Message-ID: <7344022a-6f59-7cbf-ee45-6b7d59114be6@iogearbox.net> Date: Mon, 22 Apr 2024 17:44:24 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <20240422-sleepable_array_progs-v1-1-7c46ccbaa6e2@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.103.10/27253/Mon Apr 22 10:25:51 2024) On 4/22/24 9:16 AM, Benjamin Tissoires wrote: > Arrays of progs are underlying using regular arrays, but they can only > be updated from a syscall. > Therefore, they should be safe to use while in a sleepable context. > > This is required to be able to call bpf_tail_call() from a sleepable > tracing bpf program. > > Signed-off-by: Benjamin Tissoires > --- > Hi, > > a small patch to allow to have: > > ``` > SEC("fmod_ret.s/__hid_bpf_tail_call_sleepable") > int BPF_PROG(hid_tail_call_sleepable, struct hid_bpf_ctx *hctx) > { > bpf_tail_call(ctx, &hid_jmp_table, hctx->index); > > return 0; > } > ``` > > This should allow me to add bpf hooks to functions that communicate with > the hardware. Could you also add selftests to it? In particular, I'm thinking that this is not sufficient given also bpf_prog_map_compatible() needs to be extended to check on prog->sleepable. For example we would need to disallow calling sleepable programs in that map from non-sleepable context. > kernel/bpf/verifier.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c > index 68cfd6fc6ad4..880b32795136 100644 > --- a/kernel/bpf/verifier.c > +++ b/kernel/bpf/verifier.c > @@ -18171,6 +18171,7 @@ static int check_map_prog_compatibility(struct bpf_verifier_env *env, > case BPF_MAP_TYPE_QUEUE: > case BPF_MAP_TYPE_STACK: > case BPF_MAP_TYPE_ARENA: > + case BPF_MAP_TYPE_PROG_ARRAY: > break; > default: > verbose(env, > > --- > base-commit: 735f5b8a7ccf383e50d76f7d1c25769eee474812 > change-id: 20240422-sleepable_array_progs-e0c07b17cabb > > Best regards, >