Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp520876lqh; Tue, 7 May 2024 06:33:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWwMVyZvXgv6wLePwRZs86qVOomS5lUXqqJ4ieGWgVSUKYccUfQp9qVwL+zGmFyzpPFEJapHO0pTe1nN4mTAJl3mQyXlIO3/wjWYEE1Cg== X-Google-Smtp-Source: AGHT+IFuILCFP5gzfW1Lnacxhxm11vxH0BQwLx0bRcSGR8e5zFIc9zDZ4nSkeu2JFWmm0oJmLUBo X-Received: by 2002:a17:906:7009:b0:a59:efd0:e884 with SMTP id n9-20020a170906700900b00a59efd0e884mr1105631ejj.27.1715088788508; Tue, 07 May 2024 06:33:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715088788; cv=pass; d=google.com; s=arc-20160816; b=AQeXMDp2LwH7DXevxEHv8qxR6ZZNlLiAlyFHtKJPEW4csRtl6KBoyyIaJXwoprG4CX oJ0sOr4rIWA80Zp+T3tEpWfdI/nNPmHBbkLOiyr4CYnLEhyZ+Jz8abMSDbD2gIOGxc1H P2+BGh1qPoEW/5/0dWZYhGSV//6riZkZDoYrFxTAhuwUoTHAAMdBmldfpXgWpM7ifLHY rMH4u/T2uy5na0z1Y6upbBi/5pMEnXLmcynimjumkpTszKpdfpJOZh4rVmbERkkRYa0d 8bz/E8EsjS8j7rFTdiGalfgE7IwXrVdYu6VS7e17pKLVMdNVDgXVoS219yqr5Mb/1QaH CrHg== 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=NMQRqQbAF7OE/cgRfh39mk39holiOI2Yx47HaDR8hU0=; fh=+xF1049tVypekkjShp17fvMlvSr2JIl/AO2WK77YLJ4=; b=QABiLmH3X0lnD+6yxVB6jS8bj5PNnZYpA+eQhnprA2Dt5/Kqm1ObJpx6eTL4LMxyEA +FDZIpyK6LYFmBD7nyXmSh2vZi/RhMPDdoasDXVkoD8pwIebiBaPCoxwuUNBkmdYe+cb r+xyVf3PpzBWZGGjMQcYwE7Za+i5l17iDBqoqwcYWYe1japxfni2px4t0KK2en0ijw1I V6UY+kdVkJZb+HV2UsQRHc9lVoaahVZkDtJorp0iFPJdMxLI/EuJ9rjbzSuAybr+kTQ3 PADJW/tfelsoQ5chyu0Yj1MuwpKEoEo4QNn8i3Xr3w5TC3PlvPKvfvxgRC6NEq6IkXND PdoQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OVfvXmDQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-171420-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171420-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ne30-20020a1709077b9e00b00a59f2702a23si510663ejc.846.2024.05.07.06.33.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 06:33:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-171420-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OVfvXmDQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-171420-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171420-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 8389C1F24C8C for ; Tue, 7 May 2024 13:32:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D2FD315EFD9; Tue, 7 May 2024 13:19:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OVfvXmDQ" 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 06689156F20; Tue, 7 May 2024 13:19:48 +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=1715087988; cv=none; b=rSFjQnoV5nty1p9u9JvJDtw+kj3EQpWLY+dpwQTikhlXAPZIqcswiStuVokJl1vj7sjc1h/jwvMwkeqVMzeXpTlD65mLzx6tkfAYwFEujN60dTWyP/K+99979FLqKJFyqxK4kwRn8nupCqKDRQT7E01RNY/ys9wkveQZKwoafrg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715087988; c=relaxed/simple; bh=isqHF8HeC8KRWX2yMwQXkLMgFKrRtCaj9HjYSmd5hgA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QwrAWQEgU6774txEwzOFpPQjbDOiu13hT55MXhNE0sJa7tPFCETyTJWxVaGkXhA7YGz4Vv2HSucMPAJOvpzHfOdialT/2RNiY0uDSrVh2BtN33fRsrtYouwgDWRIbQVSYpnvOiGE/BW9k1Bkl7bJn7xkMo5EJGJM9FgAX0yse3o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OVfvXmDQ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9CB22C2BBFC; Tue, 7 May 2024 13:19:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715087987; bh=isqHF8HeC8KRWX2yMwQXkLMgFKrRtCaj9HjYSmd5hgA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=OVfvXmDQMt7A0kehOhD20thI4YILIa2gsWLgP+ZQg2rnbPe0BuMSrdX/OfP6ZAJ3V CcipwCRBdjvZWaSl2O3WEfoMg/qph0ckxaQ4Ur97A37bkAEbfL3/W+AmVKuyTEu93Y Qs5Jb1Ma8AeyeI+I2VfTAzm1UYp4+sBF4QQ42127o7VDUbbh3vC/s3nZBiL4NOToQG C3fpyeYuzRbPQQ1xXYBJddInSf6grtVjkWvrratJKQQatYXOehprAw73COpQvNoCNy j6xrpEBJPMh1FmPrqNNv7xDx1qh1mXEkMqS6hcuxQSJZxG1KgDvBsHFXY0Jyct31CR A+Er9GRlfbrlQ== From: Benjamin Tissoires Date: Tue, 07 May 2024 15:19:29 +0200 Subject: [PATCH RFC bpf-next 1/8] bpf: ignore sleepable prog parameter for kfuncs 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: <20240507-bpf_async-v1-1-b4df966096d8@kernel.org> References: <20240507-bpf_async-v1-0-b4df966096d8@kernel.org> In-Reply-To: <20240507-bpf_async-v1-0-b4df966096d8@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 , Mykola Lysenko , Shuah Khan Cc: bpf@vger.kernel.org, linux-kernel@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=1715087980; l=1501; i=bentiss@kernel.org; s=20230215; h=from:subject:message-id; bh=isqHF8HeC8KRWX2yMwQXkLMgFKrRtCaj9HjYSmd5hgA=; b=k9rUZ8hFqZ1a4Otx1zvx4YybpnqH1zKr1uzHypliJVTIkPrH8HhUQncGvx39vaTB8CsEPXwbL L9Lx6klBAfGCaUsqQIF6lcEu73FyZlo049Px7cFVg1Fd+5G54E7eMxj X-Developer-Key: i=bentiss@kernel.org; a=ed25519; pk=7D1DyAVh6ajCkuUTudt/chMuXWIJHlv2qCsRkIizvFw= There is no change of behavior: for each kfunc, we store the prog sleepable state. But this allows to declare an async non sleepable callback from a syscall, where everything is sleepable. Signed-off-by: Benjamin Tissoires --- This is an RFC, and is not meant to be fully reviewed/applied as it is. I'm posting this to show what I wanted to explain in https://lore.kernel.org/bpf/mhkzkf4e23uvljtmwizwcxyuyat2tmfxn33xb4t7waafgmsa66@mcrzpj3b6ssx/ --- kernel/bpf/verifier.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 5d42db05315e..856cb77d0f87 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -5288,8 +5288,7 @@ static int map_kptr_match_type(struct bpf_verifier_env *env, static bool in_sleepable(struct bpf_verifier_env *env) { - return env->prog->sleepable || - (env->cur_state && env->cur_state->in_sleepable); + return env->cur_state ? env->cur_state->in_sleepable : env->prog->sleepable; } /* The non-sleepable programs and sleepable programs with explicit bpf_rcu_read_lock() @@ -20722,6 +20721,7 @@ static int do_check_common(struct bpf_verifier_env *env, int subprog) state->curframe = 0; state->speculative = false; state->branches = 1; + state->in_sleepable = env->prog->sleepable; state->frame[0] = kzalloc(sizeof(struct bpf_func_state), GFP_KERNEL); if (!state->frame[0]) { kfree(state); -- 2.44.0