20 Sep, 2019

1 commit

  • Disabling multicast filtering from NCSI if it is supported. As it
    should not filter any multicast packets. In current code, multicast
    filter is enabled and with an exception of optional field supported
    by device are disabled filtering.

    Mainly I see if goal is to disable filtering for IPV6 packets then let
    it disabled for every other types as well. As we are seeing issues with
    LLDP not working with this enabled filtering. And there are other issues
    with IPV6.

    By Disabling this multicast completely, it is working for both IPV6 as
    well as LLDP.

    Signed-off-by: Vijay Khemka
    Acked-by: Samuel Mendoza-Jonas
    Signed-off-by: Jakub Kicinski

    Vijay Khemka
     

01 Sep, 2019

1 commit

  • This patch adds handlers for PLDM over NC-SI command response.

    This enables NC-SI driver recognizes the packet type so the responses
    don't get dropped as unknown packet type.

    PLDM over NC-SI are not handled in kernel driver for now, but can be
    passed back to user space via Netlink for further handling.

    Signed-off-by: Ben Wei
    Signed-off-by: David S. Miller

    Ben Wei
     

28 Aug, 2019

1 commit


23 Aug, 2019

2 commits


21 Aug, 2019

1 commit


31 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 3029 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190527070032.746973796@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

21 May, 2019

1 commit


28 Apr, 2019

3 commits

  • Add options to strictly validate messages and dump messages,
    sometimes perhaps validating dump messages non-strictly may
    be required, so add an option for that as well.

    Since none of this can really be applied to existing commands,
    set the options everwhere using the following spatch:

    @@
    identifier ops;
    expression X;
    @@
    struct genl_ops ops[] = {
    ...,
    {
    .cmd = X,
    + .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
    ...
    },
    ...
    };

    For new commands one should just not copy the .validate 'opt-out'
    flags and thus get strict validation.

    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     
  • We currently have two levels of strict validation:

    1) liberal (default)
    - undefined (type >= max) & NLA_UNSPEC attributes accepted
    - attribute length >= expected accepted
    - garbage at end of message accepted
    2) strict (opt-in)
    - NLA_UNSPEC attributes accepted
    - attribute length >= expected accepted

    Split out parsing strictness into four different options:
    * TRAILING - check that there's no trailing data after parsing
    attributes (in message or nested)
    * MAXTYPE - reject attrs > max known type
    * UNSPEC - reject attributes with NLA_UNSPEC policy entries
    * STRICT_ATTRS - strictly validate attribute size

    The default for future things should be *everything*.
    The current *_strict() is a combination of TRAILING and MAXTYPE,
    and is renamed to _deprecated_strict().
    The current regular parsing has none of this, and is renamed to
    *_parse_deprecated().

    Additionally it allows us to selectively set one of the new flags
    even on old policies. Notably, the UNSPEC flag could be useful in
    this case, since it can be arranged (by filling in the policy) to
    not be an incompatible userspace ABI change, but would then going
    forward prevent forgetting attribute entries. Similar can apply
    to the POLICY flag.

    We end up with the following renames:
    * nla_parse -> nla_parse_deprecated
    * nla_parse_strict -> nla_parse_deprecated_strict
    * nlmsg_parse -> nlmsg_parse_deprecated
    * nlmsg_parse_strict -> nlmsg_parse_deprecated_strict
    * nla_parse_nested -> nla_parse_nested_deprecated
    * nla_validate_nested -> nla_validate_nested_deprecated

    Using spatch, of course:
    @@
    expression TB, MAX, HEAD, LEN, POL, EXT;
    @@
    -nla_parse(TB, MAX, HEAD, LEN, POL, EXT)
    +nla_parse_deprecated(TB, MAX, HEAD, LEN, POL, EXT)

    @@
    expression NLH, HDRLEN, TB, MAX, POL, EXT;
    @@
    -nlmsg_parse(NLH, HDRLEN, TB, MAX, POL, EXT)
    +nlmsg_parse_deprecated(NLH, HDRLEN, TB, MAX, POL, EXT)

    @@
    expression NLH, HDRLEN, TB, MAX, POL, EXT;
    @@
    -nlmsg_parse_strict(NLH, HDRLEN, TB, MAX, POL, EXT)
    +nlmsg_parse_deprecated_strict(NLH, HDRLEN, TB, MAX, POL, EXT)

    @@
    expression TB, MAX, NLA, POL, EXT;
    @@
    -nla_parse_nested(TB, MAX, NLA, POL, EXT)
    +nla_parse_nested_deprecated(TB, MAX, NLA, POL, EXT)

    @@
    expression START, MAX, POL, EXT;
    @@
    -nla_validate_nested(START, MAX, POL, EXT)
    +nla_validate_nested_deprecated(START, MAX, POL, EXT)

    @@
    expression NLH, HDRLEN, MAX, POL, EXT;
    @@
    -nlmsg_validate(NLH, HDRLEN, MAX, POL, EXT)
    +nlmsg_validate_deprecated(NLH, HDRLEN, MAX, POL, EXT)

    For this patch, don't actually add the strict, non-renamed versions
    yet so that it breaks compile if I get it wrong.

    Also, while at it, make nla_validate and nla_parse go down to a
    common __nla_validate_parse() function to avoid code duplication.

    Ultimately, this allows us to have very strict validation for every
    new caller of nla_parse()/nlmsg_parse() etc as re-introduced in the
    next patch, while existing things will continue to work as is.

    In effect then, this adds fully strict validation for any new command.

    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     
  • Even if the NLA_F_NESTED flag was introduced more than 11 years ago, most
    netlink based interfaces (including recently added ones) are still not
    setting it in kernel generated messages. Without the flag, message parsers
    not aware of attribute semantics (e.g. wireshark dissector or libmnl's
    mnl_nlmsg_fprintf()) cannot recognize nested attributes and won't display
    the structure of their contents.

    Unfortunately we cannot just add the flag everywhere as there may be
    userspace applications which check nlattr::nla_type directly rather than
    through a helper masking out the flags. Therefore the patch renames
    nla_nest_start() to nla_nest_start_noflag() and introduces nla_nest_start()
    as a wrapper adding NLA_F_NESTED. The calls which add NLA_F_NESTED manually
    are rewritten to use nla_nest_start().

    Except for changes in include/net/netlink.h, the patch was generated using
    this semantic patch:

    @@ expression E1, E2; @@
    -nla_nest_start(E1, E2)
    +nla_nest_start_noflag(E1, E2)

    @@ expression E1, E2; @@
    -nla_nest_start_noflag(E1, E2 | NLA_F_NESTED)
    +nla_nest_start(E1, E2)

    Signed-off-by: Michal Kubecek
    Acked-by: Jiri Pirko
    Acked-by: David Ahern
    Signed-off-by: David S. Miller

    Michal Kubecek
     

