From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (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 0F94D3D34BB for ; Thu, 30 Jul 2026 10:00:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785405639; cv=none; b=VjEh+HkW21plhqiu594d9pSqgRf/nnfZIggvfBDNv+eNVn70sf/YDLu8RwIbYjJwqj3ckk3/IbsBtrBmrSIed2LIUQokdz0M5k7deSumTMscESMTG6ex/fr78qoOY6K8KMSMaqEd+bfb/tV2MJ5C8z/zXa2ijf7tCPgyxkqW/4Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785405639; c=relaxed/simple; bh=v2otgkqcGoPAxtDs9BIv0BddY44N60tS9V3/kzf1rVY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NCejCa71ytJril17v82fdyp/Rgq8wuDvyQBdiy0lTrXr4qQAD9lBvI2KjrjrTeqkiEuBqlprYVTQeCSIBFc5nhX2VUsG/Vi4rwykBvFmyqTrd+yvg+2bp1f3abwQWuTIs3GlTfq3E1VBsaoxiUACP2f1+y+fZZceNm+CzWYSXjc= 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=sHyqn9ZF; arc=none smtp.client-ip=209.85.221.48 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="sHyqn9ZF" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-471eeac43bfso1763822f8f.3 for ; Thu, 30 Jul 2026 03:00:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785405635; x=1786010435; 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:content-type; bh=gPbuhEVbHecHzC1qayYU8wiK5gPmiPP8a157RrhfrjE=; b=sHyqn9ZFEY06m5SHFvzkLzgAr0InYknJQoZMQKQmpIEp/PPqDoncKpeiLPqfk+7YJ9 oZgR832i35eIYbADjPN6XycyZV4i9RcxVUR9DNdTT3cakxcKSavXi0oOJc6iKItGOWgl L2jO7GaAnIgPTpe9rCD0NwyiaAA3W1YLTe3PDrksOiyr8fpVLuijL8MwXxD64899RFFT pNBm55xedsjE3uuosLxWAHgZHNmWHapRhZbn8+n4vsQYj5OKNtbv7jrWU0H395yYAV9C TMlRhWnfjs2zGZSbNBP2/5mtXdJklRBF8BrWeO2Ubaj/Pmt58g3NCSHL+PQUTwjdNh47 mShQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785405635; x=1786010435; 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:content-type; bh=gPbuhEVbHecHzC1qayYU8wiK5gPmiPP8a157RrhfrjE=; b=LfSAs8UnjqkgUxJvTMM5BEx0UUZ3xeb9feSUuA30GbKRa5tMr6436kDnPfhFv3pKEV y8H9kL04AEwPb7hqD0K6PoPwGSutMbrhNwa8VttDq9DBov8T2PJtv2MFzitvPcHru8xv dlxu6KAy+tlpe/S5OdCZnViGxBKzyMckMyFXK6Egv8mw1rHxLBggogwOBhYJ90VjZFDu CWOvNLcT332OULR6684XV63ezHdYSgf4ebhjKuLgGqUKy1sEq9ymygBHTGiZdZS7rspC S1ElkXozglzhEjnN9/n91CHYv42+ZPS3OXmRtbwvGTeGi/SH+vcgl5jG+zX1swd+HF9x YsvA== X-Forwarded-Encrypted: i=1; AHgh+RpM7HWPJTXi/YhmX4kEf79wnPFgs+zS9K6eoDRnSbZw3YBPYFGK5HlkenrPqwX1LZAAgUTUxiXR6ffNbvE=@vger.kernel.org X-Gm-Message-State: AOJu0Yzd7ZoWqEmkR7SQZZFULY+qskC2piUDifr/uMc2Uz4FAcdKkL4x OsAIYx+zHbgc4NoBjhFG1YyNU2HlBFQmD5NRFO+XsjJq+Oyg+1bmynUC5TmOdINZ X-Gm-Gg: AR+sD10noHkvyzWKBoec/Aol0f/x+lX2NgoWePkZB7XfZvOABYihjZeOIy25t/ouIiJ xJjpPBGN7d5qxvZmg7CwJZh8JdsrJLGu2DgMDsQPS+EefpKGuSK4f9mYzy0OHZKx3gaCsaF1CFP 91IWFwajDpwSlwa/PfDUdJftWfLFRySS1AVfg87FqKzEbXYE8NC98rHjOIaCIfCpC19Ro/8QeqG 9nUsZ31ShgAW+8CDUFj/OtHOb9QB1SRfMBURiRjAH4ry6doWc2CsfpAMQIc6bs/cPRNdBVYp8JX GQiQcKJIjm9GEb2blp1it54yMBkHxKdxUY5zSTYvNS2hR1KqyJJg3C+wjS/16BzWW8M9x4ndXbe gxIeXD+cH31+eVV0V4LI8q9ho2NXGxSqDlIHu7roAs85ZcZxm8amydV1/k9b03Rh8PJILpFeiZ/ 9gZ7B6h9FQPiSP/4Ib/Diw+abafminXfPx6OnIgcj1cyJsjky7DgFZNgJdw1FlgKUvsavOn0CbG kkcBOPBuXBV X-Received: by 2002:a05:6000:2010:b0:47f:4fa9:ae42 with SMTP id ffacd0b85a97d-47fc80c2fcbmr2863337f8f.11.1785405634990; Thu, 30 Jul 2026 03:00:34 -0700 (PDT) Received: from pf-5j7x25.fkb.profitbricks.net ([2001:9e8:482:5000:a5d:311:98af:bd1a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47fc88e4721sm3984728f8f.16.2026.07.30.03.00.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jul 2026 03:00:34 -0700 (PDT) From: Reshma Sreekumar To: Jamal Hadi Salim , Jiri Pirko , netdev@vger.kernel.org Cc: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Shuah Khan , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Reshma Sreekumar Subject: [PATCH net 1/2] net/sched: flag inconsistent qdisc dumps Date: Thu, 30 Jul 2026 12:00:05 +0200 Message-ID: <20260730100006.3547944-2-reshmaisat@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260730100006.3547944-1-reshmaisat@gmail.com> References: <20260730100006.3547944-1-reshmaisat@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 tc_dump_qdisc() walks every netdev in the netns and can span many netlink batches. RTNL is only held while a single batch is filled, so devices can be registered or unregistered in between. Since 748bbef5fc6a ("net/sched: switch tc_dump_qdisc() to for_each_netdev_dump()") the walk resumes on an ifindex rather than a list position, but ifindexes are reused: a device created between two batches can be given an ifindex the dump has already walked past, and is then missed entirely. Before that commit the resume used a position in the device list, so any unregister shifted every later device and silently dropped a run of qdiscs from the reply. Unlike rtnl_dump_ifinfo(), which pairs for_each_netdev_dump() with cb->seq = dev_base_seq and nl_dump_check_consistent(), nothing under net/sched sets cb->seq at all -- and never has. NLM_F_DUMP_INTR is therefore never raised for a qdisc dump, an incomplete reply is indistinguishable from a complete one, and userspace has no way to tell it is reconciling against a partial listing. Callers already handle the flag by redoing the dump (iproute2 warns, netlink libraries retry), so raising it is enough to make this self-correcting. Use the same idiom as the link dump. Both return paths are covered, as the -EMSGSIZE path is the normal one for every batch but the last. Tested by dumping the qdiscs of 400 dummy devices (mq + 16 fq + clsact each) while unregistering devices ahead of the dump: NLM_F_DUMP_INTR is raised on 482 of 972 dumps with this patch and on 0 of 1089 without it. Signed-off-by: Reshma Sreekumar --- net/sched/sch_api.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index 668bcd60d..ab31a75fa 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c @@ -1949,12 +1949,26 @@ static int tc_dump_qdisc(struct sk_buff *skb, struct netlink_callback *cb) netdev_unlock_ops(dev); s_q_idx = 0; } - return skb->len; + err = skb->len; + goto out; error_unlock: netdev_unlock_ops(dev); ctx->q_idx = q_idx; +out: + /* RTNL is dropped between dump batches, so devices may have been + * registered or unregistered while this dump was in flight. Because + * ifindexes get reused, a device created in that window can be given an + * ifindex this dump has already walked past and be missed entirely. + * Advertise that, as rtnl_dump_ifinfo() does for RTM_GETLINK, so that + * userspace redoes the dump instead of acting on a listing that silently + * omits entries. + */ + cb->seq = READ_ONCE(net->dev_base_seq); + if (skb->len) + nl_dump_check_consistent(cb, nlmsg_hdr(skb)); + return err; } -- 2.43.0