]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
devlink: disallow reload operation during device cleanup
authorJiri Pirko <jiri@mellanox.com>
Fri, 8 Nov 2019 20:42:43 +0000 (21:42 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 8 Nov 2019 22:11:47 +0000 (14:11 -0800)
commita0c76345e3d3dbc40c39de2e00d15a3b7eef7885
tree5105fde79df0b63a9b5a65df95b338e2f273a141
parentf95e6c9c461709a1faa37b20c4d3eb50253f616a
devlink: disallow reload operation during device cleanup

There is a race between driver code that does setup/cleanup of device
and devlink reload operation that in some drivers works with the same
code. Use after free could we easily obtained by running:

while true; do
        echo 10 > /sys/bus/netdevsim/new_device
        devlink dev reload netdevsim/netdevsim10 &
        echo 10 > /sys/bus/netdevsim/del_device
done

Fix this by enabling reload only after setup of device is complete and
disabling it at the beginning of the cleanup process.

Reported-by: Ido Schimmel <idosch@mellanox.com>
Fixes: 2d8dc5bbf4e7 ("devlink: Add support for reload")
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx4/main.c
drivers/net/ethernet/mellanox/mlxsw/core.c
drivers/net/netdevsim/dev.c
include/net/devlink.h
net/core/devlink.c