• Jiri Pirko's avatar
    mlxsw: core: Unpublish devlink parameters during reload · b7265a0d
    Jiri Pirko authored
    The devlink parameter "acl_region_rehash_interval" is a runtime
    parameter whose value is stored in a dynamically allocated memory. While
    reloading the driver, this memory is freed and then allocated again. A
    use-after-free might happen if during this time frame someone tries to
    retrieve its value.
    
    Since commit 070c63f2 ("net: devlink: allow to change namespaces
    during reload") the use-after-free can be reliably triggered when
    reloading the driver into a namespace, as after freeing the memory (via
    reload_down() callback) all the parameters are notified.
    
    Fix this by unpublishing and then re-publishing the parameters during
    reload.
    
    Fixes: 98bbf70c ("mlxsw: spectrum: add "acl_region_rehash_interval" devlink param")
    Fixes: 7c62cfb8 ("devlink: publish params only after driver init is done")
    Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
    Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    b7265a0d
core.c 60.2 KB