From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f173.google.com (mail-dy1-f173.google.com [74.125.82.173]) (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 BE1214779BD for ; Wed, 1 Apr 2026 14:53:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775055227; cv=none; b=I6EvJJ4hesWzPsWKtrO6BCuCQ2p1zPnHXlXybzwwUMjZCdfuNkKVkqxWW1y19agJBVCKdnCvjfUoNMhr2mYvSugZvp8E3/e0YHqdypwBn/rgBQwmDEoFn6Y53RvgZ7CVQsR7QWlEzk9vMO+TIQLE/8squfoK3LdvMIsudYMchII= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775055227; c=relaxed/simple; bh=WWc2WPGjnLDzGTWjnud0UH8yc9NV/+PJ1u9AIBSpiuQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TIhsm1PhIzzJjndzHSSnFsAj/AlejCCU5PsU1i0lyENF6GtpzfMI/MaESrjx+sNcp68ARfXWg6WnJnIBTT7qguUPGRbZlv36cVIkWeQlLJNvbVbC62uKGyX7kL7PGV0rF0d2+mguSJXi641GYhAgcwMED9myvhvq0MUGSNeToq4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=networkplumber.org; spf=pass smtp.mailfrom=networkplumber.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20230601.gappssmtp.com header.i=@networkplumber-org.20230601.gappssmtp.com header.b=rYE0InF1; arc=none smtp.client-ip=74.125.82.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20230601.gappssmtp.com header.i=@networkplumber-org.20230601.gappssmtp.com header.b="rYE0InF1" Received: by mail-dy1-f173.google.com with SMTP id 5a478bee46e88-2b4520f6b32so7856383eec.0 for ; Wed, 01 Apr 2026 07:53:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1775055225; x=1775660025; 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=TQkiQzykTuUlpr+LQhcAQNW1WP+8TnEM/NAdEMX1s/E=; b=rYE0InF17Hjcx9fw2kc66jzuRzXSqydwDfgGgy3y8voUavGZI7T/CikDhEVcgfekMc uIvazRJ0S6o+SN86qvoQjLaVKMXp+NTy2Flm0V6OvZTDK5AWw+OJeDRkr0fD6ukYPydx acIDiEq6V4TskpjXgw9L8AwiiweMEcWup95MFa0Jrzbq/A4mY4/5Aut/6v4uhoyAaZxN xeMyv7vl6qgk5l0lD3MCcKHAgoEIWNnOU2eAJwcSiv0kW+JCueL/2y24+sIpB2RvYcl6 2AIDgpReKrUTFn5jk36xqW+8bPcOi9NarnElc77Xu4yno/Ft4kHE+IbJFKqXdXpgRgLQ r44Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775055225; x=1775660025; 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=TQkiQzykTuUlpr+LQhcAQNW1WP+8TnEM/NAdEMX1s/E=; b=ouYHsNh9ump7/qt17dNHTa86h8kVaiujPnFKFybh/omufxkvAscw/x1sIU0QyHzhFI fuE6Oh6spHd6/SPmN05kWNnpIhnQLBveL0icDwO+HsHZ5SHGtE57yPguHBGpgRwuDM62 L/xhsz15n2f4qrOrryee7hvtTB8Y8F+UIzQhzEdUQI/egc0wnpigMj56YxoEqzwarUFk 0F77ZESpOECbKDspIyWLnTmiOjEXI9k6chXVWHV41FoYlO7uFiaSo3KUtTDAHnlYQwYG chrhHd/37rWYAbQ5j98WqRu3kqo4AqVp7kXrXxNA2aPnOUTU2pcz6oeDUbvpqTn2meMx NQfQ== X-Forwarded-Encrypted: i=1; AJvYcCVleRMb4BpPceJ9VVI9g0ID3U3+byf4yeMcz2AfpqF7ccIGIbscJ0kmuT7oBphrGAZ8IWf2KjU5EutMA/8=@vger.kernel.org X-Gm-Message-State: AOJu0YxQtWFaKs8yTHBX27f+guo0rly+8UmIzom7Faq2X4zWohKn52eI N/nQ3sxKhNU374dFJr5npC0Q2I0bxwUKMafhGFWL0CTyv+/cHa2DtgNJu5ZlxXtChog= X-Gm-Gg: ATEYQzy5nRZFZZ6dl6qIejvG1hbACqtZBiREVfDFHiDPrOgBaboYILrl7a/h/CHgIyQ p0b2PGfGeeuAeWi3zop+6piZYyElDTwpU/G9R+0U5/JSyknUuAC2eWvk7ZEkCtXV45ZhSvT0A/P IfvYG3x9cFxrVoNJGednBrdKJTBYmxbHjOsLdDRQH0uZlfOPaoAqe4xLX7sdZDxJKJYVxg7SATl PK7GqsJXJcJhb4Ld1H087tTuMAVbz7x0oZos1AkbygI6SoDykxJZhVi8h5I7xcHzUf4wngHT67l Y7EEtthFODi+4llQNz4XsDU0ZM7ysR9zLQZKygqrnpLJubj1ZR/M+/0BUm86X/HZvIxJuqYps70 k9THg+48peXw7/peWmy5Y3+oAXoTnH3IzXhb4u9opIP1M0EbLi7RiMwUHhivz2gXtP+Iee1b93C frPGPNN38OGgeOwUTQ/NPf0uItyPLEEH6x X-Received: by 2002:a05:7300:2291:b0:2ca:2f21:64da with SMTP id 5a478bee46e88-2ca2f217676mr396507eec.0.1775055224489; Wed, 01 Apr 2026 07:53:44 -0700 (PDT) Received: from phoenix.lan ([104.202.41.210]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2c3c3bda13csm12804830eec.6.2026.04.01.07.53.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Apr 2026 07:53:44 -0700 (PDT) From: Stephen Hemminger To: netdev@vger.kernel.org Cc: Stephen Hemminger , Jamal Hadi Salim , Jiri Pirko , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Yousuk Seung , Neal Cardwell , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net v2 7/7] net/sched: netem: fix slot delay calculation overflow Date: Wed, 1 Apr 2026 07:51:59 -0700 Message-ID: <20260401145332.78285-8-stephen@networkplumber.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260401145332.78285-1-stephen@networkplumber.org> References: <20260401145332.78285-1-stephen@networkplumber.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit get_slot_next() computes a random delay between min_delay and max_delay using: get_random_u32() * (max_delay - min_delay) >> 32 This overflows signed 64-bit arithmetic when the delay range exceeds approximately 2.1 seconds (2^31 nanoseconds), producing a negative result that effectively disables slot-based pacing. This is a realistic configuration for WAN emulation (e.g., slot 1s 5s). Use mul_u64_u32_shr() which handles the widening multiply without overflow. Fixes: 0a9fe5c375b5 ("netem: slotting with non-uniform distribution") Signed-off-by: Stephen Hemminger --- net/sched/sch_netem.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c index ca4de7ae6f2f..5f497fc544ea 100644 --- a/net/sched/sch_netem.c +++ b/net/sched/sch_netem.c @@ -659,9 +659,8 @@ static void get_slot_next(struct netem_sched_data *q, u64 now) if (!q->slot_dist) next_delay = q->slot_config.min_delay + - (get_random_u32() * - (q->slot_config.max_delay - - q->slot_config.min_delay) >> 32); + mul_u64_u32_shr(q->slot_config.max_delay - q->slot_config.min_delay, + get_random_u32(), 32); else next_delay = tabledist(q->slot_config.dist_delay, (s32)(q->slot_config.dist_jitter), -- 2.53.0