• Vladimir Oltean's avatar
    net: ipconfig: ic_dev can be NULL in ic_close_devs · a50a151e
    Vladimir Oltean authored
    ic_close_dev contains a generalization of the logic to not close a
    network interface if it's the host port for a DSA switch. This logic is
    disguised behind an iteration through the lowers of ic_dev in
    ic_close_dev.
    
    When no interface for ipconfig can be found, ic_dev is NULL, and
    ic_close_dev:
    - dereferences a NULL pointer when assigning selected_dev
    - would attempt to search through the lower interfaces of a NULL
      net_device pointer
    
    So we should protect against that case.
    
    The "lower_dev" iterator variable was shortened to "lower" in order to
    keep the 80 character limit.
    
    Fixes: f68cbaed ("net: ipconfig: avoid use-after-free in ic_close_devs")
    Fixes: 46acf7bd ("Revert "net: ipv4: handle DSA enabled master network devices"")
    Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
    Tested-by: default avatarHeiko Thiery <heiko.thiery@gmail.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    a50a151e
ipconfig.c 42.7 KB