Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2084951lqt; Mon, 22 Apr 2024 00:22:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVN9BW7hj1J2ma9WxYSEcKP/oneK2ILj0mAxzuWbRadO/9p2ondmx7Aez4I9jpFUqATrIJpbWErSGsmzqWzDuGTpcj6gt5DirWAGccNAA== X-Google-Smtp-Source: AGHT+IEnNTYfqUc0/wuaXu7Lc5xGWrh4uIC/4HBco+3J7JrSkBA34ZjfwD1hFfI4IyOIb3Aim6By X-Received: by 2002:a17:90a:aa0e:b0:2ab:8e59:9da9 with SMTP id k14-20020a17090aaa0e00b002ab8e599da9mr12993588pjq.6.1713770553006; Mon, 22 Apr 2024 00:22:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713770552; cv=pass; d=google.com; s=arc-20160816; b=H87T6hjGLQ+DdEc4WuhZo3HDd5SsHy8Vm0IgrM0cujdeV7yONK93HBzj/71/OSXxgd woj6llcrs81AqWBY/9umuozZheAb9JWWfLZGTLPt03g2lc1n3GhexFaQuIZLVRAof0s6 xGocJ24TgzTQOUJQdeBVxbOhGQtvuzLLJLoGykH1YRK/E5x3SEpY84jNTOKlL/Q5fZOT D1uCpwJZOl6CUZbzfPqCFmExkOt36rM/pvkt7/Xs+Lpt0DvIk4fBSq6ZNhSNekUMpBnL sbuce9TGVYDc+C3QjA7gIjiwTCBMRKt1bi+AHBj+gcwrUVcsxP2JfMNVneU6pN0eJWqF DHDA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:message-id:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:subject:date :from:dkim-signature; bh=1wM6PIeQCyGBitiOiLxSU/LdbaKAJUKSBhTu6/63Bl8=; fh=sk2QLqX6vQ5NOGmEY0UaOlFSzxRmgW/TNARUXtVWujs=; b=AbV+62C9yZkqqS7RT+VTchqq5kvaLoJzqZgW7nwMqBr6ABK84NfdensypNbbJcMLJF fvMNhn2Bk5F3oaoxGk0ow03frFc1pE0kHqGW+0htgm7inaxZR8wv9j/9wkLJ2Ly3Qobp 011YSxixGslFQe9ZnfYIcw8IQOVbBd8vmMihISLaumIAp7WnSztQEP9HSHQS1Y2C+npt P/bDCPLwFTf+nKA5UT+UDTetXepyxbuwChCXKh5GG2O942rEcDfcavlgIUwWDxIr1UzP icNCpSKWmkAXBXeXR8KRrDe9FEnOV4ubV2tnA7zDG4pf5BzmEiE70ppckdmGMJjyg+Hf LsKQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DHn3HXH2; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-152857-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152857-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id l17-20020a17090b079100b002adcf21fc12si1423050pjz.120.2024.04.22.00.22.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 00:22:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-152857-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DHn3HXH2; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-152857-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152857-linux.lists.archive=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 7AB22282D9C for ; Mon, 22 Apr 2024 07:22:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7E883535A8; Mon, 22 Apr 2024 07:16:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DHn3HXH2" 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 A7DEF4B5CD; Mon, 22 Apr 2024 07:16:35 +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=1713770195; cv=none; b=MpgbN9UH022/U8Y0etB/hRIxWZKDa7lXhcHbnWLfdtxCrQ5lFQ5aTynpdJj2x5fPcpPWP67iygHrKIVusmoXG+7G0S6JPYgVpwqoWTA0GhqggIiih+C3n8BtiGHClxHXf1KDDARG14XhQNXTLMuBIOE5RS8+izFO209hM8ZB/88= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713770195; c=relaxed/simple; bh=NfAfxY4XqZehCfrVo6N7fe6sz8Rh1GXdjQSYW+wwx44=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=Ld6RmEiBhx1AVGw7rtMB+tp9+wj+MGLyjYQ3dX0pDoDTFuPTLTMr3nH8fIEEpm/ZxRE1epK8DCxusBKO2kl6iyBD2X4f7ACGIWz7UgpzEp+LrtmsLRCeaot6jKOPuLeWUvy0Km1vq5r6AC8/9fPzCK+xkgj3u7cQSuXPU72i/o8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DHn3HXH2; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40A6AC113CC; Mon, 22 Apr 2024 07:16:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713770195; bh=NfAfxY4XqZehCfrVo6N7fe6sz8Rh1GXdjQSYW+wwx44=; h=From:Date:Subject:To:Cc:From; b=DHn3HXH2eCN2Mb4w2HpzvQHTeCkLsaR/+ccsCUzukakQ4Tq82aKmoFrqyui3aEsdi tvm+AmP4HXZpsCiZLs4Bv/xzQ1EYRcFF0grrqjysrb528ZfaUQ5dQpM0ca0InUsY9Y j4h1Xe28vB7M1l7Fz7RCmMR4bSIU+Zf+zbfS9s37g+jh/5HzDUZul17XGJamEmOw6+ ib+TGfN2Bv4JpQO6QLPze5WOWj/VnJ+5vpjeRtTb0mh+Oz3WZeaTFxEJFbBOl0GGX2 COfNVMUDcIF5ypOY+aIXByE6TeSdkQV/zQN/IMQ8GYkhVLTsEq4wWPt71WQROb5Jy0 AhjPz237m8Bdw== From: Benjamin Tissoires Date: Mon, 22 Apr 2024 09:16:28 +0200 Subject: [PATCH] bpf: verifier: allow arrays of progs to be used in sleepable context Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240422-sleepable_array_progs-v1-1-7c46ccbaa6e2@kernel.org> X-B4-Tracking: v=1; b=H4sIAMsOJmYC/x3MQQqDMBBG4avIrBuIISB4lVJkkv6NA6JhBsQiu XtDl9/ivZsMKjCah5sUp5gce8f4GCivvBc4eXdT8CH6GIKzDaicNiysyt+l6lHMwWc/pXHKnBL 1tio+cv2/z1drP7hSVYdnAAAA 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 Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Benjamin Tissoires X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1713770191; l=1344; i=bentiss@kernel.org; s=20230215; h=from:subject:message-id; bh=NfAfxY4XqZehCfrVo6N7fe6sz8Rh1GXdjQSYW+wwx44=; b=BOoh+3TwqNJ3VgIIKuFS0X05BWosUogOThOQNNnoxXo2ZDKy2YK8wSwezXl2YpCCvtTMDFrbv nV7g17D1owCCy/3fLmUPTxsHFWWflmCJJ5mxb/Lhwb5Vqj5dSIfPKc1 X-Developer-Key: i=bentiss@kernel.org; a=ed25519; pk=7D1DyAVh6ajCkuUTudt/chMuXWIJHlv2qCsRkIizvFw= 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. Cheers, Benjamin --- 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, -- Benjamin Tissoires