From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) (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 3170B466B4A for ; Mon, 29 Jun 2026 16:50:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782751835; cv=none; b=qmwby9DG07l0x1WS2X/TuJyCeZJwzBBBSOC/iINFATTN8ruIJ2U6hd7cU5XO7RYm0f8BU+VNlEZ5x/9Ttuv2Y9l4JmBwHLFXJslfee0JFFBjrfU7aR4dwwrYJQDDmDTw9wFTwCu8FqTe3zJ7hqDn6FRBIIfXdC8ccxIKHf23eoQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782751835; c=relaxed/simple; bh=oeupzzhR5Ss49L8dlKMarQJVR5Sczj/faIJrQj/3wY8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=sTaOQf30If4k5DNiwhMAzwzh2p2866aBsc1t0WWvZni/rwcq0jZhMe7ytKTv1Bf/VT701k1HMgFmEILWjOQr3OJqdaPtEoejLw6LmFMVyNUj3B6Zy6Jp1eBvdQb61w9F5nadOzPr/3j4nDvlcu3Oo0S4bl8nqMYZf/XBSL1tie0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=trailofbits.com; spf=pass smtp.mailfrom=trailofbits.com; dkim=pass (2048-bit key) header.d=trailofbits.com header.i=@trailofbits.com header.b=TwIrIV5i; arc=none smtp.client-ip=209.85.160.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=trailofbits.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=trailofbits.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=trailofbits.com header.i=@trailofbits.com header.b="TwIrIV5i" Received: by mail-qt1-f171.google.com with SMTP id d75a77b69052e-519ff1c8b8bso42790091cf.3 for ; Mon, 29 Jun 2026 09:50:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trailofbits.com; s=google; t=1782751833; x=1783356633; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=46Ib9vSLcie/ttMUoRjBKHRJGPuNr1Dq2/Usm/hiTwc=; b=TwIrIV5i8MpOcqTLpx7D3b8LKC6e1CxAV/l+DSFXbykM8VlU/+qH5Wye4Yq36CRD4q DDPP9cTFidd5Q/GVEkgBiBRnb+nNtJUn+7rugXXdyLxR/C/WSGJmvaIoO2gcLH6txkpO yg2HzA8rFHQJB7ARCMlnOFXPNKdnhbO3QSsAXUaJtLHkiJyv7WalR69L9G31JmyxeMdu pPOKUs0LLS4Lyn4Dyu0i786BRTLT3KbNwrUbLpwNChhgkOOmrOPBcEkjgRMfDaK+nvsp KADII2DT5q3GvphFpk0s0NC0CsFR0pxNR34RqhK14q547Zo9ZspyNmYLUolYxXiQCsbZ KW2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782751833; x=1783356633; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=46Ib9vSLcie/ttMUoRjBKHRJGPuNr1Dq2/Usm/hiTwc=; b=TEilTp5cWcEvmRP44wxtIoVbKodP4yeIy1FvHOWPWgm4hLEe+VF6k2ifjINa7U2fOt QHw3ra/ubgHpuNO7IoxVs2T8DLwlgCNg5IyVnXFvocNQagGujxKf6z99sndRSvpHPch2 JNpRNNFv+RqXMD+1sIGI0rYLVxaYvr39+X6y4gBXJP9gwYjEzZCb/6/7gltFy7nhMZZT +N8Y3/1Sj3BPDFXkW4ksiCzN/w1QGg1FhaNEfhUauGaDQ4cQmSwvnG1sYLVJ0FSYiBDA lvUSlkNTOHfGML5V3RQdG/Pl5iUDfMKludrWqiXqn8UaY35B8SZOxc34sYLxzkhlWFxx oS6Q== X-Forwarded-Encrypted: i=1; AFNElJ/tV6hFYAo1J5E083Ji2DDjiK5AXM/VyqeH7mttJ/EhU3H6bXeMYC7UQ9dVeB23eFITxh7ixMF+UpFlCoY=@vger.kernel.org X-Gm-Message-State: AOJu0Yz7bGqVHRC737qbQv96vyo280aOwCsJUCRrwQoiXSj1Porgd3qP gGA10PY7bHTvWBafGsnpou87LyzQhwblM6pfK+IRmHdSBRIGpKFu7S9sJcYPtr2BTao= X-Gm-Gg: AfdE7cntF6GX7CvHwCFVBD0znbSDwL1U/tvZ59qQAMuTw409ABANUxhMMq/HC8GYk4A NdsLA9oIGr3pGItI6BuSbZOaLsfkb1RODzz5GfrLL4Hcdr+36vEx/Kw8ShlhLtnVtvs5xQ3wX3h PdSE7IV2BJBnGSSACe078FiTv21j0cpmeCAfDJzozcoG9XqsO8rv9K8C5lewgRRfvuqnbKSFo9Y Jp+SSZ4FMEGcAL6/HvaSKYwR4W51VACLgESlMPNfka79esPgzLsJ6qP0aNV7LDqPVbhUnpvTdWg X1/qqhiBZc6+49Xy3a3SeOOzYFbT8jKl8Wb5UbcP/VzAA7CVg+5WzVcjmEcuBUbNj+uxgAm6Ohj yPzd4F//ZKE6QWaLfrpY2pTJ8b5w7cQGZi1oN0msmRVUzeFEuJhY2Kpln2QOqRaHXAziZ6w10kq /JFEuF8yKmrk1pzON9 X-Received: by 2002:ac8:57ca:0:b0:517:642c:8196 with SMTP id d75a77b69052e-51c10752952mr1693361cf.12.1782751832951; Mon, 29 Jun 2026 09:50:32 -0700 (PDT) Received: from localhost ([161.35.96.86]) by smtp.gmail.com with UTF8SMTPSA id d75a77b69052e-51c1080d51bsm506001cf.2.2026.06.29.09.50.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 29 Jun 2026 09:50:32 -0700 (PDT) From: Samuel Moelius To: Jamal Hadi Salim Cc: Samuel Moelius , Jiri Pirko , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Terry Lam , netdev@vger.kernel.org (open list:TC subsystem), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2] net/sched: hhf: clear heavy-hitter state on reset Date: Mon, 29 Jun 2026 16:44:59 +0000 Message-ID: <20260629164458.195029.ab92a1db1120.hhf-reset-stale-classifier@trailofbits.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit HHF reset does not clear the classifier state used to identify heavy hitters. Packets after reset can therefore be scheduled using flow history from before the reset. The reset operation should return the qdisc to an empty state. Clear the heavy-hitter classifier tables when HHF is reset. Fixes: 10239edf86f1 ("net-qdisc-hhf: Heavy-Hitter Filter (HHF) qdisc") Assisted-by: Codex:gpt-5.5-cyber-preview Signed-off-by: Samuel Moelius --- Changes in v2: - Ensure no NULL dereference when initialization fails net/sched/sch_hhf.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/net/sched/sch_hhf.c b/net/sched/sch_hhf.c index 1e25b75daae2..d85cb0263b67 100644 --- a/net/sched/sch_hhf.c +++ b/net/sched/sch_hhf.c @@ -462,12 +462,39 @@ static struct sk_buff *hhf_dequeue(struct Qdisc *sch) return skb; } +static void hhf_reset_classifier(struct hhf_sched_data *q) +{ + int i; + + if (!q->hh_flows) + return; + + for (i = 0; i < HH_FLOWS_CNT; i++) { + struct hh_flow_state *flow, *next; + struct list_head *head = &q->hh_flows[i]; + + list_for_each_entry_safe(flow, next, head, flowchain) { + list_del(&flow->flowchain); + kfree(flow); + } + } + WRITE_ONCE(q->hh_flows_current_cnt, 0); + + for (i = 0; i < HHF_ARRAYS_CNT; i++) { + if (q->hhf_valid_bits[i]) + bitmap_zero(q->hhf_valid_bits[i], HHF_ARRAYS_LEN); + } + q->hhf_arrays_reset_timestamp = hhf_time_stamp(); +} + static void hhf_reset(struct Qdisc *sch) { + struct hhf_sched_data *q = qdisc_priv(sch); struct sk_buff *skb; while ((skb = hhf_dequeue(sch)) != NULL) rtnl_kfree_skbs(skb, skb); + hhf_reset_classifier(q); } static void hhf_destroy(struct Qdisc *sch) -- 2.43.0