From patchwork Fri Feb 9 13:26:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 198864 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp850081dyd; Fri, 9 Feb 2024 05:28:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IEAc9s5w6KgqvPaB9fZobx48UF+GwXyGzDp1abMHBnRiaOb4QfJefQMJfae+dpIjo178i0M X-Received: by 2002:a05:6a21:3417:b0:19e:b534:1bcb with SMTP id yn23-20020a056a21341700b0019eb5341bcbmr1696640pzb.23.1707485334203; Fri, 09 Feb 2024 05:28:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707485334; cv=pass; d=google.com; s=arc-20160816; b=g1NxZIV8LJdBtnnxnyTV08Hw6QePqfkYhkTxtCeCzGels3Ln1LqAGELP9bTS3zNMOX /YQMdWQg0T2ZOk4OxwlRDbOQinqqlpnkCLZ+JuMjNhOl93VHyJBgmUKuxKFLOth1PAEA 1nOt59eRHLPOSWfO4PP5Kbq9haKEQpIzqcg8Kw7pL/aTUK2g216FYNWy/bkpynSNQ8nF i21dXXbGjiNshue/I5NwVcCEOWiLPU3ttgtpDm9CCKHV82A/HDp7mOBgx9/Rl6KKcXIp 9cI5XO18y0DUNrLG1/bxMLsdpq3eAe8ou4mySm2d6ixhkE+HkjIMh+lvkK3hDelg9tMG qRGg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=CBHoJIoRHIOFJUlQgu7I9hR4rv8XTMDA6p8bxUXTJiU=; fh=OUeoWWvO7wPBfUaRXPehr6gOZ0DRPpK1qpajOzJNazs=; b=Y2vpCsb2Tk1EMr1O3FyXyMzrsC9A5o4RDwgHxtW3bkj5M4rSF4eR7K1TrqB5jm1H4T 7TmaCeyruWsISB0JM9P4bZA/U+b0Xt27frQN9tBXnRP2gAqG3JugyoD2WmIRDHMUe5MF hkbRUmyijYWvxEHzoAks+APRCHis6TczKiRzS5ophzkItNn0pJtbUwVBng5Di8wKpKrh WDd5YERFXZEo8letPxLlNr5kFJAmPEVEzX9ak+VryrUElv/MX+JYMFWjJsqKNm0Nvl3Q B1eKCXxx7OHrRvOHfcbyA73+f5uLuGrAi1CFgvbWgsHA2vmmQbLvkNOwiYf6z4eKmivC I7kA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MIc98VEK; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-59361-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59361-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCXhFdjcqYX1n2rlTcspMoAk1t5B/o7XaXg9TUINw9yRq1ovAesidoOjN+2wbbh7u0f98rPShZBVuO/LooYab3phSTC5vA== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id f18-20020a637552000000b005d849f5352csi1629230pgn.795.2024.02.09.05.28.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 05:28:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59361-ouuuleilei=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=@kernel.org header.s=k20201202 header.b=MIc98VEK; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-59361-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59361-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 33976B21410 for ; Fri, 9 Feb 2024 13:27:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 06E083C689; Fri, 9 Feb 2024 13:27:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MIc98VEK" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 46D6B3C466; Fri, 9 Feb 2024 13:27:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707485224; cv=none; b=dFZAuGQ449zAK26t+w+S5R4sBojYGDZ2kmJFiQpXKctswFnQMyMfbqNFeCP8CgCqa35w+4o06Dt69GoLjdXvHD6gAimKdp6+ehpVF//XKMyGM/6gUCbbdsrmSrmqV1t1zDqOGTjnGklURcx32wcy23fo8r12seMnJ5AZuUPuYdA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707485224; c=relaxed/simple; bh=aggtpyZ7nek3MZgtSL3z0MIgLr9QD1bEIGZyyyntbxw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=N7crNCm3HAZJzjQ7gYOYralr7DEpM7ibbnxSNZlZOR4b6P7Jq4q3Pto9jazS42oxII9nMNDtU8DY040QkdBRO5x00AEB791412ybiasWEAeVaPVK0zR8UPNVl40czNRJILukkyV3DPuTxEAHjT6yFWBDuV8RE4i3gVVJVyf6yls= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MIc98VEK; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7DD4C43394; Fri, 9 Feb 2024 13:26:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707485223; bh=aggtpyZ7nek3MZgtSL3z0MIgLr9QD1bEIGZyyyntbxw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=MIc98VEKq8ZDUCNTdyy2g1SBEH8q7/pxZ1YshsTUTa3jDv1BQrGHl62pEAlh88wXz mnkNnYwJzASe3uwcrZDHhpqAXN8iCpqLYbV3S9+/tWcq1hOrau7T2BbwruJNsQf3l5 iKd1F8EnF3GptJoBToHzDbSd0WuUC5I61Q40PQac3lRSN09wrlQ+tKOTuqOQqsyDEw 7FCbg/ardaf3hNjJMree2VC8+FOhxVopxXiajn1oQKlqLyEz2UXLKLxXyFsxkyyNkL JaVYUaaGtsUyaTHNat+bRnPSDj9S+aWH3D73wmoY1+ULUBZmP/HBOYdFeWGxANIABt kWTZnXe6XsMAQ== From: Benjamin Tissoires Date: Fri, 09 Feb 2024 14:26:37 +0100 Subject: [PATCH RFC bpf-next 1/9] bpf: allow more maps in sleepable bpf programs Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240209-hid-bpf-sleepable-v1-1-4cc895b5adbd@kernel.org> References: <20240209-hid-bpf-sleepable-v1-0-4cc895b5adbd@kernel.org> In-Reply-To: <20240209-hid-bpf-sleepable-v1-0-4cc895b5adbd@kernel.org> To: Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Jiri Kosina , Benjamin Tissoires , Jonathan Corbet , Shuah Khan Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Benjamin Tissoires X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1707485215; l=1146; i=bentiss@kernel.org; s=20230215; h=from:subject:message-id; bh=aggtpyZ7nek3MZgtSL3z0MIgLr9QD1bEIGZyyyntbxw=; b=d+t4wgMQWZy/S6Wfo//ND8tfS7Mtbe7J5QL0nBRV4rQPp3M8dQfY4Y56bXuggZdkfNZlUY8QU XMzXtFxJO5lAZmEF6x+JBhOoxriCFeU9J/Kw4yOAW3GEBE+W/oJW+Wt X-Developer-Key: i=bentiss@kernel.org; a=ed25519; pk=7D1DyAVh6ajCkuUTudt/chMuXWIJHlv2qCsRkIizvFw= X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790428141649392369 X-GMAIL-MSGID: 1790428141649392369 These 3 maps types are required for HID-BPF when a user wants to do IO with a device from a sleepable tracing point. HID-BPF relies on `bpf_tail_call()` to selectively call the BPF programs attached to a device, thus we need BPF_MAP_TYPE_PROG_ARRAY access. Allowing BPF_MAP_TYPE_QUEUE (and therefore BPF_MAP_TYPE_STACK) allows for a BPF program to prepare from an IRQ the list of HID commands to send back to the device and then these commands can be retrieved from the sleepable trace point. Signed-off-by: Benjamin Tissoires --- kernel/bpf/verifier.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 64fa188d00ad..3cc880ecd3e4 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -18028,6 +18028,9 @@ static int check_map_prog_compatibility(struct bpf_verifier_env *env, case BPF_MAP_TYPE_SK_STORAGE: case BPF_MAP_TYPE_TASK_STORAGE: case BPF_MAP_TYPE_CGRP_STORAGE: + case BPF_MAP_TYPE_PROG_ARRAY: + case BPF_MAP_TYPE_QUEUE: + case BPF_MAP_TYPE_STACK: break; default: verbose(env,