Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH] net/sched: act_police: fix false drops of pps-only policers
@ 2026-12-01  6:12 faicker.mo
  2026-12-01  6:18 ` netdev-bot+sinfo
  0 siblings, 1 reply; 2+ messages in thread
From: faicker.mo @ 2026-12-01  6:12 UTC (permalink / raw)
  To: faicker.mo
  Cc: stable, Jamal Hadi Salim, Jiri Pirko, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Willem de Bruijn,
	Simon Horman, Louis Peens, Baowen Zheng, netdev

From: Faicker Mo <faicker.mo@gmail.com>

tcf_police_act() reads the clock before taking tcfp_lock. Meanwhile
another CPU may update tcfp_t_c to a later time, making
now - tcfp_t_c negative.

With a byte rate, toks gets tcfp_toks added and is usually absorbed. A
pps-only policer has no byte rate, so the negative toks fails the
(toks | ptoks | ppstoks) >= 0 check and the packet is dropped even
if the pps bucket is full.

Clamp now to tcfp_t_c after taking the lock.

Fixes: 2ffe0395288a ("net/sched: act_police: add support for packet-per-second policing")
Signed-off-by: Faicker Mo <faicker.mo@gmail.com>
---
 net/sched/act_police.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/sched/act_police.c b/net/sched/act_police.c
index 3f8147f37549..0b3163385a69 100644
--- a/net/sched/act_police.c
+++ b/net/sched/act_police.c
@@ -280,6 +280,7 @@ TC_INDIRECT_SCOPE int tcf_police_act(struct sk_buff *skb,
 
 		now = ktime_get_ns();
 		spin_lock_bh(&police->tcfp_lock);
+		now = max_t(s64, now, police->tcfp_t_c);
 		toks = min_t(s64, now - police->tcfp_t_c, p->tcfp_burst);
 		if (p->peak_present) {
 			ptoks = toks + police->tcfp_ptoks;
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-01  6:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01  6:12 [PATCH] net/sched: act_police: fix false drops of pps-only policers faicker.mo
2026-12-01  6:18 ` netdev-bot+sinfo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox