Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp512632lqt; Mon, 18 Mar 2024 14:54:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWRJiKJvuKYD3/kOP6qDP3/R1ny9oKGWNi95MnxDZ/tZOGBZLALE8+WIRltpRAPJW7NpfGA+KLrtxJxshFK3IQEzJwTV5BaKYKNFu/zYQ== X-Google-Smtp-Source: AGHT+IH7ZoUnpMCo5PkJ8MdooGxJhpzxzPi6MB/TIozNrutaVEY/Y2r3+WQbY4aZFaq6NFT1dePa X-Received: by 2002:a05:6a00:1401:b0:6e6:ac71:8b38 with SMTP id l1-20020a056a00140100b006e6ac718b38mr14844528pfu.22.1710798840936; Mon, 18 Mar 2024 14:54:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710798840; cv=pass; d=google.com; s=arc-20160816; b=fHFWvgyr4Lyv6/utaqkc2DECgrhglghTu5ZWuec9UPSKAKcvG01XhdYWcbnDC5s5iN AWfMcAnvw/wKWxXMiF3cIS+wP5s9cDyot6cjxORSN+NgOHv3d/0TRydIRgvHGWJejPh5 jqqtUVdUYqklc/3FnT1e7IEWusY0mJL7WuaWhTe6UTcdVsupiE4GNN+Fh5MyjlSXigpx lqNJhtYMzkKlXERGKs6eByAig6pE6Qf2eEZg596seeHWZEtBY7HHXhskC3ijiTieN5qe eIId6Ro1ZHd+nxLhyotlXZ5QQtgv3bUOmiMAuGpO6LD/6ZqMgcaUXJ506uVh/QvFgcXh 0znw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:autocrypt:references :in-reply-to:date:cc:to:from:subject:message-id:dkim-signature; bh=NnQYQBcAPykINWSewEXD0u4daVYuhsM4radIRFdbYFs=; fh=g+KwjFLle8oNwZ9jKW5m5fECw8oL6IJevXQyRQaK9PE=; b=iWPpTVuKNXB+RNotbzFomQkm3NkssTDC/ua10GEIDpyiKcZNAmPBjFCe9AAitLMKES FsAHCRlMHwngqUy2wqEYbbzC5IQArHlv5BBN6nIc1ZiHH9+R5vh0e8TVGleDU6r+1Ghp aO3b0Ro/AwuPzKw0nF8Cum8lW7wV4GA9uTVi8mOfj2YZq1JuSMB7jZOIb4VDbzjjLZ2/ aHNOTCZ9Tfbg+Df3L97hXzZb45xfFRdx2HCeYqpos7eeNKCnwtHfS/hMwvxJMOo9jYk/ 281/KfQ5hVXDsVLAGX+HVxAmvAB3xw7KRGbA4Ia16xa0z2NT/SEGBt92851hQejJt78w fZeg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=NE3VREp5; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-106725-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106725-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id it5-20020a056a00458500b006e6be504abcsi9817960pfb.90.2024.03.18.14.54.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 14:54:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-106725-linux.lists.archive=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=@gmail.com header.s=20230601 header.b=NE3VREp5; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-106725-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106725-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 57DEFB215D9 for ; Mon, 18 Mar 2024 21:53:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AC31859B64; Mon, 18 Mar 2024 21:53:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NE3VREp5" Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1994659B53; Mon, 18 Mar 2024 21:53:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710798824; cv=none; b=cAxLZ4EbDDA6/94DnhGCa2doxfDJVnxHya8G0LnmW067Wr5GdiHXc45soBUgdmExtJxDb15uCWyzzSIn7GunG9kmK0zh5EIKNmGn+HvicOVELBaOOHxDzuDVg4lnIp/6UstI9ucBiUGGdK2oVlaFZYBjn6kZgYVQF21e4fo7HnU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710798824; c=relaxed/simple; bh=TMVNZBnuky+xlmSCjV7x5xWLbLKK7AsrIZ3eQuj1Enw=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=XgRc8dK3XCYtbf1ywrTw1uwjUZJZ4HzlWmt10VhfcIsjdBR31NoKHNz1hOWItZWSi5EzIlma9VN7GhVuYAG6Ma/SOd0egHy18t/AjHpHonrxV8FdICkXDEIucUJ2F+f98XmtIwGOiLQnf3y8qi58IqzCaXDQpoZ5yV15w97mvBQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NE3VREp5; arc=none smtp.client-ip=209.85.218.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a46d9fbb5a5so19022666b.2; Mon, 18 Mar 2024 14:53:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710798821; x=1711403621; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:autocrypt :references:in-reply-to:date:cc:to:from:subject:message-id:from:to :cc:subject:date:message-id:reply-to; bh=NnQYQBcAPykINWSewEXD0u4daVYuhsM4radIRFdbYFs=; b=NE3VREp5sFde6bCi6ihQ4EaSsMb3UxSib5eJNwzdE3yqGBcZubcMNtZLp0M+w8YwrX wHYGSP2Cuh9xTX2Cosv9AqEAO9G4/vGEEi8sW27FG62WlgUOCchm8I5c28uHXaKK8gs5 TpSupcdZChjyHKkQGHERfMo2YDl048RlB7ZDXGJ2ErADNhd1GLdJ8TEZcZ5PjA0W8onB m1JE6rNhN13+PJ2jBcH/z4pd+v9QfRpDL1/4zAym3Dq2ougoqH3gT7jwDA5H3CNvS3ml I0yOB5PuhZUnBzMlNtDZ9cqH1kxriVBUX4xbeaanY+/lT1TqhR9O0tISWbJ7JrKTAIC6 8ONA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710798821; x=1711403621; h=mime-version:user-agent:content-transfer-encoding:autocrypt :references:in-reply-to:date:cc:to:from:subject:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NnQYQBcAPykINWSewEXD0u4daVYuhsM4radIRFdbYFs=; b=h9mBb0ZcyPZARwiV7aMAvnkA5MAaypgxV3ohKS+Zc8/1YMYCDLv/sF/XnOlbJ/x+n3 KuGfuXXhOEDEnTZBuSupjj4dLNNYiVrSGxwpgVfrQU3YzcgOPGzI+JhcwXSZzf1+S1tp mDOnjqaFtxw9XoRjAKVYdcQPNfMX0ErpxuAuBUvaFDheHVrBYgLPEguYGenKa3Bw4EDW SsaHI1pl8iWVKy2znRBW9aYjBCE3IMOdC3eD0rkHEF4l8QRCLGesIbQb3wb2e+KhhI1A dflFxANTdlxLRCSG5M/UwwqrtTeORfj4TCtiHHNkPkJLyeAqumW914K7UXrYHxQReIvs oiMA== X-Forwarded-Encrypted: i=1; AJvYcCX7VGf2NCP5nzB8DAbtsKHSna2asFEZxZ6fQvl7RbuQ2rpqMS7DRZSil1edHFpQZWLDdrfjyloPRSeMHBJKC6OY/Jm0JjseRUAS8PnnSna4jkEwp1r8inMavSNczVV85P9IMTJhwWLu7rEgUPLM X-Gm-Message-State: AOJu0YzGEFFKruzlxQ+OhJgg6vNlLaLvLS5bpaoyzn2Rw4b1v5UQBnAf LEtDqon58u1FqMVwvC6BOSPaG07h7fz47vYvik4yaNuLAUtfLkmh X-Received: by 2002:a17:906:6957:b0:a46:cee9:e412 with SMTP id c23-20020a170906695700b00a46cee9e412mr359010ejs.15.1710798821193; Mon, 18 Mar 2024 14:53:41 -0700 (PDT) Received: from [192.168.6.255] ([5.1.5.0]) by smtp.gmail.com with ESMTPSA id hz13-20020a1709072ced00b00a46a9cdcfa5sm2969787ejc.162.2024.03.18.14.53.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 14:53:40 -0700 (PDT) Message-ID: <88fde9a0bb55c74fe34667e891572d8af9eec21d.camel@gmail.com> Subject: Re: [PATCH bpf-next v4 2/6] bpf/verifier: add bpf_timer as a kfunc capable type From: Eduard Zingerman To: 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 Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Date: Mon, 18 Mar 2024 23:53:39 +0200 In-Reply-To: <20240315-hid-bpf-sleepable-v4-2-5658f2540564@kernel.org> References: <20240315-hid-bpf-sleepable-v4-0-5658f2540564@kernel.org> <20240315-hid-bpf-sleepable-v4-2-5658f2540564@kernel.org> Autocrypt: addr=eddyz87@gmail.com; prefer-encrypt=mutual; keydata=mQGNBGKNNQEBDACwcUNXZOGTzn4rr7Sd18SA5Wv0Wna/ONE0ZwZEx+sIjyGrPOIhR14/DsOr3ZJer9UJ/WAJwbxOBj6E5Y2iF7grehljNbLr/jMjzPJ+hJpfOEAb5xjCB8xIqDoric1WRcCaRB+tDSk7jcsIIiMish0diTK3qTdu4MB6i/sh4aeFs2nifkNi3LdBuk8Xnk+RJHRoKFJ+C+EoSmQPuDQIRaF9N2m4yO0eG36N8jLwvUXnZzGvHkphoQ9ztbRJp58oh6xT7uH62m98OHbsVgzYKvHyBu/IU2ku5kVG9pLrFp25xfD4YdlMMkJH6l+jk+cpY0cvMTS1b6/g+1fyPM+uzD8Wy+9LtZ4PHwLZX+t4ONb/48i5AKq/jSsb5HWdciLuKEwlMyFAihZamZpEj+9n91NLPX4n7XeThXHaEvaeVVl4hfW/1Qsao7l1YjU/NCHuLaDeH4U1P59bagjwo9d1n5/PESeuD4QJFNqW+zkmE4tmyTZ6bPV6T5xdDRHeiITGc00AEQEAAbQkRWR1YXJkIFppbmdlcm1hbiA8ZWRkeXo4N0BnbW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1e767y5ErFKyXAYRweE9zarEgpNZTuSIGNNAqK+SiLLXt51G7P30TVavIeB6s2lCt1QKt62ccLqUAEQEAAYkBvAQYAQoAJhYhBMfui64wKUMqp1wmBC4MZXpJYEQJBQJijTUBAhsMBQkDwmcAAAoJEC4MZXpJYEQJkRAMAKNvWVwtXm/WxWoiLnXyF2WGXKoDe5+itTLvBmKcV/b1OKZF1s90V7WfSBz712eFAynEzyeezPbwU8QBiTpZcHXwQni3IYKvsh7s t1iq+gsfnXbPz5AnS598ScZI1oP7OrPSFJkt/z4acEbOQDQs8aUqrd46PV jsdqGvKnXZxzylux29UTNby4jTlz9pNJM+wPrDRmGfchLDUmf6CffaUYCbu4FiId+9+dcTCDvxbABRy1C3OJ8QY7cxfJ+pEZW18fRJ0XCl/fiV/ecAOfB3HsqgTzAn555h0rkFgay0hAvMU/mAW/CFNSIxV397zm749ZNLA0L2dMy1AKuOqH+/B+/ImBfJMDjmdyJQ8WU/OFRuGLdqOd2oZrA1iuPIa+yUYyZkaZfz/emQwpIL1+Q4p1R/OplA4yc301AqruXXUcVDbEB+joHW3hy5FwK5t5OwTKatrSJBkydSF9zdXy98fYzGniRyRA65P0Ix/8J3BYB4edY2/w0Ip/mdYsYQljBY0A== Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.50.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Fri, 2024-03-15 at 15:29 +0100, Benjamin Tissoires wrote: [...] > @@ -12021,6 +12034,12 @@ static int check_kfunc_args(struct bpf_verifier_= 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 map 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: --- 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 *au= x__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 incorrect of= fset cb_sleepable); bpf_timer_start(arr_timer, 0, 0); return 0; } char _license[] SEC("license") =3D "GPL"; ---------------------------- >8 ---