06 Jan, 2021

1 commit

  • [ Upstream commit efb796f5571f030743e1d9c662cdebdad724f8c5 ]

    Syzbot reported a shift of a u32 by more than 31 in strset_parse_request()
    which is undefined behavior. This is caused by range check of string set id
    using variable ret (which is always 0 at this point) instead of id (string
    set id from request).

    Fixes: 71921690f974 ("ethtool: provide string sets with STRSET_GET request")
    Reported-by: syzbot+96523fb438937cd01220@syzkaller.appspotmail.com
    Signed-off-by: Michal Kubecek
    Link: https://lore.kernel.org/r/b54ed5c5fd972a59afea3e1badfb36d86df68799.1607952208.git.mkubecek@suse.cz
    Signed-off-by: Jakub Kicinski
    Signed-off-by: Greg Kroah-Hartman

    Michal Kubecek
     

09 Oct, 2020

1 commit

  • The ETHTOOL_A_STRSET_COUNTS_ONLY flag attribute was previously
    not allowed to be used, but now due to the policy size reduction
    we would access the tb[] array out of bounds since we tried to
    check for the attribute despite it not being accepted.

    Fix both issues by adding it correctly to the appropriate policy.

    Fixes: ff419afa4310 ("ethtool: trim policy tables")
    Fixes: 71921690f974 ("ethtool: provide string sets with STRSET_GET request")
    Reported-by: Leon Romanovsky
    Signed-off-by: Johannes Berg
    Tested-by: Leon Romanovsky
    Reviewed-by: Jakub Kicinski
    Signed-off-by: Jakub Kicinski

    Johannes Berg
     

06 Oct, 2020

