From nobody Fri Sep 25 16:51:05 2026 Received: from mta1.migadu.com (out-52.mta1.migadu.com [95.215.58.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 2E96F3E1D0D for ; Thu, 10 Sep 2026 09:34:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789032877; cv=none; b=bjsgwhhKQkT/LMeQ9MSz2WV9wBpXKmrP6F2zJKC+6I66xTetYyGoFQYDLT66jwEW8NEsBM/rtT3gThlFnPNwuGgPVUzhBh1wOKeoKZUhfN/8oMqKi4D4pHnKZuhcjoCrpSUwJ47e9kJNdyuH9OuFMB9oT0bHGcrF3LXYur9G7gs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789032877; c=relaxed/simple; bh=pxNPuqInUXA5BhBex6CFLs+8pBKZ4qJtowlQoFJZa4I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Tv/+wOtR/HITHUf2bm8mZi7lzxQiRaSS6G8xtnrAJVbbHkpYEU4Fi7Gk0S04XvvDNE0+x+zMqDq9fUiluCWfWiFQP3/75NFRwv9LWIAFcIYnvCbbIu71llGTaetQ42paPhkFQh2L6XE6l9Os5gfH75PtZHQyNe/QFk3YNM2ozEI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=tfCRU3/j; arc=none smtp.client-ip=95.215.58.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="tfCRU3/j" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=pxNPuqInUXA5BhBex6CFLs+8pBKZ4qJtowlQoFJZa4I=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1789032874; v=1; x=1789637674; b=tfCRU3/j+Nemfjx1rtIU4R7iEj1EcpelSYw4gs7bQ+gnktELoxz+a4VT1a5Aqbhd9Sm9sXE0 vjucqRB8PSJhvI89EnXme2VnIft5nk7uEv3I99DtqgAkpls11KDW9PKymL/TShhEayAAKk/bPe5 YAF/qGVazVwSBZLywrcciEn8= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 5d418fa20c543b52; Thu, 10 Sep 2026 09:34:33 +0000 X-Mizu-Trace-ID: 5d418fa20c543b52 X-Migadu-Flow: FLOW_OUT From: Xuanqiang Luo To: netdev@vger.kernel.org Cc: jhs@mojatatu.com, jiri@resnulli.us, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, shuah@kernel.org, marcelo.leitner@gmail.com, pctammela@mojatatu.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Xuanqiang Luo , stable@vger.kernel.org Subject: [PATCH net v1 1/2] net/sched: act_api: release tail references on DELACTION failure Date: Thu, 10 Sep 2026 17:34:12 +0800 Message-ID: <20260910093413.34509-2-xuanqiang.luo@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260910093413.34509-1-xuanqiang.luo@linux.dev> References: <20260910093413.34509-1-xuanqiang.luo@linux.dev> 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: Xuanqiang Luo A batched RTM_DELACTION request takes a temporary reference on each action before attempting any deletion. tcf_action_delete() clears each processed slot and drops its temporary reference before attempting the deletion. If deletion fails, tca_action_gd() calls tcf_action_put_many() to release the remaining references, but its tcf_act_for_each_action() iterator stops at the first NULL slot. When a batch stops at an action bound to a filter, this leaks a reference on each subsequent action. A later delete of an unbound action can then return success without removing it from the IDR. Walk the full array in tcf_action_put_many() and skip NULL slots to release the references held on the unprocessed actions. Fixes: a0e947c9ccff ("net/sched: act_api: avoid non-contiguous action array= ") Cc: stable@vger.kernel.org Signed-off-by: Xuanqiang Luo --- net/sched/act_api.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 37eced84dfa5f..86710a596a0fa 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -1223,11 +1223,16 @@ static int tcf_action_put(struct tc_action *p) =20 static void tcf_action_put_many(struct tc_action *actions[]) { - struct tc_action *a; int i; =20 - tcf_act_for_each_action(i, a, actions) { - const struct tc_action_ops *ops =3D a->ops; + /* Deletion may have cleared entries before failing. */ + for (i =3D 0; i < TCA_ACT_MAX_PRIO; i++) { + struct tc_action *a =3D actions[i]; + const struct tc_action_ops *ops; + + if (!a) + continue; + ops =3D a->ops; if (tcf_action_put(a)) module_put(ops->owner); } --=20 2.43.0 From nobody Fri Sep 25 16:51:05 2026 Received: from mta1.migadu.com (out-67.mta1.migadu.com [95.215.58.67]) (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 DC9C93E5ED1 for ; Thu, 10 Sep 2026 09:34:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.67 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789032884; cv=none; b=hucUFr34cB8V0BfhxTZi91WM68K9Xb+Rf5cy66cBnfwB9P+dLqHPr8rh0e+tmm3sAI3nprebDjKjFQ2u09iGUJf/Uvy44MROLjk9DTo2xoYtRms0H4RAKk+WzY3J2Gz6b+W0n1vvhGZPvQzxAGO1VEBF+sP/58N040pl7ek3LU0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789032884; c=relaxed/simple; bh=QW5F+KC6Mtc19N8+SJ6VtwIGPrdVeLpE90M+rMrrlUQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hy37niaqEB5M+JKQqr+fvyL19QJUSvW3EJz72/MrekDW6Lm/B/xAczkGW2LFM2BfzzuFExv1/90LDOUgiUuwzLanSfqIp5z7mfDjU4OcOQ99FXduw5GOsFi4+8jmmACKKqscMpSbyFQzfhG8M9FtnQw9/7Vs73LNEkcSgVVRU7Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=l68KufMU; arc=none smtp.client-ip=95.215.58.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="l68KufMU" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=QW5F+KC6Mtc19N8+SJ6VtwIGPrdVeLpE90M+rMrrlUQ=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1789032879; v=1; x=1789637679; b=l68KufMUs8MjF0atgUN0wNwds7dpgaKwssgp6Gp82jhPR5cvZJ7Mf8eHKK31/4kfZfkDDV2v aZlMixhhxUcmukgeuZBn1Cnww5Mps4iUJaBVT0cDpVjntiCM/Xwe36NtgMHJmXRKZqcBSldZNyK NwqLs6V+NWG3bCly3QPC6rao= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id b9c99183e804cd3e; Thu, 10 Sep 2026 09:34:39 +0000 X-Mizu-Trace-ID: b9c99183e804cd3e X-Migadu-Flow: FLOW_OUT From: Xuanqiang Luo To: netdev@vger.kernel.org Cc: jhs@mojatatu.com, jiri@resnulli.us, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, shuah@kernel.org, marcelo.leitner@gmail.com, pctammela@mojatatu.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Xuanqiang Luo Subject: [PATCH net v1 2/2] selftests: tc-testing: test action batch deletion failure cleanup Date: Thu, 10 Sep 2026 17:34:13 +0800 Message-ID: <20260910093413.34509-3-xuanqiang.luo@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260910093413.34509-1-xuanqiang.luo@linux.dev> References: <20260910093413.34509-1-xuanqiang.luo@linux.dev> 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: Xuanqiang Luo Add tests for cleanup after a batched RTM_DELACTION request fails at a gact action bound to a filter. Check that subsequent actions retain their original reference counts and that earlier successful deletions are preserved. Cover failures at the first and middle entries. Verify that a remaining unbound action can be removed with one subsequent delete. Signed-off-by: Xuanqiang Luo --- .../tc-tests/actions/batch-delete.json | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 tools/testing/selftests/tc-testing/tc-tests/actions/bat= ch-delete.json diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/batch-dele= te.json b/tools/testing/selftests/tc-testing/tc-tests/actions/batch-delete.= json new file mode 100644 index 0000000000000..ef7ca4a6775bc --- /dev/null +++ b/tools/testing/selftests/tc-testing/tc-tests/actions/batch-delete.json @@ -0,0 +1,115 @@ +[ + { + "id": "d710", + "name": "Release tail references after first action deletion fails= ", + "category": [ + "actions", + "gact" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + "$TC qdisc add dev $DEV1 ingress", + "$TC actions add action pass index 1", + "$TC actions add action pass index 2", + "$TC actions add action pass index 3", + "$TC filter add dev $DEV1 protocol ip ingress u32 match u32 0 = 0 action gact index 1" + ], + "cmdUnderTest": "$TC actions del action gact index 1 action gact i= ndex 2 action gact index 3", + "expExitCode": "255", + "verifyCmd": "$TC actions ls action gact", + "matchPattern": "total acts 3\\b.*index 1 ref 2 bind 1\\b.*index 2= ref 1 bind 0\\b.*index 3 ref 1 bind 0\\b", + "matchCount": "1", + "teardown": [ + "$TC qdisc del dev $DEV1 ingress", + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ] + ] + }, + { + "id": "d711", + "name": "Release tail references after middle action deletion fail= s", + "category": [ + "actions", + "gact" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + "$TC qdisc add dev $DEV1 ingress", + "$TC actions add action pass index 1", + "$TC actions add action pass index 2", + "$TC actions add action pass index 3", + "$TC filter add dev $DEV1 protocol ip ingress u32 match u32 0 = 0 action gact index 2" + ], + "cmdUnderTest": "$TC actions del action gact index 1 action gact i= ndex 2 action gact index 3", + "expExitCode": "255", + "verifyCmd": "$TC actions ls action gact", + "matchPattern": "total acts 2\\b.*index 2 ref 2 bind 1\\b.*index 3= ref 1 bind 0\\b", + "matchCount": "1", + "teardown": [ + "$TC qdisc del dev $DEV1 ingress", + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ] + ] + }, + { + "id": "d713", + "name": "Delete a tail action once after a failed batch", + "category": [ + "actions", + "gact" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ], + "$TC qdisc add dev $DEV1 ingress", + "$TC actions add action pass index 1", + "$TC actions add action pass index 2", + "$TC filter add dev $DEV1 protocol ip ingress u32 match u32 0 = 0 action gact index 1" + ], + "cmdUnderTest": "$TC actions del action gact index 1 action gact i= ndex 2", + "expExitCode": "255", + "verifyCmd": "sh -c '$TC actions del action gact index 2 && $TC ac= tions ls action gact'", + "matchPattern": "total acts 1\\b.*index 1 ref 2 bind 1\\b", + "matchCount": "1", + "teardown": [ + "$TC qdisc del dev $DEV1 ingress", + [ + "$TC actions flush action gact", + 0, + 1, + 255 + ] + ] + } +] --=20 2.43.0