From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 78E3342983E for ; Tue, 9 Jun 2026 13:56:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781013364; cv=none; b=U60AEORNdlI44+pV9Ii/kued65FqWxeQLnfK8KG8n2IZ6HhZ6ydwxgSzhcJcEeJr3dnDuk/KEqfID2PKA+DBMKN34ptyRLJbyUvqkJOgasRojo4yc2w5qiQq5ugvMaWnZXkUtGo/lTmciBO/Fj4mNApeccA0yS0b/wjHCwlhtKI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781013364; c=relaxed/simple; bh=RfNWACLgqPh7mn6BW2OHVluMXiuuJTWj+ppahGvAWho=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J//so4428ICuVXTj/TG4x/dNjn/Esvstdw1bCfykcXfo9olgcE7StfjMjHZ0HYJRn+dJt9yBeiVtG+tZrJ9Eg4IMLq4Z5CEzHQS/dnLc9+68sXaAFkO8dIvExrZHuj2cdIpxNH3xHUgJdQifGv0CyMgKQCvXTGCdpSY9taBzNxY= 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=i/jSc41/; arc=none smtp.client-ip=209.85.221.52 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="i/jSc41/" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-45ef372c58aso2969868f8f.0 for ; Tue, 09 Jun 2026 06:56:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781013362; x=1781618162; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+mArFZON/573TsUWZ5APnKTWJ9fGsLln8Kw8VObW6p8=; b=i/jSc41/vi+/+uf5ui8TqopdoL6cNNeFIaqEPhyOMiG/SpXXOhiEstM+/CL5V06l1D I//OZeWT8/iuJL1TW5J9TskXHPSrL7NHOYDUGji1nXg5Wjodv2lG13Osc6grxZDMKTLc gOxGtOH3gVq0QzJhjgLZozAlRaFpTTufNyEP15UG30/jfa5Rnm7mRBsLWuSGQ4xzPc43 eCu1Q0qAdXvmTSfvAsnKhZCRT2/1ULOofpZIejNqHoG/PGwUhKrY5p7/NCBY3mRaGZk2 4CBd27/IBrpgyoS1gZbNyHzpeKkN5rAWZdc7lEHzrRGE0vrgnF8ItJHmL04F+D1XGVKY gX1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781013362; x=1781618162; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=+mArFZON/573TsUWZ5APnKTWJ9fGsLln8Kw8VObW6p8=; b=MgvjKo2EWiKcYK/dLjLwrNP5hQmhsnbhWu5oPDeMXZE9fEhR82ZjQeSiTWj+nsU4br fxq7wycshLD7FN2KBIdTcmIyaEf/hUwjaYJdT0Gc6Vu2GZkraIwvZmt8Ay4uamYw8PlO DG9xd9QKH+zozUEGTCw06eb0J/K+rCuJmhhY8Q4CM5En9snue6PKR3lgrJICkvhDrVMd f5wfd9BVYX2q8iNQhK+ibIv/SFJCrANmDKXYW46ZJVmCwBZtIZ3ltg8t+K1D7MImtYl3 naSguTe09KxVr5s3FbH2SKrzLpbyramXn0TnsyV44aLk8Jwvu3uPYJupbzosElo+4DYr JV3Q== X-Forwarded-Encrypted: i=1; AFNElJ/HXFjbVycL7CSUmAN56sjvBPwY6TEJHVuL7i/7NjTgtDEYdLh+JRJO6mfi+5IxMJs4NobJ9REY7K9Kuik=@vger.kernel.org X-Gm-Message-State: AOJu0YwKdzyYzSelXCjSErjDvpOI+xC7juznNzTdckhaPQIMtfPdO6uI Rt4yiIAU9syQenasnD4vcvADFJBTrBPN3ZjOEdkXrP7umi2GwNtLD2pl X-Gm-Gg: Acq92OGHhp3SC0PLIXzXCDDs6VK1acFIi7dSR1vSfnx5KNEYxDNxZdcpGrgm8SQMIpH Ama5lAWWXFjeEIWHc6DqOF28pnSJyn5hsFe7nEyHgKuwM4QXkm5L52pAsT7mxDmlZnxacnOTKW6 oX4BLcQEaotDWfMg9kFpN8uIVtTu+e37EgngIRqaUYo1qtn87agbEAQbCG48owr9egRN9Qcp30S RILBpcsSOgzUzCz3I3pHrR7O+N5vrXCr4rpNmvqdG/0IfDF0G1EbJ4SJa/VArYWTKg+P+8dsDhi BlOflv2PNjkeZHCRe+pE+jGGVO+GLaRDCPHqVZFk49yJovHWj5TNSyRX+lfbFTFHkeGgm7R5fYs VBMqYdl2rlsWW+4zE55KV8Jw9wVsQ9UwIfBgvU17OMiFw/uD5lZQPZ2He088b1zaTwk4dTmCdOB qf3SBskTkHFSXrXdk7G1jgUN3qEzQ= X-Received: by 2002:a05:6000:4696:b0:45d:4a00:b927 with SMTP id ffacd0b85a97d-4603075bb9bmr22100636f8f.31.1781013361632; Tue, 09 Jun 2026 06:56:01 -0700 (PDT) Received: from localhost ([2a03:2880:30ff:72::]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4601f3529e0sm64140898f8f.28.2026.06.09.06.56.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2026 06:56:01 -0700 (PDT) From: Vlad Poenaru To: bpf@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , John Fastabend , Martin KaFai Lau , Eduard Zingerman , Kumar Kartikeya Dwivedi , Song Liu , Yonghong Song , Jiri Olsa , =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= Cc: Emil Tsalapatis , linux-kernel@vger.kernel.org Subject: [PATCH bpf v2 0/2] bpf, lpm_trie: Allow sleepable BPF programs to use LPM tries Date: Tue, 9 Jun 2026 06:55:56 -0700 Message-ID: <20260609135558.193287-1-vlad.wing@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260529174233.2954240-1-vlad.wing@gmail.com> References: <20260529174233.2954240-1-vlad.wing@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit trie_lookup_elem() annotates its rcu_dereference_check() walks with only rcu_read_lock_bh_held(), so a sleepable BPF program that touches an LPM trie (e.g. a sleepable LSM hook calling bpf_map_lookup_elem()) trips a "suspicious RCU usage" lockdep splat on debug kernels: it holds only rcu_read_lock_trace(), which that annotation does not accept. Patch 1 relaxes the rcu_dereference annotations in the trie walks so they no longer trip lockdep from the Tasks Trace context, including the trie_update_elem()/trie_delete_elem() writer walks (protected by trie->lock). Patch 2 adds BPF_MAP_TYPE_LPM_TRIE to the verifier's sleepable map whitelist so sleepable programs can reference an LPM trie directly, not just as the inner map of a map-of-maps. LPM trie nodes are reclaimed via bpf_mem_cache_free_rcu(), which chains a regular RCU grace period into a Tasks Trace grace period before freeing -- the same discipline BPF_MAP_TYPE_HASH relies on for sleepable access. Changes since v1: - Split into a 2-patch series. - Patch 1 now also converts the trie_update_elem()/trie_delete_elem() walks from rcu_dereference() to rcu_dereference_protected(*p, 1), addressing review feedback that v1 only fixed the lookup path and left the same splat on the writer paths. - New patch 2 adds the verifier whitelist entry so the fix is actually reachable for directly-referenced LPM tries. - Retitled v1 ("Allow lookups from sleepable BPF programs"). v1: https://lore.kernel.org/all/20260529174233.2954240-1-vlad.wing@gmail.com/ Vlad Poenaru (2): bpf, lpm_trie: Allow access from sleepable BPF programs bpf, lpm_trie: Allow sleepable programs to use LPM trie maps directly kernel/bpf/lpm_trie.c | 8 ++++---- kernel/bpf/verifier.c | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) -- 2.53.0-Meta