3 commits

  • To get the most out of parsing by the core, and to allow dumping
    full policies we need to specify which policy applies to nested
    attrs. For headers it's ethnl_header_policy.

    $ sed -i 's@\(ETHTOOL_A_.*HEADER\].*=\) { .type = NLA_NESTED },@\1\n\t\tNLA_POLICY_NESTED(ethnl_header_policy),@' net/ethtool/*

    Signed-off-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Jakub Kicinski
     
  • Since ethtool uses strict attribute validation there's no need
    to initialize all attributes in policy tables. 0 is NLA_UNSPEC
    which is going to be rejected. Remove the NLA_REJECTs.

    Similarly attributes above maxattrs are rejected, so there's
    no need to always size the policy tables to ETHTOOL_A_..._MAX.

    v2: - new patch

    Suggested-by: Johannes Berg
    Signed-off-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Jakub Kicinski
     
  • Wire up policies for get commands in struct nla_policy of the ethtool
    family. Make use of genetlink code attr validation and parsing, as well
    as allow dumping policies to user space.

    For every ETHTOOL_MSG_*_GET:
    - add 'ethnl_' prefix to policy name
    - add extern declaration in net/ethtool/netlink.h
    - wire up the policy & attr in ethtool_genl_ops[].
    - remove .request_policy and .max_attr from ethnl_request_ops.

    Obviously core only records the first "layer" of parsed attrs
    so we still need to parse the sub-attrs of the nested header
    attribute.

    v2:
    - merge of patches 1 and 2 from v1
    - remove stray empty lines in ops
    - also remove .max_attr

    Signed-off-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Jakub Kicinski
     

11 Jul, 2020

1 commit

  • Add an interface to report offloaded UDP ports via ethtool netlink.

    Now that core takes care of tracking which UDP tunnel ports the NICs
    are aware of we can quite easily export this information out to
    user space.

    The responsibility of writing the netlink dumps is split between
    ethtool code and udp_tunnel_nic.c - since udp_tunnel module may
    not always be loaded, yet we should always report the capabilities
    of the NIC.

    $ ethtool --show-tunnels eth0
    Tunnel information for eth0:
    UDP port table 0:
    Size: 4
    Types: vxlan
    No entries
    UDP port table 1:
    Size: 4
    Types: geneve, vxlan-gpe
    Entries (1):
    port 1230, vxlan-gpe

    v4:
    - back to v2, build fix is now directly in udp_tunnel.h
    v3:
    - don't compile ETHTOOL_MSG_TUNNEL_INFO_GET in if CONFIG_INET
    not set.
    v2:
    - fix string set count,
    - reorder enums in the uAPI,
    - fix type of ETHTOOL_A_TUNNEL_UDP_TABLE_TYPES to bitset
    in docs and comments.

    Signed-off-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Jakub Kicinski
     

09 Jul, 2020

1 commit

  • Now that we have moved the PHY ethtool statistics to be dynamically
    registered, we no longer need to inline those for ethtool. This used to
    be done to avoid cross symbol referencing and allow ethtool to be
    decoupled from PHYLIB entirely.

    Signed-off-by: Florian Fainelli
    Reviewed-by: Andrew Lunn
    Signed-off-by: David S. Miller

    Florian Fainelli
     

22 May, 2020

1 commit

  • As ethnl_request_ops::reply_size handlers do not include common header
    size into calculated/estimated reply size, it needs to be added in
    ethnl_default_doit() and ethnl_default_notify() before allocating the
    message. On the other hand, strset_reply_size() should not add common
    header size.

    Fixes: 728480f12442 ("ethtool: default handlers for GET requests")
    Reported-by: Oleksij Rempel
    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     

30 Mar, 2020

1 commit

  • Add three string sets related to timestamping information:

    ETH_SS_SOF_TIMESTAMPING: SOF_TIMESTAMPING_* flags
    ETH_SS_TS_TX_TYPES: timestamping Tx types
    ETH_SS_TS_RX_FILTERS: timestamping Rx filters

    These will be used for TIMESTAMP_GET request.

    v2: avoid compiler warning ("enumeration value not handled in switch")
    in net_hwtstamp_validate()

    v3: omit dash in Tx type names ("one-step-*" -> "onestep-*"), suggested by
    Richard Cochran

    Signed-off-by: Michal Kubecek
    Acked-by: Richard Cochran
    Signed-off-by: David S. Miller

    Michal Kubecek
     

27 Jan, 2020

3 commits

  • Implement WOL_GET request to get wake-on-lan settings for a device,
    traditionally available via ETHTOOL_GWOL ioctl request.

    As part of the implementation, provide symbolic names for wake-on-line
    modes as ETH_SS_WOL_MODES string set.

    Signed-off-by: Michal Kubecek
    Reviewed-by: Andrew Lunn
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Implement DEBUG_GET request to get debugging settings for a device. At the
    moment, only message mask corresponding to message level as reported by
    ETHTOOL_GMSGLVL ioctl request is provided. (It is called message level in
    ioctl interface but almost all drivers interpret it as a bit mask.)

    As part of the implementation, provide symbolic names for message mask bits
    as ETH_SS_MSG_CLASSES string set.

    Signed-off-by: Michal Kubecek
    Reviewed-by: Andrew Lunn
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Fix missing or incorrect function argument and struct member descriptions.

    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     

09 Jan, 2020

1 commit

  • Smatch complains that the NULL checking isn't done consistently:

    net/ethtool/strset.c:253 strset_prepare_data()
    error: we previously assumed 'dev' could be null (see line 233)

    It looks like there is a missing return on this path.

    Fixes: 71921690f974 ("ethtool: provide string sets with STRSET_GET request")
    Signed-off-by: Dan Carpenter
    Reviewed-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Dan Carpenter
     

28 Dec, 2019

1 commit

  • Requests a contents of one or more string sets, i.e. indexed arrays of
    strings; this information is provided by ETHTOOL_GSSET_INFO and
    ETHTOOL_GSTRINGS commands of ioctl interface. Unlike ioctl interface, all
    information can be retrieved with one request and mulitple string sets can
    be requested at once.

    There are three types of requests:

    - no NLM_F_DUMP, no device: get "global" stringsets
    - no NLM_F_DUMP, with device: get string sets related to the device
    - NLM_F_DUMP, no device: get device related string sets for all devices

    Client can request either all string sets of given type (global or device
    related) or only specific sets. With ETHTOOL_A_STRSET_COUNTS flag set, only
    set sizes (numbers of strings) are returned.

    Signed-off-by: Michal Kubecek
    Reviewed-by: Florian Fainelli
    Signed-off-by: David S. Miller

    Michal Kubecek