Article View: linux.kernel.netdev
Article #10665[PATCH iproute2-main] libnetlink: handle failed time seeds and sequence wrap
From: Florian Fainelli
Date: Tue, 03 Nov 2026 21:59
Date: Tue, 03 Nov 2026 21:59
48 lines
11953 bytes
11953 bytes
A 32-bit time_t overflows when the board clock is beyond 2038. time()
returns -1, and the first request then has sequence zero. The sequence
range check underflows and discards the valid reply, leaving ip blocked
in recvmsg(). The same range check also fails on a normal counter wrap.
Use zero as a fallback seed when time() fails. Compare the unsigned
sequence distance against the number of requests, allowing wraparound
and rejecting the sequence immediately before the first request.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
lib/libnetlink.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/libnetlink.c b/lib/libnetlink.c
index edf3a8ba7ce0..5bc7c43245fb 100644
--- a/lib/libnetlink.c
+++ b/lib/libnetlink.c
@@ -194,6 +194,7 @@ int rtnl_open_byproto(struct rtnl_handle *rth, unsigned int subscriptions,
int protocol)
{
socklen_t addr_len;
+ time_t now;
int sndbuf = 32768;
int one = 1;
@@ -246,7 +247,8 @@ int rtnl_open_byproto(struct rtnl_handle *rth, unsigned int subscriptions,
rth->local.nl_family);
goto err;
}
- rth->seq = time(NULL);
+ now = time(NULL);
+ rth->seq = now == (time_t)-1 ? 0 : (__u32)now;
return 0;
err:
rtnl_close(rth);
@@ -1092,7 +1094,7 @@ next:
if (nladdr.nl_pid != 0 ||
h->nlmsg_pid != rtnl->local.nl_pid ||
- h->nlmsg_seq > seq || h->nlmsg_seq < seq - iovlen) {
+ (unsigned int)(seq - h->nlmsg_seq) >= iovlen) {
/* Don't forget to skip that message. */
status -= NLMSG_ALIGN(len);
h = (struct nlmsghdr *)((char *)h + NLMSG_ALIGN(len));
--
2.53.0
Technical Details
Message-ID:
<20261103215932.1191741-1-f.fainelli@gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-356008-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-356008-linux-kernel-netdev=dewy.ru
From: f.fainelli@gmail.com (Florian Fainelli)
Newsgroups: linux.kernel.netdev
Subject: [PATCH iproute2-main] libnetlink: handle failed time seeds and sequence wrap
Date: Tue, 3 Nov 2026 13:59:32 -0800
Organization: Usenet Network
Message-ID: <20261103215932.1191741-1-f.fainelli@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="3271388"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:A+QU+zSZqvK6Yr+zqnVfAyIfzYE= sha256:OSP5R6tn/iJ/ymh9FmGTfvaAISJP/r9oS46VGXNpzOE=
sha1:YKpx59jQsn8LJvaRhDOuQKhmjVg= sha256:oQQjDPyf9mq2QOD5pVLF/94AcFAin4UE755MPRPRPEs=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 0B551112A36; Wed, 4 Nov 2026 01:03:08 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id rHwZmg-m0Gk7;
Wed, 4 Nov 2026 01:03:05 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-356008-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
by mail.dewy.ru (Postfix) with ESMTPS id 90812112A32; Wed, 4 Nov 2026 01:02:57 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by tor.lore.kernel.org (Postfix) with ESMTP id 6F984260E8; Tue, 3 Nov 2026 22:02:29 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1793743347;
b=hsJ+uNFubji7ojWuDABw9LII37/CqOXsn8LWWsn5o2AVSEevXeH36PcPr5duP/jVrAwT
O91JeonwNhN0//P1wwWs0yQdvSOmxbQolIeTGelisWe8tncv50Tge/eYAosN6KYo3HRLF
57qBHUVB8qVDipMQgA7ANbA6vGKar/gurBViETXPyc4OjBMhraQ4HpkQAIqYKGtSNJ2qd
uw65vYNGtdOyZtiVv78jRGhU97vCmnDtrXjgxiZn0uUwL0zkkDJuWjuiop51OiDxqvHgw
d0jBYErW83Th028EzHqtbh50ScmJQgcjhqh5zhRzm9E5IIUI/5oDUtZn0+euEUMQ+4A==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793743347;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:X-Mailing-List:
List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding;
bh=0Q996RswduMpIhVsoVyPA2VHGPwwWWrs+cfGJMYGH0w=;
b=njuIH8OhMM6mvLZBwMXpH9DkU8ls45wHK7G110sWEAchtWV4iKNCYEAx5lHAQZug5fDx
lPigGUn2mZy+L7+tP73bv1ThPeOVJ5I6eGufJIAZ9/bdVwdS2Sya9alEJf+mx/leZGu4D
6ogA7nIP23D9KV+OZX7GvATPqCvkwc2Fn/DXeSpvz84PcT3mXeMoiAYiNz/T8XcHa+v7H
SWZlBYWNvJagUmtLo1YtfRUv+XHJVnl5FmWXzu1FBa+S3iyFhlK53fx7awO0q08k8VxJL
W2oV3hspD97VlhGap0CL4jdI022cTTIA89C1aC0xksSG1kw3yv3zPoJTkxtwfu8uDOQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Aog6qtnP;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 7C0CB606A32E;
Tue, 3 Nov 2026 22:02:27 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Aog6qtnP
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.176
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1793743346;
b=mTo2ZqClQgTNmrufuSjqCtMFizpKg5R30SDRnYfLCY09FAKXug1H5TySgM0ThW2uJuPN
+3GGw1Cr7CYeAXG3B3cSJ4xDg6Z851XZInFAuCy1O/zlyvzlQ1Pfpavw7IhX0T8EEKhSu
kUL9QklIU7e2FPQ4V1Hn2dBZINUWipK2gNA8dwSsWecd1U1PH4YVKojeu/bBqBdAi5CLq
GwKP9EddGK3RYuNFX2OqlId7Ql7iXGrOKBieJ/GA6HmjLCpTiug3SypyH2LZY7jm8BszP
oILZbM5Vq0GlS3Uk7MFkfBz190TIKffiFGbOCjnZQipZbe+yXWbcEvtZYaIYnj2OLZw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793743346;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
Date:Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding;
bh=0Q996RswduMpIhVsoVyPA2VHGPwwWWrs+cfGJMYGH0w=;
b=Mg2XuOzfD6eX/42wNj3kjeWiCyqIr5igaIBLTE1wfbc87yWtMThszk0DmzIlaoNfd265
PsQon4LuvU97WqqLl8AZMgxm0b+Fw/ZXMiyWen2Xjst6/n1U9ueATqWPOshwVamBjNbe/
CcHbVkRYGpAJqDnudsifImFo9d1yQve7jp+ahK1fkphJUbIKfqlt1ha4XE1tJqhyVVl3u
KSdEnJMGcwA4mg9PaP+wH2u7PoewQifuFgIIfvhcyXQYiRFcTT8BGVPitnzWUZAdsnoVq
6JykfDs1iIu8uv+j1kLDeycADEBI+/xdc4K789vwfYpFb7tNCFB2ccuXHzMf1yzBmuw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Aog6qtnP;
arc=none smtp.remote-ip=74.125.82.176
X-Received: from mail-dy1-f176.google.com (mail-dy1-f176.google.com [74.125.82.176])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4487E606A31B
for <netdev@vger.kernel.org>; Tue, 3 Nov 2026 22:02:26 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4487E606A31B
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-dy1-f176.google.com with SMTP id 5a478bee46e88-369f33df08eso18848eec.0
for <netdev@vger.kernel.org>; Tue, 03 Nov 2026 14:02:26 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1793743345; x=1794348145; 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:content-type;
bh=0Q996RswduMpIhVsoVyPA2VHGPwwWWrs+cfGJMYGH0w=;
b=Aog6qtnP0tAl7RfxxsRY+nhBR8Om1wLA7yqodbUGaCnryP65x8QfNoYRuRPx/0/8tH
n4hz/yfQlbBKdM6+NlsGtakiC3RDeAJ9JQfG8/xJKTWamfBlCIpWTj4PvwddrmR+JYv+
PgN41rauk0EjgMmaQdxlM77EKsiHubLZJsfwXbYVcTYAZLQ8WBi1aaoRGRlOW3h9Wlnd
1qVOmUI3ZjZWutQ7MzGSjevagkxa00Qje6nwdRpzeVv9ut9oXmeK567npp1Z3CwOmVWq
JDfrXXtSk1GVcuqJagWmtLZnFo/MxyiIu1FItEMYZH9NXdGsL4GxAXK+/ioe3zYl1vtQ
J+VA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1793743345; x=1794348145;
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:content-type;
bh=0Q996RswduMpIhVsoVyPA2VHGPwwWWrs+cfGJMYGH0w=;
b=kMpVMmj0dFX5YfqmCbrt7T3Lnb4yK/W82SGycrzwih2Vsj2GPLjoVD1SBQYh4BqN+w
9GxPncR6YPi9NXMiRqFNMo7Yk8VIWGa93/JLoFHjed6E4LlSSKfHQ8p8zGj5tz7CNpWF
+vuZ3y3YJmJzSvDnazMMefmOvArkuFHmS7tKRqt21ScQ7eGb7CYBvF2OrqJuY+/sqCrh
EThu02UWVAQh53bvSojuAZpsSqZsLkzKSBs6Q98gF8Al9QrPiXzM8rzCZ9rXEjTavRr2
HaH+pseRq+tOC3BMeRm8YIlrtoYZdHjdt381HHorAuS4IaptlnfCPGR/39wuqPxT0Fmb
Z2lA==
X-Gm-Message-State: APuU4Z9uMTIobjpq3UtXa80759qqK5hWdKl1Rj5JkGWLtnwMPigVxwby
ThOempL6LrBpXjb/HgvOjpowwWCTk9jpfcxU7reroW+HU/CpBtiFpQIZ4kjMfg==
X-Gm-Gg: AYBFou0agiPwoutIl4RZmN9aCgZufMrlbT9SfPd6q329lxF+iETHItMCldqUw3ti/cZ
EjY10W62L2c9xRqtfBZFgMCSaYXEIXUHnxVf+JULv1af+CsH0E/IQEBvCjXmIPfev/Is/vjMFTY
pKIUoSEevixpzRTzAaIT7g48JuTYFRK1WWER9nTDins3F+hbO4ShrkVlWEnsOb+yVT5xQk6Yg70
bjYK+MYR788bXm4B4bHn85K6oMlHhk+pKHwabCvSwBVBDwHdKpmz/Dq9UTSNYsPTD32uZZayPBl
bNqdRgkqbXhbbochHYBU3rwGeSWOa2TAauoLc0zj5ynhAnDfZ5z0NxpMPNBFE7ti0O7JvrOe9bM
IjbMbOiU1JOo0pXH9TEAMC9u1uzBJAGfWnkYmQPDxecvqApwBhxX/4GIhV1yD/ruE+QzK/X9KlY
Tao5TbMSN2kVZGXfHSBQGTVrxa1JNIQttGBqH7/5EKq48tNd3kcofxek99/MBpF8WN4W5k11AG9
5xQa5gKsdRnPr5Ig7cY6nceQ7Iq1OTkX4HqTEul/e3RN0y+w6wM1FOZy9NjVWx0VEIYYR4zT/v3
oXWNPo+2wB3PgVwsQU9uJmNSg2dR+A==
X-Received: by 2002:a05:7300:3b0c:b0:36a:238:1485 with SMTP id 5a478bee46e88-36a4244276cmr30366729eec.37.1793743345194;
Tue, 03 Nov 2026 14:02:25 -0800 (PST)
X-Received: from eldorado ([2600:8802:b00:1f88::287])
by smtp.gmail.com with ESMTPSA id 5a478bee46e88-36ca39c5f0csm808541eec.29.2026.11.03.14.02.24
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Tue, 03 Nov 2026 14:02:24 -0800 (PST)
X-Cc: stephen@networkplumber.org,
dsahern@kernel.org,
Florian Fainelli <f.fainelli@gmail.com>
X-Mailer: git-send-email 2.53.0
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list