The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Vadim Fedorenko <vadim.fedorenko@linux.dev>
To: Tung Quang Nguyen <tung.quang.nguyen@est.tech>,
	"Cen Zhang (Microsoft)" <blbllhy@gmail.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"tipc-discussion@lists.sourceforge.net"
	<tipc-discussion@lists.sourceforge.net>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"AutonomousCodeSecurity@microsoft.com"
	<AutonomousCodeSecurity@microsoft.com>,
	"tgopinath@linux.microsoft.com" <tgopinath@linux.microsoft.com>,
	"kys@microsoft.com" <kys@microsoft.com>,
	"jmaloy@redhat.com" <jmaloy@redhat.com>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"edumazet@google.com" <edumazet@google.com>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"pabeni@redhat.com" <pabeni@redhat.com>,
	"horms@kernel.org" <horms@kernel.org>
Subject: Re: [PATCH net v4] tipc: fix u16 MTU truncation in media and bearer MTU validation
Date: Fri, 10 Jul 2026 15:02:51 +0100	[thread overview]
Message-ID: <a5bc092d-3312-4b1c-94cc-4a8bed6c6588@linux.dev> (raw)
In-Reply-To: <GV1P189MB1988A52C474B5F7D7A9EC00CC6FD2@GV1P189MB1988.EURP189.PROD.OUTLOOK.COM>

On 10/07/2026 13:57, Tung Quang Nguyen wrote:
>> Subject: [PATCH net v4] tipc: fix u16 MTU truncation in media and bearer MTU
>> validation
>>
>> Both TIPC_NL_MEDIA_SET and TIPC_NL_BEARER_SET accept user-supplied
>> MTU values but only enforce a minimum bound, not a maximum. When a user
>> sets the MTU to a value exceeding U16_MAX (65535), it passes validation but is
>> silently truncated when assigned to u16 fields l->mtu and
>> l->advertised_mtu in tipc_link_create(). Values like 65536 (0x10000)
>> truncate to 0, causing a division by zero in tipc_link_set_queue_limits() which
>> computes TIPC_MAX_PUBL / (l->mtu / ITEM_SIZE). Other overflowing values
>> (e.g. 65537-131071) produce small incorrect MTU values, resulting in link
>> malfunction behaviors.
> 
> Yes, this is a bug. I can reproduce the same div-by-zero.
> 
>>
>> Crash stack (triggered as unprivileged user via user namespace):
>>
>>   tipc_link_set_queue_limits  net/tipc/link.c:2531
>>   tipc_link_create            net/tipc/link.c:520
>>   tipc_node_check_dest        net/tipc/node.c:1279
>>   tipc_disc_rcv               net/tipc/discover.c:252
>>   tipc_rcv                    net/tipc/node.c:2129
>>   tipc_udp_recv               net/tipc/udp_media.c:392
>>
>> Two independent paths lack the upper bound check:
>> 1. tipc_udp_mtu_bad() -- called from __tipc_nl_media_set() (MEDIA_SET) 2.
>> inline check in __tipc_nl_bearer_set() at bearer.c:1160 (BEARER_SET)
>>
>> Fix both by rejecting MTU values above U16_MAX.
>>
>> Fixes: 901271e0403a ("tipc: implement configuration of UDP media MTU")
>> Reported-by: AutonomousCodeSecurity@microsoft.com
>> Closes: https://lore.kernel.org/all/CAB8m9WgETt0AjmFwE=F-
>> CKjGXsK6_WDv0=kbYRcC8-noo+amnA@mail.gmail.com
>> Signed-off-by: Cen Zhang (Microsoft) <blbllhy@gmail.com>
>> ---
>> v4: Add .min check value
>> v3: Use nla_policy check to limit MTU max value as suggested by Vadim
>> v2: Solved format issue
>> Link: https://lore.kernel.org/all/CAB8m9WgETt0AjmFwE=F-
>> CKjGXsK6_WDv0=kbYRcC8-noo+amnA@mail.gmail.com
>>
>> net/tipc/netlink.c | 7 ++++++-
>> 1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/net/tipc/netlink.c b/net/tipc/netlink.c index
>> 8336a9664703..811438c44542 100644
>> --- a/net/tipc/netlink.c
>> +++ b/net/tipc/netlink.c
>> @@ -113,12 +113,17 @@ const struct nla_policy
>> tipc_nl_node_policy[TIPC_NLA_NODE_MAX + 1] = {  };
>>
>> /* Properties valid for media, bearer and link */
>> +static const struct netlink_range_validation tipc_nl_mtu_range = {
>> +	.min = TIPC_MIN_BEARER_MTU,
> 
> Adding lower threshold checking introduces two issues:
> 1. Existing function tipc_udp_mtu_bad() can never return "true".

it can. if MTU is in the range [TIPC_MIN_BEARER_MTU, TIPC_MIN_BEARER_MTU 
+ sizeof(iphdr) + sizeof(udphdr)]

> 2. Breaking user-space applications looking for error message " Error: MTU value is out-of-range". Look at the error messages before and after your patch:
> [Before patch]
> node1 ~ # tipc bearer set mtu 15 media udp name UDP0
> Error: MTU value is out-of-range.
> kernel answers: Invalid argument
> 
> [After  patch]
> node1 ~ # tipc bearer set mtu 15 media udp name UDP0
> kernel answers: Numerical result out of range

that's interesting, because this error message belongs to 9p scope...

anyways, we can keep v3 of this patch with .max value set only


> 
>> +	.max = U16_MAX,
>> +};
>> +
>> const struct nla_policy tipc_nl_prop_policy[TIPC_NLA_PROP_MAX + 1] = {
>> 	[TIPC_NLA_PROP_UNSPEC]		= { .type = NLA_UNSPEC },
>> 	[TIPC_NLA_PROP_PRIO]		= { .type = NLA_U32 },
>> 	[TIPC_NLA_PROP_TOL]		= { .type = NLA_U32 },
>> 	[TIPC_NLA_PROP_WIN]		= { .type = NLA_U32 },
>> -	[TIPC_NLA_PROP_MTU]		= { .type = NLA_U32 },
>> +	[TIPC_NLA_PROP_MTU]		=
>> NLA_POLICY_FULL_RANGE(NLA_U32, &tipc_nl_mtu_range),
>> 	[TIPC_NLA_PROP_BROADCAST]	= { .type = NLA_U32 },
>> 	[TIPC_NLA_PROP_BROADCAST_RATIO]	= { .type = NLA_U32 }
>> };
>> --
>> 2.53.0
> 


  reply	other threads:[~2026-07-10 14:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09 21:16 [PATCH net v4] tipc: fix u16 MTU truncation in media and bearer MTU validation Cen Zhang (Microsoft)
2026-07-10 12:12 ` Vadim Fedorenko
2026-07-10 12:57 ` Tung Quang Nguyen
2026-07-10 14:02   ` Vadim Fedorenko [this message]
2026-07-10 14:23     ` Tung Quang Nguyen
2026-07-10 16:34 ` Andrew Lunn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a5bc092d-3312-4b1c-94cc-4a8bed6c6588@linux.dev \
    --to=vadim.fedorenko@linux.dev \
    --cc=AutonomousCodeSecurity@microsoft.com \
    --cc=blbllhy@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jmaloy@redhat.com \
    --cc=kuba@kernel.org \
    --cc=kys@microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=tgopinath@linux.microsoft.com \
    --cc=tipc-discussion@lists.sourceforge.net \
    --cc=tung.quang.nguyen@est.tech \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox