From nobody Wed Feb 11 04:18:33 2026 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (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 620A12D46A9 for ; Mon, 9 Feb 2026 02:53:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770605589; cv=none; b=Nva95D4xQ8PVzLC8Oj0/Mcv3g2Kv8UaaFLLxNMXEm/CxDKq/xiGg5fr+BTexFdg1Jtdp/2uAv+0jrUPrucr/b5JzrXQBkKkFPTxpCGZpV1lwM0zGDUPKHaUwU5i/d6kvpajdL9LIXISPV+WYKOdDjx6WObqD3/jwMhue6TcEhNg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770605589; c=relaxed/simple; bh=dZyWorY56D04HTdXpSwh7QEZlBPCUnue80n0dJ628hc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eqI1UscUguU29TVVkecZCtII2GgmFQwdlCay0nXWE0nzf9Jrmv6PrTWKYKGgDHPMfWVx+qRVLBoM9zcDiqCa/kBJo/c944cBTfPKk0Mqf2NSiF/8EeZ5cerUQLtY5trkCMHh01kc8jmw+1oz0v7c3KDwm6YOmF2GqTEHW5Gs9G8= 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=dWOxidjj; arc=none smtp.client-ip=209.85.216.44 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="dWOxidjj" Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-352ccc61658so1890138a91.0 for ; Sun, 08 Feb 2026 18:53:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770605589; x=1771210389; 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=EQyhNUDLqzwbtqwaK40Ft6UNR4W3i+d+XwrUt1sl98s=; b=dWOxidjjI33rHL2TvhPdcEEzFcd/LYMhI6G9ZD3wiH7/GSBH6dOR49aJ2vhX9i+6an agnHddBa8V7x3ozmqoYtOqlGB8Q5esrAl3K6k4TILJfDzWiBuioiMNnog5sTnJmnWt06 DPKB5LiYrAopUmba5yafH15ctSxqLn3E67iX5uxZM4CtcVw8zOBFIM8cDBN+DQGOGCxe KUg+NnhxAx2WPC6gyZWfJMcKdoNMa6LuM6ACINPodZ1H6pwsv6mBdbRjiV4mJvNnecsB SwLlX0q4WSQP0mpDhuOv+x4GEJz3xh+jCmgHTJT4QwF/GcfKEgpQMtXMNVagdTJ9zaBC ivBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770605589; x=1771210389; 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=EQyhNUDLqzwbtqwaK40Ft6UNR4W3i+d+XwrUt1sl98s=; b=f0LghF+mtTCGEgayCvxpz6gbCbcVfjOyHJf9xG0HKfYs77S9EJyMlPyrOG/1+9pSxb H3mCndG6RSE2N4BnFEnDKK3LY+Ix0GqpkH/0uFvr+jFkbclTI377ELxLEBnudqzrPhuH 5FokNZojUUovMb9MQ3Qw6aAjy/x58a0ti3o/bNAMhMWXOdaI8YfRNhl6gVunwP+jU+eM 93jywqL6yEXLuTYAHHYyX1qXjaYmokgbpvhC2aUSd9VWQ6xP2kS7fxXhzdrxfFiFYm3q /QH7tbEeuytypj2Z3tLa4jwX2lWZDdokhlp43iQXS9+/lN1owNkfmos54GbDCSn4Pmqm AnVg== X-Forwarded-Encrypted: i=1; AJvYcCWi4PbMJQ8uPN//LOOlPQfp1ybkLz4h8E3DI2/q2hBSM9nOYRNTI8N6dbnvwje0nPgUXcJEz1NqEjEqiRU=@vger.kernel.org X-Gm-Message-State: AOJu0YzMiytjD3Ml2fYjS5O1TEaaomfXtbVVAWfF8VuDie7zFJFL7XQR sdkQJfvzfzNlJ7x5jPsHIfT/Yt+MjwH3aLae74xxF0SR+SQ5tOUJj36z X-Gm-Gg: AZuq6aIfdDN9z7L+hQ9DqvMJloavtfkjJvn+7RI5ESMNKSCLQJlz2HZLQEsFql6fLsY dssJ1UdMAaD5PqguwCRXG8+qUDxqGYKnpQYF/vXyVqlnaudM1ekLBDC32WvR7aVt0pI0BvYyUNZ wTvz6BTu3UClabUqTHbntE9Vqkj1y3zCRS1koKMmLd4ACcp1JlLCPg0DfBesCtNHHUlhiCjQ/r8 2F4mBph4fVASikjhx8KtPD53Ud2Il9Dy8JEKMW5jjxjpvv8R/Of2vYv5e0ja87KGPuJ8BQuAkbZ c+h3nFJLu9Z13uZ0ZrISvJaoINnxlf89Vz4aybR/ifSlTh5blzw0oAl3VW55y2jeoTLRsL96At5 ThD9uA5Xfo8QHdIvDTtNqt2TVBx7jgDqsmkpd1Y+ED5Xqw1kznDYBOI8fpAAm/M/gCtNq1D5w+8 bwB5jA712buIez49ZU2aQiAroO4jSEAaEl4pkwlD9oX1NhfisJFVUo X-Received: by 2002:a17:90b:1c8a:b0:356:268f:4fc with SMTP id 98e67ed59e1d1-356268f08c5mr4112871a91.11.1770605588737; Sun, 08 Feb 2026 18:53:08 -0800 (PST) Received: from localhost.localdomain ([116.128.244.171]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35621177896sm6302649a91.15.2026.02.08.18.53.03 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 08 Feb 2026 18:53:08 -0800 (PST) From: Chengkaitao To: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org, yonghong.song@linux.dev, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@fomichev.me, haoluo@google.com, jolsa@kernel.org, shuah@kernel.org Cc: chengkaitao@kylinos.cn, leon.hwang@linux.dev, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH 1/2] bpf: Introduce the bpf_list_del kfunc. Date: Mon, 9 Feb 2026 10:52:49 +0800 Message-ID: <20260209025250.55750-2-pilgrimtao@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260209025250.55750-1-pilgrimtao@gmail.com> References: <20260209025250.55750-1-pilgrimtao@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: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kaitao Cheng If a user holds ownership of a node in the middle of a list, they can directly remove it from the list without strictly adhering to deletion rules from the head or tail. This is typically paired with bpf_refcount. After calling bpf_list_del, it is generally necessary to drop the reference to the list node twice to prevent reference count leaks. Signed-off-by: Kaitao Cheng --- kernel/bpf/helpers.c | 19 +++++++++++++++++++ kernel/bpf/verifier.c | 6 +++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c index db72b96f9c8c..44d9b9ea8d40 100644 --- a/kernel/bpf/helpers.c +++ b/kernel/bpf/helpers.c @@ -2388,6 +2388,24 @@ __bpf_kfunc struct bpf_list_node *bpf_list_pop_back(= struct bpf_list_head *head) return __bpf_list_del(head, true); } =20 +__bpf_kfunc struct bpf_list_node *bpf_list_del(struct bpf_list_head *head, + struct bpf_list_node *node) +{ + struct bpf_list_node_kern *knode =3D (struct bpf_list_node_kern *)node; + struct list_head *h =3D (void *)head; + + if (unlikely(!knode)) + return NULL; + + if (WARN_ON_ONCE(READ_ONCE(knode->owner) !=3D h)) + return NULL; + + list_del_init(&knode->list_head); + WRITE_ONCE(knode->owner, NULL); + + return node; +} + __bpf_kfunc struct bpf_list_node *bpf_list_front(struct bpf_list_head *hea= d) { struct list_head *h =3D (struct list_head *)head; @@ -4404,6 +4422,7 @@ BTF_ID_FLAGS(func, bpf_list_push_front_impl) BTF_ID_FLAGS(func, bpf_list_push_back_impl) BTF_ID_FLAGS(func, bpf_list_pop_front, KF_ACQUIRE | KF_RET_NULL) BTF_ID_FLAGS(func, bpf_list_pop_back, KF_ACQUIRE | KF_RET_NULL) +BTF_ID_FLAGS(func, bpf_list_del, KF_ACQUIRE | KF_RET_NULL) BTF_ID_FLAGS(func, bpf_list_front, KF_RET_NULL) BTF_ID_FLAGS(func, bpf_list_back, KF_RET_NULL) BTF_ID_FLAGS(func, bpf_task_acquire, KF_ACQUIRE | KF_RCU | KF_RET_NULL) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 50cb4956e5bb..dff6cc8912e4 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -12345,6 +12345,7 @@ enum special_kfunc_type { KF_bpf_list_push_back_impl, KF_bpf_list_pop_front, KF_bpf_list_pop_back, + KF_bpf_list_del, KF_bpf_list_front, KF_bpf_list_back, KF_bpf_cast_to_kern_ctx, @@ -12399,6 +12400,7 @@ BTF_ID(func, bpf_list_push_front_impl) BTF_ID(func, bpf_list_push_back_impl) BTF_ID(func, bpf_list_pop_front) BTF_ID(func, bpf_list_pop_back) +BTF_ID(func, bpf_list_del) BTF_ID(func, bpf_list_front) BTF_ID(func, bpf_list_back) BTF_ID(func, bpf_cast_to_kern_ctx) @@ -12862,6 +12864,7 @@ static bool is_bpf_list_api_kfunc(u32 btf_id) btf_id =3D=3D special_kfunc_list[KF_bpf_list_push_back_impl] || btf_id =3D=3D special_kfunc_list[KF_bpf_list_pop_front] || btf_id =3D=3D special_kfunc_list[KF_bpf_list_pop_back] || + btf_id =3D=3D special_kfunc_list[KF_bpf_list_del] || btf_id =3D=3D special_kfunc_list[KF_bpf_list_front] || btf_id =3D=3D special_kfunc_list[KF_bpf_list_back]; } @@ -12970,7 +12973,8 @@ static bool check_kfunc_is_graph_node_api(struct bp= f_verifier_env *env, switch (node_field_type) { case BPF_LIST_NODE: ret =3D (kfunc_btf_id =3D=3D special_kfunc_list[KF_bpf_list_push_front_i= mpl] || - kfunc_btf_id =3D=3D special_kfunc_list[KF_bpf_list_push_back_impl= ]); + kfunc_btf_id =3D=3D special_kfunc_list[KF_bpf_list_push_back_impl= ] || + kfunc_btf_id =3D=3D special_kfunc_list[KF_bpf_list_del]); break; case BPF_RB_NODE: ret =3D (kfunc_btf_id =3D=3D special_kfunc_list[KF_bpf_rbtree_remove] || --=20 2.50.1 (Apple Git-155) From nobody Wed Feb 11 04:18:33 2026 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (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 7E0C02C0F72 for ; Mon, 9 Feb 2026 02:53:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770605595; cv=none; b=A0gBGDT639iWpKLHeWYNCi99Cn3ZkE+sSzZBcUjrqSOdgfWW5JtyXcARQKtLgk9KBh3GNWlU/8in56sXtBBZCgMfpuDqhisl6TVYv4Fc9+u9dCSdS02ea4AN1ql0UixilL7F542oS/481gHa8VhMDRcTf+2qwgJWsstoabC3m8U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770605595; c=relaxed/simple; bh=RmGHUe45I4K7MVIz7OBicUcd2G4lg/Tg0QEzkQLAcIo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=udoZlMH03xTiVNRVXWcfHyPkssWgP8lXKPxBkj/trwlq741u6ZbmavLV8RrzlJ2N96hFJWxa/qtRaTRKPO/W9gWvj1xrfrzdalEnqEVAoEVsscz1etz/Be4PAzdD7XB3YSI2F0I3FVFB6HmdP0JVrtY4iKWiZLEeX+0ZRBDjbBk= 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=ndrhTPjc; arc=none smtp.client-ip=209.85.216.53 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="ndrhTPjc" Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-354bb7d2cb1so887042a91.0 for ; Sun, 08 Feb 2026 18:53:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770605595; x=1771210395; 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=UoKEL4fx2cXbp8ykQKKpnwt29v9mHhKU5fa9H902sH4=; b=ndrhTPjcGnmVExHoGlvd9h1lvagktFJhVEIcp10SGBmVCRoXzwZEjbWgwRjgojwsNh 863/XVcbY+EdMslqju7Q06Dg24QEA2Yb8eBwJCu+wHUcYFtiG8dkvyUvSqcVoOvSgrtI 0DT5WBeZcfqCxpaWtZ2S18uDTMKQy0eGtmskYZ7R7kCoPrTZ11xJ/RHFXs73ucIGdCvM GgYllMBnicJGDdaVtRsVLgLrtx+f12aLNoHcbk2cZdA4PBr0udufkWYWIzoUAP9W/Vnh ZJfmSFut+G7SImvqeZK3Y9fzHbT0HWjkQCMHcNgaXzeTfdH9+iCffOa0IbP9i9Qbx8kb aOVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770605595; x=1771210395; 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=UoKEL4fx2cXbp8ykQKKpnwt29v9mHhKU5fa9H902sH4=; b=gxTCQNUTb5wcwnUzYbYP3JwbZW+c1dJg1jh3NeZ302ZGHbbqAtoW0o80YpAry6s84t McaWVsm63PIn6w/lTbqUuDux39q9EXQLOdjR2ACQU4gg0b59xtVYb1Lhs0orafk3Cgxj fpss/8OVHAkYd4ggWksvp5b8BOOQ7UCPd+rROyiy3CCxyG8Y2wwV16HpaNtdhGIgO9v7 hZxkUty0jNicDkJXDaMVhpA9dTzStG5TD54fi4pbely2lBADwgO3lYw15O3QUEERPd8r 0Xvv9g2mrl9YRycCgJG6EVqpnIbNAMpZcW4MwS97K/8fMHk9647OvUaQNyM0TdncTyNL Ox3g== X-Forwarded-Encrypted: i=1; AJvYcCUA4hYIJdqscJIrk5l992H9nLU2CHIJfTBZCtQP3YN8t4xY30diq82vrJ2aXCafxQ/qLneresnwaLCbxX8=@vger.kernel.org X-Gm-Message-State: AOJu0YzOxg4CgxpnWo5EicuyZQAO6GzpnOnvU+D1k+KnpCKqCMGz6U4L nnlFlICJUOOlk1RTX0YAWHFn6KredVmGGc0nEBDEA84UIoUasXIkcFru X-Gm-Gg: AZuq6aI3SvZbno+lewhQcfP0eo27v58/sPSaD2dCsuHnn9gUp/B5VmaITm77HYaZbfC g+LsFYVeyi6u1QTfLj4I0QmIKlEZAKcHlI5gd4Hfan1cyVJSZRkCyKMuejUU730bxtnYBp1ncW3 YF5RvVI6ZKc9ENAsaEsyBw5VNBA72DiUjt2DFa/+Mua49BoWk8l+ZJnvZBa/3TjJx75dD4Yf0WR /qtqE7ZqPbErQh/w1UMRhYp9WAFwNAEgKHkf2/n/fWKjNq4vi0MPSkkFi1ipmHeArCH297tEscm W8wnJMNWYG4o7jTnobZWJwzfnDG3qP7t7WfTakVPqvSt+Gsf5rxZGzKT1R0RWWQINQ6Z0dhalQi nMwmg2c1nDFz/bOV2poEfDBrm4InRzrtww8J53coKsLk35NeZinelRL+Pknd55mfDo677qLXe0y 3nQuTCil2YCdquoPb+RWmg+x/YiYzN37M/Q7n9yju5BI+/iOGo8Hn6 X-Received: by 2002:a17:90b:2682:b0:349:162d:ae0c with SMTP id 98e67ed59e1d1-354b2f6219amr8689322a91.4.1770605594812; Sun, 08 Feb 2026 18:53:14 -0800 (PST) Received: from localhost.localdomain ([116.128.244.171]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35621177896sm6302649a91.15.2026.02.08.18.53.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 08 Feb 2026 18:53:14 -0800 (PST) From: Chengkaitao To: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org, yonghong.song@linux.dev, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@fomichev.me, haoluo@google.com, jolsa@kernel.org, shuah@kernel.org Cc: chengkaitao@kylinos.cn, leon.hwang@linux.dev, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH 2/2] selftests/bpf: Add test cases for bpf_list_del Date: Mon, 9 Feb 2026 10:52:50 +0800 Message-ID: <20260209025250.55750-3-pilgrimtao@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260209025250.55750-1-pilgrimtao@gmail.com> References: <20260209025250.55750-1-pilgrimtao@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: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kaitao Cheng Add a node to both an rbtree and a list, retrieve the node from the rbtree, use the obtained node pointer to remove it from the list, and finally free the node. Signed-off-by: Kaitao Cheng --- .../testing/selftests/bpf/bpf_experimental.h | 11 +++++ .../selftests/bpf/progs/refcounted_kptr.c | 41 +++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/tools/testing/selftests/bpf/bpf_experimental.h b/tools/testing= /selftests/bpf/bpf_experimental.h index 2cd9165c7348..6d8175abc590 100644 --- a/tools/testing/selftests/bpf/bpf_experimental.h +++ b/tools/testing/selftests/bpf/bpf_experimental.h @@ -99,6 +99,17 @@ extern struct bpf_list_node *bpf_list_pop_front(struct b= pf_list_head *head) __ks */ extern struct bpf_list_node *bpf_list_pop_back(struct bpf_list_head *head)= __ksym; =20 +/* Description + * Remove 'node' from the BPF linked list with head 'head'. + * The node must be in the list. Caller receives ownership of the + * removed node and must release it with bpf_obj_drop. + * Returns + * Pointer to the removed bpf_list_node, or NULL if 'node' is NULL + * or not in the list. + */ +extern struct bpf_list_node *bpf_list_del(struct bpf_list_head *head, + struct bpf_list_node *node) __ksym; + /* Description * Remove 'node' from rbtree with root 'root' * Returns diff --git a/tools/testing/selftests/bpf/progs/refcounted_kptr.c b/tools/te= sting/selftests/bpf/progs/refcounted_kptr.c index 1aca85d86aeb..2cb6dd73db7a 100644 --- a/tools/testing/selftests/bpf/progs/refcounted_kptr.c +++ b/tools/testing/selftests/bpf/progs/refcounted_kptr.c @@ -367,6 +367,47 @@ long insert_rbtree_and_stash__del_tree_##rem_tree(void= *ctx) \ INSERT_STASH_READ(true, "insert_stash_read: remove from tree"); INSERT_STASH_READ(false, "insert_stash_read: don't remove from tree"); =20 +/* Insert node_data into both rbtree and list, remove from tree, then remo= ve + * from list via bpf_list_del using the node obtained from the tree. + */ +SEC("tc") +__description("test_bpf_list_del: remove an arbitrary node from the list") +__success __retval(0) +long test_bpf_list_del(void *ctx) +{ + long err; + struct bpf_rb_node *rb; + struct bpf_list_node *l; + struct node_data *n; + + err =3D __insert_in_tree_and_list(&head, &root, &lock); + if (err) + return err; + + bpf_spin_lock(&lock); + rb =3D bpf_rbtree_first(&root); + if (!rb) { + bpf_spin_unlock(&lock); + return -4; + } + + rb =3D bpf_rbtree_remove(&root, rb); + bpf_spin_unlock(&lock); + if (!rb) + return -5; + n =3D container_of(rb, struct node_data, r); + + bpf_spin_lock(&lock); + l =3D bpf_list_del(&head, &n->l); + bpf_spin_unlock(&lock); + bpf_obj_drop(n); + if (!l) + return -6; + + bpf_obj_drop(container_of(l, struct node_data, l)); + return 0; +} + SEC("tc") __success long rbtree_refcounted_node_ref_escapes(void *ctx) --=20 2.50.1 (Apple Git-155)