Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp562635lqp; Thu, 21 Mar 2024 08:59:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUVND+NNlRmCY6GuYSNW+yAmPIhZff9NIAQxvPW4+HS1lFR7OV9Laykie5qiIE67H49teBHv/dyc9dxdr9mqUuFjwa4UDbhjWK/+KfbKg== X-Google-Smtp-Source: AGHT+IFAaOV+h2Um+LQxDdmLrzqv49KxReU621oW0Jk6xaJj0ZTLzMK1l6xZmy7c8cNVUkQC8Hep X-Received: by 2002:a05:6359:6412:b0:17e:b933:84d with SMTP id sh18-20020a056359641200b0017eb933084dmr16092830rwb.13.1711036741692; Thu, 21 Mar 2024 08:59:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711036741; cv=pass; d=google.com; s=arc-20160816; b=IZD6fhc25xlZNNHsSAoiXJmeEhPxu4LfSouPyLtQ9bzoO5aHuqhhP2N6LVFUF5xG0P 2DXeAP75NdqQwvOWloNnbJKTMEufSnAe5B+mULLg9uOpNsDVcYJX0mUG+vBqgpnCg2LS fTYsK5yvsf4huonj6yhW6o1Yo6yLDaiDFA+HuSddt3MlKMhk0t26r5q6KJnSImgoBnXQ Q0+RVvvqPhK9ACpOhzj0kvaMFDZ6LBNbHgbJCIa8DyzNpFRdxuerAikYjUZ+mNEeqoEQ rdd6bDTcWfzdkRC8i4cg30AbeSzqq8RFUjLziPm4ZMo3VZM8TFvbCgZogWjc41hk3z/X OIHg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=F/BIMjBq7uK/tVcgzATJ/EBrygqAy5kphRG6l+IH21c=; fh=gISK+n6esTF0tfmQhxJ+WpAS3Z7L3JasEbYL5JuYVLE=; b=f5K86ui21A7HsklXwAsoRZlhBOLMmKimGC0Dayhdji34qRbVgL1QYBt4PlGCUeD4Bt E5Az7kRIKhNM0N8gIbetyety9V1nz0BmCkzG5xbw8ijKoVdkqfBaGM0FfqpEU6BEstb4 YgQF2gYzD6zKbSdTXZ4ey8e41WPf5TAB3meYX9dzVf7s8PSB6LdE+uu7IEeXNWJrPLYh YKxM1N/vE/lPTUtUuBG634fGNdJ9uCtv2H+SHUyOs9nPQqP48ctqizbjt0YTMBJ8KkOO j4K5TqYj3Sljqdcav0OPanX6Xq/hquPpKpwb91x90S7QJsPRchAGPny7IUEKakoxWk8/ CTGw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aSgdNimu; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-110291-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110291-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q33-20020a635c21000000b005dc905460d2si41756pgb.233.2024.03.21.08.59.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 08:59:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110291-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=@redhat.com header.s=mimecast20190719 header.b=aSgdNimu; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-110291-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110291-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 21F3A284803 for ; Thu, 21 Mar 2024 15:59:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5B7F012BF20; Thu, 21 Mar 2024 15:58:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="aSgdNimu" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 00DA412BF1A for ; Thu, 21 Mar 2024 15:58:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711036736; cv=none; b=Mj2gyYIw4z2XSLTK3TT+HnPPeHEOvZHGW7t5pLU5jWo/zJ1ScvXq9b+R4caLyLbPb1zvmzO6GoCkK2nc81/kiEkM1VM0aP1dZmgm9xCrDKYqgh3TCBSoCDXTdFO9/FzYSkJOaddJcXHIOojN4LtViYapBoBjuvxTm81cVOgWs9M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711036736; c=relaxed/simple; bh=Iad1tyKhiFMIDC8Xt0/zXsbE/rY3pkbp2kXvv1eL2yo=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=W3orK0LohBRZm6mLlBEcrW6UptJ/YmHBzhp4qi7PXmI9eZtLj7PYrJS6wu9TTpj5zaHBzeRDW7B0nQWypJatb0TCtHn+ZRbsdaZhhX5rVrKwA8pnvqVldJyY9K/5eTIbGnEsosy5xW7YA1lcLOCxyug1Nwb3ZJqlekLAf7pyku8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=aSgdNimu; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711036732; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=F/BIMjBq7uK/tVcgzATJ/EBrygqAy5kphRG6l+IH21c=; b=aSgdNimuDtp43Ddp3j/PBEGyXJj4aXlnffoi9EIImL3UpJzYbxrkqhW8mribUW8lI/pikN agIq1t6FDsn+rQsLMHuISuUrJsEl9su56qNQhWkeV9zMaAtmA3PFvIHfUerTgjc1go8BXU N1Nk16qCY0kd7UCkEeuR6mpfV5tqcQw= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-256-T1lVxz7_NQ2k-tjWTXe59g-1; Thu, 21 Mar 2024 11:58:51 -0400 X-MC-Unique: T1lVxz7_NQ2k-tjWTXe59g-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a46f6c1104eso131899466b.1 for ; Thu, 21 Mar 2024 08:58:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711036730; x=1711641530; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=F/BIMjBq7uK/tVcgzATJ/EBrygqAy5kphRG6l+IH21c=; b=lE8rSXombqiq/9NSuuZBxmYrqXXGKaxqYL5V4T04cjLfaFyuWKCukG7fbJLNV7A4UK y8cZ8P+ONrkufSny0pFPrz633POSacEIjcUneokwhDDFyLWF0pLG+OioFrOhZE2YY956 ULgPxuJLjH2VThd3E3Xf+B9lNQFLYuyDq2wyhRugzcFwm6c2qwE8fQaYi7lLwoXeAA1l GE332OCPhPjmsZo3CsEXmetv+uGrebD00o+ELMnpVR4TuADMcirhNMJccsHoronNf6k/ MvYHYYfrp8swmzFAt8mINOU8rKu/OIoMpcLxm3+YoMYl3nTzhjKfThLCgVHsldpir/gl d0/g== X-Forwarded-Encrypted: i=1; AJvYcCXQZI/cHd5fshjk4XNFDeqNYOcJIUcdSAb4R/zeAFZGnhtO5qUTLZbuZ8OeLtWnFPgdBvqOp27d6lWJaSxDfL/Jn4bCfpCc2oa+0z5q X-Gm-Message-State: AOJu0Yyz/+XOPIGnU1v3T299XDXvxwIpXDuidGl1ONh6O8bIai9WYpeL QvNWA82EiceH+OeQgWC95hJQzWD8rqV05R+VZ45EszoScGxtD4BBJU+uccauevn/NND8TtxxbKD XKhkc9s8EoTEYivgTErPqfr2yR1e4I3TVUhfYcKavm3ONe6WabLHNYOhlcCpZh1L//KJvpPX0SA Pt7TFaYLfsii0DlNkACehKAahy7ojTONorVu4P X-Received: by 2002:a17:906:c149:b0:a45:bde1:a334 with SMTP id dp9-20020a170906c14900b00a45bde1a334mr3108498ejc.27.1711036730304; Thu, 21 Mar 2024 08:58:50 -0700 (PDT) X-Received: by 2002:a17:906:c149:b0:a45:bde1:a334 with SMTP id dp9-20020a170906c14900b00a45bde1a334mr3108485ejc.27.1711036730019; Thu, 21 Mar 2024 08:58:50 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240315-hid-bpf-sleepable-v4-0-5658f2540564@kernel.org> <20240315-hid-bpf-sleepable-v4-2-5658f2540564@kernel.org> <88fde9a0bb55c74fe34667e891572d8af9eec21d.camel@gmail.com> In-Reply-To: <88fde9a0bb55c74fe34667e891572d8af9eec21d.camel@gmail.com> From: Benjamin Tissoires Date: Thu, 21 Mar 2024 16:58:38 +0100 Message-ID: Subject: Re: [PATCH bpf-next v4 2/6] bpf/verifier: add bpf_timer as a kfunc capable type To: Eduard Zingerman Cc: Benjamin Tissoires , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Mar 18, 2024 at 10:59=E2=80=AFPM Eduard Zingerman wrote: > > On Fri, 2024-03-15 at 15:29 +0100, Benjamin Tissoires wrote: > [...] > > > @@ -12021,6 +12034,12 @@ static int check_kfunc_args(struct bpf_verifie= r_env *env, struct bpf_kfunc_call_ > > if (ret) > > return ret; > > break; > > + case KF_ARG_PTR_TO_TIMER: > > + if (reg->type !=3D PTR_TO_MAP_VALUE) { > > + verbose(env, "arg#%d doesn't point to a m= ap value\n", i); > > + return -EINVAL; > > + } > > + break; > > I think that pointer offset has to be checked as well, > otherwise the following program verifies w/o error: I initially thought it would be harder than it actually was. Fixed (with the new test below) in v5. Cheers, Benjamin > > --- 8< ---------------------------- > > #include > #include > #include > #include > #include "bpf_tcp_helpers.h" > > extern int bpf_timer_set_sleepable_cb_impl(struct bpf_timer *timer, > int (callback_fn)(void *map, int *key, struct bpf_timer *= timer), void *aux__ign) __ksym; > > #define bpf_timer_set_sleepable_cb(timer, cb) \ > bpf_timer_set_sleepable_cb_impl(timer, cb, NULL) > > struct elem { > struct bpf_timer t; > }; > > struct { > __uint(type, BPF_MAP_TYPE_ARRAY); > __uint(max_entries, 2); > __type(key, int); > __type(value, struct elem); > } array SEC(".maps"); > > static int cb_sleepable(void *map, int *key, struct bpf_timer *timer) > { > return 0; > } > > SEC("fentry/bpf_fentry_test5") > int BPF_PROG2(test_sleepable, int, a) > { > struct bpf_timer *arr_timer; > int array_key =3D 1; > > arr_timer =3D bpf_map_lookup_elem(&array, &array_key); > if (!arr_timer) > return 0; > bpf_timer_init(arr_timer, &array, CLOCK_MONOTONIC); > bpf_timer_set_sleepable_cb((void *)arr_timer + 1, // <-- note inc= orrect offset > cb_sleepable); > bpf_timer_start(arr_timer, 0, 0); > return 0; > } > > char _license[] SEC("license") =3D "GPL"; > > ---------------------------- >8 --- >