Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2695222lqp; Mon, 25 Mar 2024 06:56:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWsZNyZTz3a1Kg8H4lgwU2C34eQ9OBQhQVLt1ghUJ46+cl464Cb+HLc3nhCoQDm7F73hlJvpOCBOSrJU6enP6WeQM3zkfwSxsOFuv6uyg== X-Google-Smtp-Source: AGHT+IF5ZuPHcLUomD2OQIpZMi1OwtFauHTTX9vJLPjN9q7e9J0HMY1gCOjG3qI6C3baGuD87g1H X-Received: by 2002:a17:902:db02:b0:1dd:c0bc:5933 with SMTP id m2-20020a170902db0200b001ddc0bc5933mr10302416plx.2.1711375003760; Mon, 25 Mar 2024 06:56:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711375003; cv=pass; d=google.com; s=arc-20160816; b=jyb/Lo3uX/7sz359gvMvmpMJgavobNFyGf1M3SFgBI2fsNF5H+Zm8GuoZBP0MbL5X0 +DM3etZ45rZUTk1oZl97buU3D85gGBJePSy9tH0vCxfc7A5bQ1azRBT0KynhP4RzpC72 pOBvs9JpRHyXs0m0ONL4xA6uEZDTs1UzhtmoRcuU7WGeOuKRe/KAdj6OZ2DsP8unXkXX Q2D2P1IaSUdYRvKedA3ApXFLOCEI5Cj1JxiqU6CsRIIPIyArnoGkOwMfp0zHCabimzB6 BSMGcz8xRwKaXTW///FnZvbVT88J367OpwdPFv9sxHphZwFZRzY3qdLk6QAxGtW7Wwd5 cT6Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=x8SCb74zPfhyF2KF9z9UJJIraYiZCDP8SSPjme+GvrI=; fh=q/qYeuEysaH7Eew8fkCIsyZ1OWR3NwceLaRYrkHNhik=; b=kF3GzbNs5wSZ/jdM3/1RXJ0N/kRzkBZzjT1YsmAUE+JWmyjPRTFQ24ZuCpoJm/Jk8p M/4KuaOAPbt0/L8rdm+OQF++2mxEBvrO1tDPr7qCEdHzezg4c+CCx0DrfF1gPB1Z8xSI g7Z79EaRLwvikq8guG0rO3F59/1KQYIfcJKafMx0lj4xN8L/LN630ZliewwUGUd/wdbR sm8NIWpx+5LY7Msiyz6zubcO2f7vu8Vvh/8w3hi1mJh0LzOxETLWmaTE1VHcF3ybZDGK g/MqicsYXnwA2drULiccwLRT0X1+QXE1ex5Ssa1tx65EVfhjBuuKzkFbR7Da3riPRgFa qNig==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jfEEXMXP; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116706-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116706-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 p10-20020a170902c70a00b001e01baf194asi1944007plp.472.2024.03.25.06.56.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 06:56:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-116706-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=jfEEXMXP; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116706-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116706-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 4B8442C8C3B for ; Mon, 25 Mar 2024 13:44:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2CEC76BB28; Mon, 25 Mar 2024 10:28:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jfEEXMXP" 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 6FF935D480; Mon, 25 Mar 2024 08:42:15 +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=1711356135; cv=none; b=RrCgoxYDhlaPL6nBDR5hgvV4vv+vzZLb6cDdXaOi+0twLo4aUJS+sMjuzKVsFBubAiK+rcvh/W3Lchp6DqGpH545T2yNSe9FJql5SBF/N+T0RG3tvwievzuCfxIzmTy+c3sm76avCsTVIH/1vrCyMBQKj1yF+7E+V5Z8SaaiQDk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711356135; c=relaxed/simple; bh=T7/juRgI0RYFtzJn/DyHvQa9WLQrkIas1WYOJnYYG/Q=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=PJxJw8xvcZqADK+Tlv0zLGYX3dQapeTmMuM7if//SaTrn9gJGh8Otee/Pjn5d3Q2EZYJidNQi0ZTFARsq9iQAS+QUHlk+80Szz3U+7NkpIJ5ep8oPEM7t+/B9pGZjjb8bC95PXCBTc+Agmxdy1wreYWwBIQp4knDrF+jqS6JI/0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jfEEXMXP; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DA01C433C7; Mon, 25 Mar 2024 08:42:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711356134; bh=T7/juRgI0RYFtzJn/DyHvQa9WLQrkIas1WYOJnYYG/Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jfEEXMXPQow2DoAAD+t7eJCuk4c9KnusX05DCDf/bK+Nsu9UZiyZMvIsYXE52+zFu KlHld6yGaNSlSguP2KQbDDys8fL2gpBBgI2xNpC1TKZH2vNI7ZrV6gFO3jJmUpKTVV 0eybsTG8SXWefeh2wcX7GWYoJIdFp02eoCXg7vP93hRiwVrbFJ1foJ/kVfQ0zjwv0R nFKFxwkjHp/n4b1LUn9VVAa3vSKEwV8ikcInYf/MkCj83ZWEujBFarXtj5Spt/6sdN DrJ3+iAV9yQERO05dHT1MvIPtELUxVciEO46Xtp0oqfuDXzUjdM4lecGJHF+tuGL/K Whcm8N3ppdtmw== Date: Mon, 25 Mar 2024 09:42:08 +0100 From: Benjamin Tissoires To: Alexei Starovoitov Cc: Kumar Kartikeya Dwivedi , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , bpf , LKML , "open list:KERNEL SELFTEST FRAMEWORK" Subject: Re: [PATCH bpf-next v5 2/6] bpf/verifier: add bpf_timer as a kfunc capable type Message-ID: References: <20240322-hid-bpf-sleepable-v5-0-179c7b59eaaa@kernel.org> <20240322-hid-bpf-sleepable-v5-2-179c7b59eaaa@kernel.org> 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-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Mar 24 2024, Alexei Starovoitov wrote: > On Sat, Mar 23, 2024 at 9:57 PM Kumar Kartikeya Dwivedi > wrote: > > > > > > > > > > > Observation is correct. The patch is buggy, > > > > > but the suggestion to follow process_dynptr_func() will lead > > > > > to unnecessary complexity. > > > > > dynptr-s are on stack with plenty of extra checks. > > > > > > > > The suggestion was to call process_timer_func, not process_dynptr_func. > > > > > > > > > In this case bpf_timer is in map_value. > > > > > Much simpler is to follow KF_ARG_PTR_TO_MAP approach. > > > > > > > > What I meant by the example was that dynptr handling does the same > > > > thing for kfuncs and helpers (using the same function), so timer > > > > arguments should do the same (i.e. use process_timer_func), which will > > > > do all checks for constant offset (ensuring var_off is tnum_is_const) > > > > and match it against btf_record->timer_off. > > > > > > I don't follow. Please elaborate with a patch. > > > The var_off and off is a part of the bug, but it's not the biggest part of it. > > > > Not compile tested. Compiles just fine :) > > I see. All makes sense to me. > > Benjamin, > pls incorporate it in your set. > OK, done! I just had to revert to the following or KF_ARG_TIMER_ID was not recognized by the verifier: --- diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 7ee20e9d14bd..a5e147468ac8 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -10848,7 +10848,7 @@ BTF_ID(struct, bpf_list_head) BTF_ID(struct, bpf_list_node) BTF_ID(struct, bpf_rb_root) BTF_ID(struct, bpf_rb_node) -BTF_ID(struct, bpf_timer) +BTF_ID(struct, bpf_timer_kern) static bool __is_kfunc_ptr_arg_type(const struct btf *btf, const struct btf_param *arg, int type) --- Cheers, Benjamin