diff options
| author | David S. Miller <[email protected]> | 2023-05-15 10:21:21 +0100 | 
|---|---|---|
| committer | David S. Miller <[email protected]> | 2023-05-15 10:21:21 +0100 | 
| commit | d1b2777d1467a3aa86d403492cc0411bf429dbe4 (patch) | |
| tree | ab4a17e1ba482527d1a03d895bfb776f7e73f8b8 /net/tipc/bearer.c | |
| parent | b48a18644046c9bc0667493a147dfa01e8241eab (diff) | |
| parent | 35a089b5d793d2bfd2cc7cfa6104545184de2ce7 (diff) | |
Merge branch 'tipc-fixes'
Xin Long says:
====================
tipc: fix the mtu update in link mtu negotiation
This patchset fixes a crash caused by a too small MTU carried in the
activate msg. Note that as such malicious packet does not exist in
the normal env, the fix won't break any application
The 1st patch introduces a function to calculate the minimum MTU for
the bearer, and the 2nd patch fixes the crash with this helper. While
at it, the 3rd patch fixes the udp bearer mtu update by netlink with
this helper.
====================
Reviewed-by: Tung Nguyen <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
Diffstat (limited to 'net/tipc/bearer.c')
| -rw-r--r-- | net/tipc/bearer.c | 17 | 
1 files changed, 15 insertions, 2 deletions
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 35cac7733fd3..53881406e200 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c @@ -541,6 +541,19 @@ int tipc_bearer_mtu(struct net *net, u32 bearer_id)  	return mtu;  } +int tipc_bearer_min_mtu(struct net *net, u32 bearer_id) +{ +	int mtu = TIPC_MIN_BEARER_MTU; +	struct tipc_bearer *b; + +	rcu_read_lock(); +	b = bearer_get(net, bearer_id); +	if (b) +		mtu += b->encap_hlen; +	rcu_read_unlock(); +	return mtu; +} +  /* tipc_bearer_xmit_skb - sends buffer to destination over bearer   */  void tipc_bearer_xmit_skb(struct net *net, u32 bearer_id, @@ -1138,8 +1151,8 @@ int __tipc_nl_bearer_set(struct sk_buff *skb, struct genl_info *info)  				return -EINVAL;  			}  #ifdef CONFIG_TIPC_MEDIA_UDP -			if (tipc_udp_mtu_bad(nla_get_u32 -					     (props[TIPC_NLA_PROP_MTU]))) { +			if (nla_get_u32(props[TIPC_NLA_PROP_MTU]) < +			    b->encap_hlen + TIPC_MIN_BEARER_MTU) {  				NL_SET_ERR_MSG(info->extack,  					       "MTU value is out-of-range");  				return -EINVAL;  |