Skip to content

Commit f02334a

Browse files
occiagregkh
authored andcommitted
tipc: fix u16 MTU truncation in media and bearer MTU validation
[ Upstream commit 9f29cd8 ] 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. 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: 901271e ("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 Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev> Signed-off-by: Cen Zhang (Microsoft) <blbllhy@gmail.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20260714041541.307702-1-blbllhy@gmail.com Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 9249274 commit f02334a

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

net/tipc/netlink.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,16 @@ const struct nla_policy tipc_nl_node_policy[TIPC_NLA_NODE_MAX + 1] = {
113113
};
114114

115115
/* Properties valid for media, bearer and link */
116+
static struct netlink_range_validation tipc_nl_mtu_range = {
117+
.max = U16_MAX,
118+
};
119+
116120
const struct nla_policy tipc_nl_prop_policy[TIPC_NLA_PROP_MAX + 1] = {
117121
[TIPC_NLA_PROP_UNSPEC] = { .type = NLA_UNSPEC },
118122
[TIPC_NLA_PROP_PRIO] = { .type = NLA_U32 },
119123
[TIPC_NLA_PROP_TOL] = { .type = NLA_U32 },
120124
[TIPC_NLA_PROP_WIN] = { .type = NLA_U32 },
121-
[TIPC_NLA_PROP_MTU] = { .type = NLA_U32 },
125+
[TIPC_NLA_PROP_MTU] = NLA_POLICY_FULL_RANGE(NLA_U32, &tipc_nl_mtu_range),
122126
[TIPC_NLA_PROP_BROADCAST] = { .type = NLA_U32 },
123127
[TIPC_NLA_PROP_BROADCAST_RATIO] = { .type = NLA_U32 }
124128
};

0 commit comments

Comments
 (0)