26 Apr, 2019

1 commit


24 Apr, 2019

1 commit

  • Previously BMC's MAC address is calculated by simply adding 1 to the
    last byte of network controller's MAC address, and it produces incorrect
    result when network controller's MAC address ends with 0xFF.

    The problem can be fixed by calling eth_addr_inc() function to increment
    MAC address; besides, the MAC address is also validated before assigning
    to BMC.

    Fixes: cb10c7c0dfd9 ("net/ncsi: Add NCSI Broadcom OEM command")
    Signed-off-by: Tao Ren
    Acked-by: Jakub Kicinski
    Acked-by: Samuel Mendoza-Jonas
    Signed-off-by: David S. Miller

    Tao Ren
     

22 Mar, 2019

1 commit

  • Since maxattr is common, the policy can't really differ sanely,
    so make it common as well.

    The only user that did in fact manage to make a non-common policy
    is taskstats, which has to be really careful about it (since it's
    still using a common maxattr!). This is no longer supported, but
    we can fake it using pre_doit.

    This reduces the size of e.g. nl80211.o (which has lots of commands):

    text data bss dec hex filename
    398745 14323 2240 415308 6564c net/wireless/nl80211.o (before)
    397913 14331 2240 414484 65314 net/wireless/nl80211.o (after)
    --------------------------------
    -832 +8 0 -824

    Which is obviously just 8 bytes for each command, and an added 8
    bytes for the new policy pointer. I'm not sure why the ops list is
    counted as .text though.

    Most of the code transformations were done using the following spatch:
    @ops@
    identifier OPS;
    expression POLICY;
    @@
    struct genl_ops OPS[] = {
    ...,
    {
    - .policy = POLICY,
    },
    ...
    };

    @@
    identifier ops.OPS;
    expression ops.POLICY;
    identifier fam;
    expression M;
    @@
    struct genl_family fam = {
    .ops = OPS,
    .maxattr = M,
    + .policy = POLICY,
    ...
    };

    This also gets rid of devlink_nl_cmd_region_read_dumpit() accessing
    the cb->data as ops, which we want to change in a later genl patch.

    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     

