🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #20640

Re: [PATCH net v2] ipv6: fix ioam6_id_wide sysctl on 32-bit architectures

#20640
From: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 01:40
170 lines
13578 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] proc_ioam6_id_wide() (net/ipv6/sysctl_net_ipv6.c) changes how
  writes are parsed on 64-bit in several ways the commit body does not…
- [Low] proc_ioam6_id_wide() passes a temporary ctl_table `tmp` with only
  .data and .maxlen set to proc_dostring().

--

ipv6: fix ioam6_id_wide sysctl on 32-bit architectures

net.ipv6.ioam6_id_wide was handled by proc_doulongvec_minmax(). This
commit replaces that with a local handler, proc_ioam6_id_wide(), which
formats and parses the u64 through proc_dostring() and kstrtou64(). This
fixes 32-bit architectures, where unsigned long is 4 bytes and the old
handler treated the u64 as a vector of two 32-bit values.

> diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
> index 1a0a36dcdabc1..61c28df64d582 100644
> --- a/net/ipv6/sysctl_net_ipv6.c
> +++ b/net/ipv6/sysctl_net_ipv6.c
> @@ -30,6 +30,48 @@ static u32 rt6_multipath_hash_fields_all_mask =
>  static u32 ioam6_id_max = IOAM6_DEFAULT_ID;
>  static u64 ioam6_id_wide_max = IOAM6_DEFAULT_ID_WIDE;
>  
> +/* unsigned long is 32-bit on some arches, so handle the u64 here */
> +static int proc_ioam6_id_wide(const struct ctl_table *table, int write,
> +			      void *buffer, size_t *lenp, loff_t *ppos)
> +{
> +	u64 *valp = table->data;
> +	char buf[24] = "";
> +	const struct ctl_table tmp = {
> +		.data	= buf,
> +		.maxlen	= sizeof(buf),
> +	};

[Severity: Low]

The temporary table passed to proc_dostring() has no procname. Will the
sysctl write warning then print "(null)" instead of ioam6_id_wide?

On every write, proc_dostring() calls:

kernel/sysctl.c:proc_dostring() {
	if (SYSCTL_USER_TO_KERN(dir))
		proc_first_pos_non_zero_ignore(ppos, table);
    ...
}

Take kernel.sysctl_writes_strict=0 and a write shorter than 24 bytes at
a non-zero offset. That write reaches warn_sysctl_write(&tmp):

	pr_warn_once("%s wrote to %s when file position was not 0!\n"
		[ ... ]
		current->comm, table->procname);

This is pr_warn_once(), so a message that doesn't name the file would
use up the only warning for the whole system. The old
proc_doulongvec_minmax() path passed the real table here.

Would adding .procname = table->procname to tmp be enough?

> +	loff_t pos = *ppos;
> +	u64 val;
> +	int ret;
> +
> +	if (!write) {
> +		snprintf(buf, sizeof(buf), "%llu", READ_ONCE(*valp));
> +		return proc_dostring(&tmp, write, buffer, lenp, ppos);
> +	}
> +
> +	/* an empty write changes nothing, as with proc_doulongvec_minmax() */
> +	if (!*lenp)
> +		return 0;
> +
> +	/* proc_dostring() would silently truncate a longer input */
> +	if (*lenp >= sizeof(buf))
> +		return -EINVAL;
> +
> +	ret = proc_dostring(&tmp, write, buffer, lenp, ppos);
> +	if (ret)
> +		return ret;
> +
> +	/* a lone "\n" is invalid, a continued write in strict mode is ignored */
> +	if (!buf[0])
> +		return pos ? 0 : -EINVAL;
> +
> +	if (kstrtou64(strim(buf), 0, &val) || val > ioam6_id_wide_max)
> +		return -EINVAL;

[Severity: Medium]

The commit message says:

  One change on 64-bit: a write of two numbers such as "5 6" is now
  rejected with -EINVAL, instead of being a partial write that sets the
  value to 5.

Does proc_ioam6_id_wide() change 64-bit behaviour in other ways that
should be listed too?

The length guard checks the total write size. But _proc_do_string()
copies at most maxlen - 1 bytes and stops at the first '\n' or NUL:

kernel/sysctl.c:_proc_do_string() {
    ...
		while ((p - buffer) < *lenp && len < maxlen - 1) {
			c = *(p++);
			if (c == 0 || c == '\n')
				break;
			data[len++] = c;
		}
    ...
}

So a 24-byte write of 23 characters plus "\n" fits in buf without being
truncated, yet the guard rejects it. The guard also rejects "5\n"
followed by 22 or more bytes, and a value padded with 24 or more bytes
of whitespace. The old path accepted all of these, fully or as a partial
write.

Is the comment "proc_dostring() would silently truncate a longer input"
accurate for these cases?

In strict mode, a continued write at a non-zero offset now returns
-EINVAL if it is 24 bytes or longer, and is ignored if it is shorter.
The old proc_first_pos_non_zero_ignore() path ignored it at any length.

Because _proc_do_string() stops at the first '\n', "\n5" or " \n 5"
leaves buf empty and returns -EINVAL. The old path skipped the newline
in proc_skip_spaces() and set 5.

In the other direction, "5\n6" now succeeds, sets 5 and reports all
bytes consumed. Meanwhile "5 6" and "5\t6" return -EINVAL.

kstrtou64() also skips a leading '+', so "+5" is now accepted. The old
path rejected it in proc_get_long():

	if (!isdigit(*p))
		return -EINVAL;

Two other changes are only described below the --- line, so they won't
reach git history: 21 to 23 digit input is now accepted, and a lone "\n"
at a non-zero offset in non-strict mode is now ignored.

Could the up-front total length check be dropped? After proc_dostring(),
the handler could check whether a terminator was found within
maxlen - 1 bytes, and decide explicitly whether data after '\n' is
rejected. Any 64-bit changes that remain could then go in the commit
body.

> +
> +	WRITE_ONCE(*valp, val);
> +	return 0;
> +}

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261122013848.14287-1-jain.sm%40gmail.com
Technical Details
Message-ID: <179539800944.3135.14978978337031412574@kernel.org>
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368943-linux-kernel-netdev=dewy.ru
References: <20261122013848.14287-1-jain.sm@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368943-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2] ipv6: fix ioam6_id_wide sysctl on 32-bit architectures
Date: Mon, 23 Nov 2026 01:40:09 +0000
Organization: Usenet Network
Message-ID: <179539800944.3135.14978978337031412574@kernel.org>
References: <20261122013848.14287-1-jain.sm@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3764845"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:4Ui1E+eNky8y1pGU0tjonpRtm0Y= sha256:61roxX9XgnYKusobmFxh25QPa0YsobrcX8xkJX5ba1A=
	sha1:gNl53iG9iVrba5LcAf7Xa4Jh8q8= sha256:GQ/nNi+LfWQuLPlW5Foqgt8Cm2TgXtQWHEJp8WmIZPk=
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 9F46F125D87; Mon, 23 Nov 2026 04:40:36 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
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 IASotEHEfoA8;
	Mon, 23 Nov 2026 04:40:32 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-368943-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 8ACAB125D8A; Mon, 23 Nov 2026 04:40:24 +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 4D20728D75; Mon, 23 Nov 2026 01:40:20 +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=1795398016;
	b=zuBhT28JpuOdNUZD3euzRWJEddpYSjxhLBTLeNybaj4q5Fk64VX/LhaoVMxRkqPnRIeI
	 g/MUXkz9nf2TYrWJeoCSL9skzD/QU/T61k0QvunZFXW1H0c4nCqCOvftejFrrorug1CVh
	 JiX415M5JIJvFngxrg1JmKR/Q5Or8w23h7jvHYSnaAweGP7ns9tdJjTxoZZQXnFpPndFR
	 2oDE3lkG6M4vx9xQBZB26u/wQgoVACw6fnGd8sOP77SYsLKvIJp2ZvPSS0oULxMz+b6mY
	 yQg/osVcrX57oMqNvhuTMbKmUAq4LjGm2taKzwSYALT7JiKxGZOzYa9LabOtszDOmAA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795398016;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=y89p4Zfp3vjpcB8k1IxkJ///JSjR1z1U+uhQSBuiQGA=;
	b=vVbN0S9DQPgxWdVnJwBGKSEhiZAK1gwt7tNM76YBh7lhDOHClyzTmOVV/3xgu/vZTdEm
	 RXAIJh2/BHACkP+Sb+T02A3DYgwpueDEYZV1Y868B2QlRFHxVC7LdCQ6pSKAwDd4T0dNv
	 F8/IKl/lh8keNc64ulLRL14ej5B4W5a5fqZ6EZB35A4s+42kq0ENFTrQrLwN60NtqnXe3
	 9vWrFv5gLjSXzYat5+E+CZ6Bg+4VgPCW1xJ4T+MGr1xW7uAwFhGGjNYn4IkTM0OvfJimn
	 Pc+kZof5tRf2itIROmyeJz3nHbX7AQA0mwz+N6Y2JsKl1WPqKjj01fuSXbYH1RaBriw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FFxI34y5;
	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 A0AC0606A334;
	Mon, 23 Nov 2026 01:40:16 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FFxI34y5
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795398010;
	b=14fn4ZA94PcQZlABmp3Y09p531dOjMt/NBK/lXO649hktfOWGBkarArt+hnaallMAHzS
	 QmPAIVjPveYm3p6LXLnLY8bpGGU+0ZFPZLqghqH+srloMbxP+aJkugxSn7Hk/LlQdzVEV
	 d+sAls03rd7LXjNRX7KnuvbLHSPhjJxsZ7sD+JKwsJAVVNXsvQACJzCOktr8QBTc/xtwM
	 68HuHOAyAAT4E67See4bcczNM2mvXedyNyLeFAfx+Id+Hv5Y/4IUOZMFq+W6k9ZlQyXcP
	 R7Uml5fUvZccB3+FvThTqJSe9NHIzyXeREpXZZxoNcZ91mJMJWR4PpMlFDZTzay91JQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795398010;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=y89p4Zfp3vjpcB8k1IxkJ///JSjR1z1U+uhQSBuiQGA=;
	b=S7xwHRcvk5oPrUykLJKO4yG+SUeiD4ZcOvLFMQZyq62IUB/MMuXrFmdX28Jg0wj2+u62
	 tViAWrNw8IdBcKK6U9rNPPz7T9xxFBcuRGaDQcTxnDARJ/asp/0S6nsKRy+RqfUID9A7+
	 wkJaSykvgxW8BbzhUkdJfu3iQ0FjnZaF1J6p1leE4KaJm2kx8X7l8EEl+DgjSiVs45NUX
	 tZf1+QGOjhXBaxs2DEzZk5hHFvxMBYBQMlEjyoymvvDLnS/9Cz1oC5zIQBsZT4nIkm2Am
	 3A91j7pKBAblTeorX7dbvjqJrsw4H2l+Igq5YkFV5J8PRwt4seIY84obPkXDorX6K9A==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FFxI34y5;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id BEFFE606A681;
	Mon, 23 Nov 2026 01:40:10 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3D9C1F000C0;
	Mon, 23 Nov 2026 01:40:09 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795398010;
	bh=y89p4Zfp3vjpcB8k1IxkJ///JSjR1z1U+uhQSBuiQGA=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=FFxI34y5GtZr6CUsawb3gkCSqiCeap6v7VnzXzALiAqSh9wCziAo94IfgkhRTuIge
	 yxkbk+qAXh2gh93bulEqxWXjxLwdG8gUO/4FxucytAvn8K1Qa/Dmf2EZZSUvX9OI2g
	 SK5QL/yBzm93ZRmzX8hy00rTfm93fggrks+PHk9FQclSfGzWawBHbkBC2tj1yUUrmZ
	 z7uoy1yt1CvTMqkrNsUOdQoXu6iJbKEwgjDy4Xso9FJfXOWSOPLl7w0vusMAmF0b/8
	 1hL+o3t+TfVn8wF4mwrpVW2y5lsciPJ8mufZ6XATmeWVEGQxzCrf6ddD4uxVPHgVJW
	 wQZTUaXresW6A==
X-Cc: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
 pabeni@redhat.com, justin.iurman@gmail.com, horms@kernel.org,
 joel.granados@kernel.org, netdev@vger.kernel.org,
 linux-kernel@vger.kernel.org
X-In-Reply-To: <20261122013848.14287-1-jain.sm@gmail.com>
X-sashiko-severity: Medium
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