Messages in this thread | | | Date | Thu, 28 Jul 2022 15:12:16 +0200 | From | Andrew Lunn <> | Subject | Re: [RFC 1/1] net: introduce OpenVPN Data Channel Offload (ovpn-dco) |
| |
On Thu, Jul 28, 2022 at 09:44:18AM +0200, Antonio Quartulli wrote: > Hi, > > On 19/07/2022 17:37, Andrew Lunn wrote: > > > +static int ovpn_net_change_mtu(struct net_device *dev, int new_mtu) > > > +{ > > > + if (new_mtu < IPV4_MIN_MTU || > > > + new_mtu + dev->hard_header_len > IP_MAX_MTU) > > > + return -EINVAL; > > > > If you set dev->min_mtu and dev->max_mtu, the core will validate this > > for you, see dev_validate_mtu(). > > Yeah, thanks for the pointer. > > > > > > +static int ovpn_get_link_ksettings(struct net_device *dev, > > > + struct ethtool_link_ksettings *cmd) > > > +{ > > > + ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported, 0); > > > + ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising, 0); > > > > These two should not be needed. Look at tun, veth etc, they don't set > > them. > > I found this in tun.c: > > 3512 ethtool_link_ksettings_zero_link_mode(cmd, supported); > 3513 ethtool_link_ksettings_zero_link_mode(cmd, advertising); > > Which seems a more appropriate version of my code, no?
I would trace is backwards. Where is cmd coming from? In order to avoid unintentional information leaks, the core should be clearing any memory which gets passed to a driver which might optionally be filled in and then returned to user space. So take a look in net/ethtool, and see if there is a memset() or a kzalloc() etc. If it is already been zero'ed, you don't need this.
Andrew
| |