17 Mar, 2019

1 commit


28 Nov, 2018

1 commit

  • This patch adds OEM Mellanox commands and response handling. It also
    defines OEM Get MAC Address handler to get and configure the device.

    ncsi_oem_gma_handler_mlx: This handler send NCSI mellanox command for
    getting mac address.
    ncsi_rsp_handler_oem_mlx: This handles response received for all
    mellanox OEM commands.
    ncsi_rsp_handler_oem_mlx_gma: This handles get mac address response and
    set it to device.

    Signed-off-by: Vijay Khemka
    Signed-off-by: David S. Miller

    Vijay Khemka
     

18 Nov, 2018

6 commits

  • This patch extends the ncsi-netlink interface with two new commands and
    three new attributes to configure multiple packages and/or channels at
    once, and configure specific failover modes.

    NCSI_CMD_SET_PACKAGE mask and NCSI_CMD_SET_CHANNEL_MASK set a whitelist
    of packages or channels allowed to be configured with the
    NCSI_ATTR_PACKAGE_MASK and NCSI_ATTR_CHANNEL_MASK attributes
    respectively. If one of these whitelists is set only packages or
    channels matching the whitelist are considered for the channel queue in
    ncsi_choose_active_channel().

    These commands may also use the NCSI_ATTR_MULTI_FLAG to signal that
    multiple packages or channels may be configured simultaneously. NCSI
    hardware arbitration (HWA) must be available in order to enable
    multi-package mode. Multi-channel mode is always available.

    If the NCSI_ATTR_CHANNEL_ID attribute is present in the
    NCSI_CMD_SET_CHANNEL_MASK command the it sets the preferred channel as
    with the NCSI_CMD_SET_INTERFACE command. The combination of preferred
    channel and channel whitelist defines a primary channel and the allowed
    failover channels.
    If the NCSI_ATTR_MULTI_FLAG attribute is also present then the preferred
    channel is configured for Tx/Rx and the other channels are enabled only
    for Rx.

    Signed-off-by: Samuel Mendoza-Jonas
    Signed-off-by: David S. Miller

    Samuel Mendoza-Jonas
     
  • When the NCSI driver is stopped with ncsi_stop_dev() the channel
    monitors are stopped and the state set to "inactive". However the
    channels are still configured and active from the perspective of the
    network controller. We should suspend each active channel but in the
    context of ncsi_stop_dev() the transmit queue has been or is about to be
    stopped so we won't have time to do so.

    Instead when ncsi_start_dev() is called if the NCSI topology has already
    been probed then call ncsi_reset_dev() to suspend any channels that were
    previously active. This resets the network controller to a known state,
    provides an up to date view of channel link state, and makes sure that
    mode flags such as NCSI_MODE_TX_ENABLE are properly reset.

    In addition to ncsi_start_dev() use ncsi_reset_dev() in ncsi-netlink.c
    to update the channel configuration more cleanly.

    Signed-off-by: Samuel Mendoza-Jonas
    Signed-off-by: David S. Miller

    Samuel Mendoza-Jonas
     
  • The concepts of a channel being 'active' and it having link are slightly
    muddled in the NCSI driver. Tweak this slightly so that
    NCSI_CHANNEL_ACTIVE represents a channel that has been configured and
    enabled, and NCSI_CHANNEL_INACTIVE represents a de-configured channel.
    This distinction is important because a channel can be 'active' but have
    its link down; in this case the channel may still need to be configured
    so that it may receive AEN link-state-change packets.

    Signed-off-by: Samuel Mendoza-Jonas
    Signed-off-by: David S. Miller

    Samuel Mendoza-Jonas
     
  • When a package is deselected all channels of that package cease
    communication. If there are other channels active on the package of the
    suspended channel this will disable them as well, so only send a
    deselect-package command if no other channels are active.

    Signed-off-by: Samuel Mendoza-Jonas
    Signed-off-by: David S. Miller

    Samuel Mendoza-Jonas
     
  • Currently the NCSI driver sends a select-package command to all possible
    packages simultaneously to discover what packages are available. However
    at this stage in the probe process the driver does not know if
    hardware arbitration is available: if it isn't then this process could
    cause collisions on the RMII bus when packages try to respond.

    Update the probe loop to probe each package one by one, and once
    complete check if HWA is universally supported.

    Signed-off-by: Samuel Mendoza-Jonas
    Signed-off-by: David S. Miller

    Samuel Mendoza-Jonas
     
  • NCSI hardware arbitration allows multiple packages to be enabled at once
    and share the same wiring. If the NCSI driver recognises that HWA is
    available it unconditionally enables all packages and channels; but that
    is a configuration decision rather than something required by HWA.
    Additionally the current implementation will not failover on link events
    which can cause connectivity to be lost unless the interface is manually
    bounced.

    Retain basic HWA support but remove the separate configuration path to
    enable all channels, leaving this to be handled by a later
    implementation.

    Signed-off-by: Samuel Mendoza-Jonas
    Signed-off-by: David S. Miller

    Samuel Mendoza-Jonas
     

