Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2117983rdb; Tue, 20 Feb 2024 18:59:17 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVv7VPnpE+o0rqSZC3GQMtWpf7MOzgpviCtcgVdSRNfwUhEPF+HO0YKj534IcW7Ml8TZC3jT1M/uOxJUqZIgMYQh7abIYSZiOA+aQy9sg== X-Google-Smtp-Source: AGHT+IGLjurwSJKQRXB4Atc+UhyrK+lkaKtDVd5glYyXMxkBpUOAwYwYIg6UxovjjRgReqYjPOhu X-Received: by 2002:a05:620a:2953:b0:787:73a6:bc8f with SMTP id n19-20020a05620a295300b0078773a6bc8fmr5804830qkp.78.1708484357471; Tue, 20 Feb 2024 18:59:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708484357; cv=pass; d=google.com; s=arc-20160816; b=zR48bLd3eD/0eregXMHfrJHv3hc4dy4oij961kYJgKYY+ZmKgtWGXIwUivOslhLK0u cHjqwcwNBSUK5IU79EITTQU7kVrYo49Aov+lPZatqUy1z659p/hZNst65PVyOc1qzOvW SjmZMWd+zdPv/VCGn2kOMLZZrel8Oy2v0pNkV343tqf8ZNEcvUlbWGfaPD2i8eYuSNwD g5lTnCUMSsxzUttFVCUSq2LQ1nShtCaZsErm6dQKf+DGB/i5AkTwsHZBBHY2pg35BGG0 LhKX8g16ZI3THcKUVIKqxnnSjKGiKecsVnPJ8WF2f5vCqWhS6PydUzNfaGtY5UG8/+eJ bLGw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=rKRR1jeoUaWk2hMXPXX2OybDUOW0Xq12PBDdL5AGBKI=; fh=58aqgUN7qd0jwxOorWT2B9fyGyfuwxMwy0CrsTpRfqA=; b=nKVQF6AvFdlimFnqA0tZfDQPvee1Al1Sg7jAPwsowEQS48/4wGhB7VHwCDW3MusaY2 PbEsMtlud+OwXmeRkBoUNEjYRs/0LeqpC4Fm5qjAzmle6DAOpE/DRD4G3k1IE06lDtqK AoYJMwJTsQH0wGs7qIux4Q+ub1tWUOV8lOQxOnaSeuT40cU1h1f0Dbkb9BymhszpxUM7 yaXNsZxuqmCAyBsMPWULWo5WRS3THDPTSDxrTMcZPCQAerUZG4iV7+UnjJlfcsfioRcr 0nAg6WaXYP/ETpXe/aaoQ0fQ1AGeC4B6sx1lLc8Q2qe23o8Zikuv7Ae7msHXFzXlfTSN OCVw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bwNL6Y+8; 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-73984-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73984-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id cz5-20020a05620a36c500b007877cc42788si2110620qkb.3.2024.02.20.18.59.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 18:59:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-73984-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bwNL6Y+8; 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-73984-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73984-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 3DE9A1C2300B for ; Wed, 21 Feb 2024 02:59:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CB08F2E3FE; Wed, 21 Feb 2024 02:59:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bwNL6Y+8" Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (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 88C012837E; Wed, 21 Feb 2024 02:59:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708484349; cv=none; b=csqehXsatSuD0j2F3LVg2lYeHEqEApyrtOzTBR7ww+7yFezT837+HJ/JbMvzXXFq64UMhCVHfLLI5MXWWmPSn883qbrm3BonKbe05NW4+iWT5blv6fmpGa+xieNhzBFCwQpPr81q65/v5AsmXqzehfqw28gEow+YkGcW0PKbB1M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708484349; c=relaxed/simple; bh=ki7oZqPLTBBU4e9QixFjvu/JrFVfmPfGr4kBpBiuZ54=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=cE1uA2XgQhG14HJF/JTVK/VRFavCWFztbi4Vl4IG/fHu3F6nO1Ds9k9U5yFaMyG9Lle5JofLdcIGuXhqk3wGyz7xiKfznZRAtozsNJ+dffSxMzHI6U2OcqDmSdtCEETnOmEsq3ToKC0OiuH0ucIritRuoMLvjw8uJC4JpJbu1Hs= 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=bwNL6Y+8; arc=none smtp.client-ip=209.85.216.45 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-pj1-f45.google.com with SMTP id 98e67ed59e1d1-2997a9f4d61so2305000a91.3; Tue, 20 Feb 2024 18:59:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708484347; x=1709089147; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=rKRR1jeoUaWk2hMXPXX2OybDUOW0Xq12PBDdL5AGBKI=; b=bwNL6Y+8qjOyLB+DqaMtGAIpKquvsbtfWnghCa6NymM2uah81RKAr/8xuC4parLLPc Cm8YPHq1zyuh7+ZJroPhh6el0CLRKP4NUiQKzzBlZ7JpIpX1PfAZ3Xyd1IUjSoBhquzV UfybgqXVpHuXoaNS1t/vRo7vpqsZlTun8xBRgTLY01/AJwN/HEdrJemxQIa2hOMZlncf 6VXU90H+nFnn6ofjpTCO0J44t0Mdy/W6MJ3qehbVlZyVa0rCIQ1rG39wKD0IiPSV767+ Fn3Y/4MTLWYf3N9DYj816Al3JsEm3wBXW71kXD5L8Z8Y0RdILHggboYnAWHRaGrbRKXZ kw/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708484347; x=1709089147; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=rKRR1jeoUaWk2hMXPXX2OybDUOW0Xq12PBDdL5AGBKI=; b=CLuYWYOsie0mHLVToPocc2T7wmviNWS+cTluQ5Iy2Iie5IeqTmMl8o+ktMlEu/NBQ/ 5bnHwnFHYl4VTF4jOvOSwm8bHF57zkiG5HC6fMxhgo7zHfvmLKVCKfEPj0FuX9Ty5Szg Eastous87nAwD5rZfgKyrtVBOeRTJJQzPu5VIlaKMxumxW6IOdxMYElcU3drUkCqKzob KAyNJm9CRaa75ggJL+wKJ+WZAFvsCOmT2HlWlLfFhH4jrZkuISlMwdT15PA2VGwtCzia F6vJSyGKUPEx0Owil2JzwZzHtG41h6yvXKwL53qh+srJgW1k7ODnc/yvNcfxPllp7I57 oZvg== X-Forwarded-Encrypted: i=1; AJvYcCU4JazQ+Z2Xy1tyQUI3qAtv9+/QJcktpGCOu51WQ3Vi1bp1MGJq1nLCCYrX8xs3iCnFW0xOrHCdyEwIcGkI9T/kALbpq0oghigAFX/ETh1I5Lg+gmmrOSg9MF37kjGqcfn3KFYi3xiiusp6N2CXLKVSbjPQjiBZ+4j+ADnnfRPlFoyvTAY3aF0zuKKdCTeMK14JNaJlTcHw8TBZczFvY1WWa+iqmmzrt2RIh72x9Ilc8wii6aQ3/nH+08o= X-Gm-Message-State: AOJu0Yz4kvYOSfo9U3ptbqclifaoWFE5Ry+VGxlULmKc2S3M1Xmb5f+D C8IxxiY0rWnDi8toi4n8lBSa/Q+f0Up36KsZBiKBcbpMlx/g620i X-Received: by 2002:a17:90b:4a0c:b0:299:3334:51d1 with SMTP id kk12-20020a17090b4a0c00b00299333451d1mr11593925pjb.10.1708484346801; Tue, 20 Feb 2024 18:59:06 -0800 (PST) Received: from macbook-pro-49.dhcp.thefacebook.com ([2620:10d:c090:400::4:b11c]) by smtp.gmail.com with ESMTPSA id v11-20020a170902f0cb00b001d937bc5602sm6946664pla.227.2024.02.20.18.59.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 18:59:06 -0800 (PST) Date: Tue, 20 Feb 2024 18:59:03 -0800 From: Alexei Starovoitov To: Benjamin Tissoires Cc: 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 , 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 Subject: Re: [PATCH RFC bpf-next v2 02/10] bpf/helpers: introduce sleepable timers Message-ID: References: <20240214-hid-bpf-sleepable-v2-0-5756b054724d@kernel.org> <20240214-hid-bpf-sleepable-v2-2-5756b054724d@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=us-ascii Content-Disposition: inline In-Reply-To: On Fri, Feb 16, 2024 at 10:50:10AM +0100, Benjamin Tissoires wrote: > static bool is_rbtree_lock_required_kfunc(u32 btf_id) > { > return is_bpf_rbtree_api_kfunc(btf_id); > @@ -12140,6 +12143,16 @@ static int check_kfunc_call(struct bpf_verifier_env *env, struct bpf_insn *insn, > } > } > > + if (is_bpf_timer_set_sleepable_cb_kfunc(meta.func_id)) { > + err = push_callback_call(env, insn, insn_idx, meta.subprogno, > + set_timer_callback_state); > + if (err) { > + verbose(env, "kfunc %s#%d failed callback verification\n", > + func_name, meta.func_id); > + return err; > + } > + } All makes sense so far. Please squash all the fix and repost. It's hard to do a proper review in this shape of the patch. As far as rcu_read_lock/unlock that is done in callback... it feels buggy and unnecessary. bpf prog and timer won't disappear while work is queued. array and hash map will call bpf_obj_free_timer() before going away. And things like: + rcu_read_lock(); + callback_fn = rcu_dereference(t->sleepable_cb_fn); + rcu_read_unlock(); + if (!callback_fn) + return; is 99% broken. if (!callback_fn) line is UAF.