Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2046024rbb; Tue, 27 Feb 2024 09:01:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUdKlKQNvhD5hswO1QUjIrIIw2TBxc2j1Mx6Fcvs3zNu3dq3k1Fg/aFI8g/t4vw50dmilPO7AZzROlrtWAn+RnyKabG0SFsYLoppdemQQ== X-Google-Smtp-Source: AGHT+IGeU/LJ74cCl974G9Rvvleyn7ReADsw8nqDO+82oiMCDzfyTBe3t15O/lj3fY2p6R5AKtJS X-Received: by 2002:aa7:868d:0:b0:6de:1b57:ca8c with SMTP id d13-20020aa7868d000000b006de1b57ca8cmr10429371pfo.23.1709053291022; Tue, 27 Feb 2024 09:01:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709053291; cv=pass; d=google.com; s=arc-20160816; b=GAMQ/1Tuo/DW36sHNMN10xu0z+Oyg6yW/OLpnLandTTfqKJOf9fc3MUOcqNKVLsGBo FfUgs0BhB7uCvilsoeU8Q5GXuOvZvr9nGtyYQkCeZaQ6CpCBIWcY+vXDIYt27TG9TuDW ySD5IuTHRXcfDJhGBCK0AAy3wQTiK4pS8QIrBRwq6c5uX8tV2r5yjkY8WM0m1Plhd31V ZaGXQXc9bYTDj9JAbbhN/ZdKhuBqO69Fmin2ebA+KenTSWMqeoA6YsYghm3eG3fKGByn 422VnlMmGEiutdI50HPwAudmDnu/2YRAglU5rPmwIhQrbL9ZQmwMuRX9oTrpEupLdTr6 pnSg== 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=XTzJpS7X9XEoV4xvNdFIuJu4pysu7KWGugmJiXpsQsY=; fh=pg2EG6vprcybZ7VsWd+9p7DOfDdIZ4+edadCEkbwVLA=; b=TEaXkk3D5lAwdY0rof8UXeUeQxzZTQMi3xkrzEmQwpQnbOoSs83SMna9XQKw+43mYa KAm+vcjQg2eMJIFTuzylGiJmDbgWGuUXtqHMgaMg1raNiCHKVF5rKc6vrf2FlC/bA970 ymYb89Fca5cmqV7n+5BY3+1RtICg+sL9pZC9uty9DAFw68Hy2eiys7jY9EziG3bf7Df5 uHPSd318poNB7zXs+FH2f0Z0EKmTYlA132dFtGUic/WNIjgKs6e7lM6uM/EyWvdqqZJg Cf1fdEYrbPwKXrMCj1+ickboiA/sBqzzo9XyTK9wNdnERNCrkIJxfnDtPkwPLPtU7OkI /EGg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=C56muvyF; 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-83616-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83616-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. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id y13-20020a63ce0d000000b005cfc084b80esi5738055pgf.221.2024.02.27.09.01.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 09:01:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-83616-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=C56muvyF; 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-83616-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83616-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 50FC4B308F5 for ; Tue, 27 Feb 2024 16:37:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5F4B72110E; Tue, 27 Feb 2024 16:36:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="C56muvyF" Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (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 BA2AA200D5; Tue, 27 Feb 2024 16:36:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709051803; cv=none; b=IP/Riqy29R0vHvSuLUw2TTSOsNFfcSilGcaGlBRU0OZl7VWC0iw9jUzMfYbQvIao6x9opTdytFfk8lJwhokyAkCqshg/GuLPwHkifJjGC8epayyQ68cyXu3zKZtZN595eYkdqsYpPyGKzhapiIAQpglm4pnBniLZKH+PED9hXxY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709051803; c=relaxed/simple; bh=hXwL4660+XM+wMrQMkOFCB0IGRMCfdbE0pfYHgN8LDY=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=k3eyq5Z5hX0wkoGBj1Wilu1aPIgFNyOCtWHI0eGaz+JV9GV40FF3P2KwfBzBsPI8Xx5wtZ9MLs55GcQTra1JWL5cQZSCjzvboOHpHong50A4kytoJ81gP3aohsnX2b3bV6pw3vkEPS5gAjM/eNc2cVKw+3Z1/R0hqLkDN3KfcMU= 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=C56muvyF; arc=none smtp.client-ip=209.85.218.46 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-f46.google.com with SMTP id a640c23a62f3a-a3d5e77cfbeso807728066b.0; Tue, 27 Feb 2024 08:36:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709051800; x=1709656600; 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=XTzJpS7X9XEoV4xvNdFIuJu4pysu7KWGugmJiXpsQsY=; b=C56muvyFgnDMKaVPLpn71owu0IHf0H6YI75i1YxDE850MmWoIyeclDs9DDGap/r2yJ jkbv9SiBsVwkstzxyyK48Ofg7uz3lAunM0ICKxHEgP3HX55zW/ibBGv5dB7rbqiRn17W s6njdZ7xbDVX4OatctqKbdeSQPEcq7PO6DS/qlbWinGeayOr6sRyoUxhx4rJm+HNfb1d jOgL7CapHtXyS5/5IEACNvJXrQepGrT9tgDWOK5bcWNA1LdqExSnUrJXkifTmqxihyFZ 0/yCaPC/DXHCho0zJB3QQXuRIHlBE+xcmMzkYTw7suEER/zf6cD9AzLPNKTinyuDtPgu 0n2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709051800; x=1709656600; 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=XTzJpS7X9XEoV4xvNdFIuJu4pysu7KWGugmJiXpsQsY=; b=PKyeHu3KLGgl1QNpJlq3blB4jSf41d+SPlvvhfJdIhSnaOAU2RGX/NgCekHukvCa8K A72VzYx8Pr8UOaqaxzeWn3NGNq3PaXFRxp07vVV4+9j98xLg8TEpH5CwSHWwoUSIl3+z YfpWH52Pocj5gdfjfQ5oSySkOWEnH8U9KT26LnOPLOmU3ZJ5hRM9N99vXXm/JjMOi+ve 9VhyRcCRHpkuqfg18NQUivsQ6mVvvsId3/k3so+c5d+BmAvZaJ4lmA8AiqbPvwCo0GDA jinc4K9oxgmhkIjUmlQ7BvaxcJd2rUgrJraGcztchn2uTE3QxYv0DX/1h/xdVmx4JPob Khww== X-Forwarded-Encrypted: i=1; AJvYcCV+DgtwTyDTkaMDcwjl/8omOX2C4HoVfAUqB2451PbezjQYKdzyMvukmTN2oL1skCKhyrh5IlZpF7ihwaBYFPe+Y1J/2b9zK0HS3QDyqIWOvi/WqMrHTacqMdoIwY2v+tA5f8LzIcxSiLu6tR6MART4cGFbDdRlSi1JH4ROXzNT+cVtrfmxM3Hnm8/qLPfiLuMWV8LuN0f/c5CmJUm+ytNuv0VD3/Cwanc2g527HmAHGbumm5pVR3xT+XY= X-Gm-Message-State: AOJu0YwEMwTvy5VXBjUIi8tH92EeFePHdWm6hMZMxHyHyWyO5SawfhNM VamgJ79OBgRGBwCb00HFqdK9pWAY1KKxUUkHCQob6JrkmmK6V5PZ X-Received: by 2002:a17:906:408d:b0:a3c:5e17:1635 with SMTP id u13-20020a170906408d00b00a3c5e171635mr9143240ejj.30.1709051799951; Tue, 27 Feb 2024 08:36:39 -0800 (PST) Received: from [192.168.1.94] (host-176-36-0-241.b024.la.net.ua. [176.36.0.241]) by smtp.gmail.com with ESMTPSA id lh11-20020a170906f8cb00b00a3fb62260e3sm919913ejb.72.2024.02.27.08.36.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 08:36:39 -0800 (PST) Message-ID: <9a35a53a1887fb664fd540ec7e272cb3ea63f799.camel@gmail.com> Subject: Re: [PATCH RFC bpf-next v3 08/16] bpf/verifier: do_misc_fixups for is_bpf_timer_set_sleepable_cb_kfunc From: Eduard Zingerman To: Benjamin Tissoires Cc: Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Jiri Kosina , Benjamin Tissoires , Jonathan Corbet , Shuah Khan , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org Date: Tue, 27 Feb 2024 18:36:37 +0200 In-Reply-To: References: <20240221-hid-bpf-sleepable-v3-0-1fb378ca6301@kernel.org> <20240221-hid-bpf-sleepable-v3-8-1fb378ca6301@kernel.org> <55177311ccdc24a74811d4a291ee1880044a5227.camel@gmail.com> 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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ttDtiZ0+IH4DZcvyKPUcK3tOj4u8GvO3RnOrglERzNCM/WhVdG1+vgU9fXO83TB/PcfAsvxYSie7u792s/I+yA4XKKh82PSTvTzg2/4vEDGpI9yubkfXRkQN28w+HKF5qoRB8/L1ZW/brlXkNzA6SveJhCnH7aOF0Yezl6TfX27w1CW5Xmvfi7X33V/SPvo0tY1THrO1c+bOjt5F+2/K3tvejmXMS/I6URwa8n1e767y5ErFKyXAYRweE9zarEgpNZTuSIGNNAqK+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 Tue, 2024-02-27 at 17:18 +0100, Benjamin Tissoires wrote: [...] > Hmm, I must still be missing a piece of the puzzle: > if I declare bpf_timer_set_sleepable_cb() to take a third "aux" > argument, given that it is declared as kfunc, I also must declare it in > my bpf program, or I get the following: >=20 > # libbpf: extern (func ksym) 'bpf_timer_set_sleepable_cb': func_proto [26= 4] incompatible with vmlinux [18151] >=20 > And if I declare it, then I don't know what to pass, given that this is > purely added by the verifier: >=20 > 43: (85) call bpf_timer_set_sleepable_cb#18152 > arg#2 pointer type STRUCT bpf_prog_aux must point to scalar, or struct wi= th scalar Right, something has to be done about number of arguments and we don't have a convenient mechanism for this afaik. The simplest way would be to have two kfuncs: - one with 2 arguments, used form bpf program; - another with 3 arguments, used at runtime; - replace former by latter during rewrite. > Maybe I should teach the verifier that this kfunc only takes 2 > arguments, and the third one is virtual, but that also means that when > the kfunc definitions are to be included in vmlinux.h, they would also > have this special case. It might be a somewhat generic mechanism, e.g. btf_decl_tag("hidden") for kfunc parameter. imho, having two kfuncs is less hacky. > (I just tried with a blank u64 instead of the struct bpf_prog_aux*, but > it crashes with KASAN complaining). For my understanding: - you added a 3rd param (void *) to kfunc; - passed it as zero in BPF program; - applied the above rewrite, so that r3 equals to prog->aux; - and now KASAN complains, right? Could you please provide more details on what exactly it complains about?