18 Oct, 2018

1 commit

  • This patch adds OEM Broadcom commands and response handling. It also
    defines OEM Get MAC Address handler to get and configure the device.

    ncsi_oem_gma_handler_bcm: This handler send NCSI broadcom command for
    getting mac address.
    ncsi_rsp_handler_oem_bcm: This handles response received for all
    broadcom OEM commands.
    ncsi_rsp_handler_oem_bcm_gma: This handles get mac address response and
    set it to device.

    Signed-off-by: Vijay Khemka
    Reviewed-by: Samuel Mendoza-Jonas
    Signed-off-by: David S. Miller

    Vijay Khemka
     

16 Oct, 2018

1 commit

  • The new command (NCSI_CMD_SEND_CMD) is added to allow user space application
    to send NC-SI command to the network card.
    Also, add a new attribute (NCSI_ATTR_DATA) for transferring request and response.

    The work flow is as below.

    Request:
    User space application
    -> Netlink interface (msg)
    -> new Netlink handler - ncsi_send_cmd_nl()
    -> ncsi_xmit_cmd()

    Response:
    Response received - ncsi_rcv_rsp()
    -> internal response handler - ncsi_rsp_handler_xxx()
    -> ncsi_rsp_handler_netlink()
    -> ncsi_send_netlink_rsp ()
    -> Netlink interface (msg)
    -> user space application

    Command timeout - ncsi_request_timeout()
    -> ncsi_send_netlink_timeout ()
    -> Netlink interface (msg with zero data length)
    -> user space application

    Error:
    Error detected
    -> ncsi_send_netlink_err ()
    -> Netlink interface (err msg)
    -> user space application

    Signed-off-by: Justin Lee
    Reviewed-by: Samuel Mendoza-Jonas
    Signed-off-by: David S. Miller

    Justin.Lee1@Dell.com
     

06 Oct, 2018

1 commit

  • This patch adds OEM commands and response handling. It also defines OEM
    command and response structure as per NCSI specification along with its
    handlers.

    ncsi_cmd_handler_oem: This is a generic command request handler for OEM
    commands
    ncsi_rsp_handler_oem: This is a generic response handler for OEM commands

    Signed-off-by: Vijay Khemka
    Reviewed-by: Justin Lee
    Reviewed-by: Samuel Mendoza-Jonas
    Signed-off-by: David S. Miller

    Vijay Khemka
     

30 Aug, 2018

1 commit


23 Aug, 2018

1 commit


20 Jun, 2018

3 commits

  • This moves all of the netdev_printk(KERN_DEBUG, ...) messages over to
    netdev_dbg.

    As Joe explains:

    > netdev_dbg is not included in object code unless
    > DEBUG is defined or CONFIG_DYNAMIC_DEBUG is set.
    > And then, it is not emitted into the log unless
    > DEBUG is set or this specific netdev_dbg is enabled
    > via the dynamic debug control file.

    Which is what we're after in this case.

    Acked-by: Samuel Mendoza-Jonas
    Signed-off-by: Joel Stanley
    Signed-off-by: David S. Miller

    Joel Stanley
     
  • This does not provide useful information. As the ncsi maintainer said:

    > either we get a channel or broadcom has gone out to lunch

    Acked-by: Samuel Mendoza-Jonas
    Signed-off-by: Joel Stanley
    Signed-off-by: David S. Miller

    Joel Stanley
     
  • In normal operation we see this series of messages as the host drives
    the network device:

    ftgmac100 1e660000.ethernet eth0: NCSI: LSC AEN - channel 0 state down
    ftgmac100 1e660000.ethernet eth0: NCSI: suspending channel 0
    ftgmac100 1e660000.ethernet eth0: NCSI: configuring channel 0
    ftgmac100 1e660000.ethernet eth0: NCSI: channel 0 link down after config
    ftgmac100 1e660000.ethernet eth0: NCSI interface down
    ftgmac100 1e660000.ethernet eth0: NCSI: LSC AEN - channel 0 state up
    ftgmac100 1e660000.ethernet eth0: NCSI: configuring channel 0
    ftgmac100 1e660000.ethernet eth0: NCSI interface up
    ftgmac100 1e660000.ethernet eth0: NCSI: LSC AEN - channel 0 state down
    ftgmac100 1e660000.ethernet eth0: NCSI: suspending channel 0
    ftgmac100 1e660000.ethernet eth0: NCSI: configuring channel 0
    ftgmac100 1e660000.ethernet eth0: NCSI: channel 0 link down after config
    ftgmac100 1e660000.ethernet eth0: NCSI interface down
    ftgmac100 1e660000.ethernet eth0: NCSI: LSC AEN - channel 0 state up
    ftgmac100 1e660000.ethernet eth0: NCSI: configuring channel 0
    ftgmac100 1e660000.ethernet eth0: NCSI interface up

    This makes all of these messages netdev_dbg. They are still useful to
    debug eg. misbehaving network device firmware, but we do not need them
    filling up the kernel logs in normal operation.

    Acked-by: Samuel Mendoza-Jonas
    Signed-off-by: Joel Stanley
    Signed-off-by: David S. Miller

    Joel Stanley
     

03 Jun, 2018

2 commits

  • ncsi_rsp_handler_gc() allocates the filter arrays using GFP_KERNEL in
    softirq context, causing the below backtrace. This allocation is only a
    few dozen bytes during probing so allocate with GFP_ATOMIC instead.

    [ 42.813372] BUG: sleeping function called from invalid context at mm/slab.h:416
    [ 42.820900] in_atomic(): 1, irqs_disabled(): 0, pid: 213, name: kworker/0:1
    [ 42.827893] INFO: lockdep is turned off.
    [ 42.832023] CPU: 0 PID: 213 Comm: kworker/0:1 Tainted: G W 4.13.16-01441-gad99b38 #65
    [ 42.841007] Hardware name: Generic DT based system
    [ 42.845966] Workqueue: events ncsi_dev_work
    [ 42.850251] [] (unwind_backtrace) from [] (show_stack+0x20/0x24)
    [ 42.858046] [] (show_stack) from [] (dump_stack+0x20/0x28)
    [ 42.865309] [] (dump_stack) from [] (___might_sleep+0x230/0x2b0)
    [ 42.873241] [] (___might_sleep) from [] (__might_sleep+0x6c/0xac)
    [ 42.881129] [] (__might_sleep) from [] (__kmalloc+0x210/0x2fc)
    [ 42.888737] [] (__kmalloc) from [] (ncsi_rsp_handler_gc+0xd0/0x170)
    [ 42.896770] [] (ncsi_rsp_handler_gc) from [] (ncsi_rcv_rsp+0x16c/0x1d4)
    [ 42.905314] [] (ncsi_rcv_rsp) from [] (__netif_receive_skb_core+0x3c8/0xb50)
    [ 42.914158] [] (__netif_receive_skb_core) from [] (__netif_receive_skb+0x20/0x7c)
    [ 42.923420] [] (__netif_receive_skb) from [] (netif_receive_skb_internal+0x78/0x6a4)
    [ 42.932931] [] (netif_receive_skb_internal) from [] (netif_receive_skb+0x78/0x158)
    [ 42.942292] [] (netif_receive_skb) from [] (ftgmac100_poll+0x43c/0x4e8)
    [ 42.950855] [] (ftgmac100_poll) from [] (net_rx_action+0x278/0x4c4)
    [ 42.958918] [] (net_rx_action) from [] (__do_softirq+0xe0/0x4c4)
    [ 42.966716] [] (__do_softirq) from [] (do_softirq.part.4+0x50/0x78)
    [ 42.974756] [] (do_softirq.part.4) from [] (__local_bh_enable_ip+0xf8/0x11c)
    [ 42.983579] [] (__local_bh_enable_ip) from [] (__dev_queue_xmit+0x260/0x890)
    [ 42.992392] [] (__dev_queue_xmit) from [] (dev_queue_xmit+0x1c/0x20)
    [ 43.000689] [] (dev_queue_xmit) from [] (ncsi_xmit_cmd+0x1c0/0x244)
    [ 43.008763] [] (ncsi_xmit_cmd) from [] (ncsi_dev_work+0x2e0/0x4c8)
    [ 43.016725] [] (ncsi_dev_work) from [] (process_one_work+0x214/0x6f8)
    [ 43.024940] [] (process_one_work) from [] (worker_thread+0x48/0x558)
    [ 43.033070] [] (worker_thread) from [] (kthread+0x130/0x174)
    [ 43.040506] [] (kthread) from [] (ret_from_fork+0x14/0x24)

    Fixes: 062b3e1b6d4f ("net/ncsi: Refactor MAC, VLAN filters")
    Signed-off-by: Samuel Mendoza-Jonas
    Signed-off-by: David S. Miller

    Samuel Mendoza-Jonas
     
  • Filling in the padding slot in the bpf structure as a bug fix in 'ne'
    overlapped with actually using that padding area for something in
    'net-next'.

    Signed-off-by: David S. Miller

    David S. Miller
     

01 Jun, 2018

1 commit

  • With CONFIG_CC_STACKPROTECTOR enabled the kernel panics as below when
    parsing a NCSI_CMD_PKG_INFO command:

    [ 150.149711] Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: 805cff08
    [ 150.149711]
    [ 150.159919] CPU: 0 PID: 1301 Comm: ncsi-netlink Not tainted 4.13.16-468cbec6d2c91239332cb91b1f0a73aafcb6f0c6 #1
    [ 150.170004] Hardware name: Generic DT based system
    [ 150.174852] [] (unwind_backtrace) from [] (show_stack+0x20/0x24)
    [ 150.182641] [] (show_stack) from [] (dump_stack+0x20/0x28)
    [ 150.189888] [] (dump_stack) from [] (panic+0xdc/0x278)
    [ 150.196780] [] (panic) from [] (__stack_chk_fail+0x20/0x24)
    [ 150.204111] [] (__stack_chk_fail) from [] (ncsi_pkg_info_all_nl+0x244/0x258)
    [ 150.212912] [] (ncsi_pkg_info_all_nl) from [] (genl_lock_dumpit+0x3c/0x54)
    [ 150.221535] [] (genl_lock_dumpit) from [] (netlink_dump+0xf8/0x284)
    [ 150.229550] [] (netlink_dump) from [] (__netlink_dump_start+0x124/0x17c)
    [ 150.237992] [] (__netlink_dump_start) from [] (genl_rcv_msg+0x1c8/0x3d4)
    [ 150.246440] [] (genl_rcv_msg) from [] (netlink_rcv_skb+0xd8/0x134)
    [ 150.254361] [] (netlink_rcv_skb) from [] (genl_rcv+0x30/0x44)
    [ 150.261850] [] (genl_rcv) from [] (netlink_unicast+0x198/0x234)
    [ 150.269511] [] (netlink_unicast) from [] (netlink_sendmsg+0x368/0x3b0)
    [ 150.277783] [] (netlink_sendmsg) from [] (sock_sendmsg+0x24/0x34)
    [ 150.285625] [] (sock_sendmsg) from [] (___sys_sendmsg+0x244/0x260)
    [ 150.293556] [] (___sys_sendmsg) from [] (__sys_sendmsg+0x5c/0x9c)
    [ 150.301400] [] (__sys_sendmsg) from [] (SyS_sendmsg+0x18/0x1c)
    [ 150.308984] [] (SyS_sendmsg) from [] (ret_fast_syscall+0x0/0x3c)
    [ 150.316743] ---[ end Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: 805cff08

    This turns out to be because the attrs array in ncsi_pkg_info_all_nl()
    is initialised to a length of NCSI_ATTR_MAX which is the maximum
    attribute number, not the number of attributes.

    Fixes: 955dc68cb9b2 ("net/ncsi: Add generic netlink family")
    Signed-off-by: Samuel Mendoza-Jonas
    Signed-off-by: David S. Miller

    Samuel Mendoza-Jonas
     

29 May, 2018

1 commit


18 May, 2018

1 commit

  • We recently refactored this code and introduced a static checker
    warning. Smatch complains that if cmd->index is zero then we would
    underflow the arrays. That's obviously true.

    The question is whether we prevent cmd->index from being zero at a
    different level. I've looked at the code and I don't immediately see
    a check for that.

    Fixes: 062b3e1b6d4f ("net/ncsi: Refactor MAC, VLAN filters")
    Signed-off-by: Dan Carpenter
    Signed-off-by: David S. Miller

    Dan Carpenter
     

18 Apr, 2018

1 commit

  • The NCSI driver defines a generic ncsi_channel_filter struct that can be
    used to store arbitrarily formatted filters, and several generic methods
    of accessing data stored in such a filter.
    However in both the driver and as defined in the NCSI specification
    there are only two actual filters: VLAN ID filters and MAC address
    filters. The splitting of the MAC filter into unicast, multicast, and
    mixed is also technically not necessary as these are stored in the same
    location in hardware.

    To save complexity, particularly in the set up and accessing of these
    generic filters, remove them in favour of two specific structs. These
    can be acted on directly and do not need several generic helper
    functions to use.

    This also fixes a memory error found by KASAN on ARM32 (which is not
    upstream yet), where response handlers accessing a filter's data field
    could write past allocated memory.

    [ 114.926512] ==================================================================
    [ 114.933861] BUG: KASAN: slab-out-of-bounds in ncsi_configure_channel+0x4b8/0xc58
    [ 114.941304] Read of size 2 at addr 94888558 by task kworker/0:2/546
    [ 114.947593]
    [ 114.949146] CPU: 0 PID: 546 Comm: kworker/0:2 Not tainted 4.16.0-rc6-00119-ge156398bfcad #13
    ...
    [ 115.170233] The buggy address belongs to the object at 94888540
    [ 115.170233] which belongs to the cache kmalloc-32 of size 32
    [ 115.181917] The buggy address is located 24 bytes inside of
    [ 115.181917] 32-byte region [94888540, 94888560)
    [ 115.192115] The buggy address belongs to the page:
    [ 115.196943] page:9eeac100 count:1 mapcount:0 mapping:94888000 index:0x94888fc1
    [ 115.204200] flags: 0x100(slab)
    [ 115.207330] raw: 00000100 94888000 94888fc1 0000003f 00000001 9eea2014 9eecaa74 96c003e0
    [ 115.215444] page dumped because: kasan: bad access detected
    [ 115.221036]
    [ 115.222544] Memory state around the buggy address:
    [ 115.227384] 94888400: fb fb fb fb fc fc fc fc 04 fc fc fc fc fc fc fc
    [ 115.233959] 94888480: 00 00 00 fc fc fc fc fc 00 04 fc fc fc fc fc fc
    [ 115.240529] >94888500: 00 00 04 fc fc fc fc fc 00 00 04 fc fc fc fc fc
    [ 115.247077] ^
    [ 115.252523] 94888580: 00 04 fc fc fc fc fc fc 06 fc fc fc fc fc fc fc
    [ 115.259093] 94888600: 00 00 06 fc fc fc fc fc 00 00 04 fc fc fc fc fc
    [ 115.265639] ==================================================================

    Reported-by: Joel Stanley
    Signed-off-by: Samuel Mendoza-Jonas
    Signed-off-by: David S. Miller

    Samuel Mendoza-Jonas
     

27 Mar, 2018

1 commit

  • The call to nla_nest_start calls nla_put which can lead to a NULL
    return so it's possible for attr to become NULL and we can potentially
    get a NULL pointer dereference on attr. Fix this by checking for
    a NULL return.

    Detected by CoverityScan, CID#1466125 ("Dereference null return")

    Fixes: 955dc68cb9b2 ("net/ncsi: Add generic netlink family")
    Signed-off-by: Colin Ian King
    Signed-off-by: David S. Miller

    Colin Ian King
     

09 Mar, 2018

2 commits


05 Mar, 2018

1 commit

  • Add a generic netlink family for NCSI. This supports three commands;
    NCSI_CMD_PKG_INFO which returns information on packages and their
    associated channels, NCSI_CMD_SET_INTERFACE which allows a specific
    package or package/channel combination to be set as the preferred
    choice, and NCSI_CMD_CLEAR_INTERFACE which clears any preferred setting.

    Signed-off-by: Samuel Mendoza-Jonas
    Signed-off-by: David S. Miller

    Samuel Mendoza-Jonas