• D
    ipv4: Fix device used for dst_alloc with local routes · 2d08e2bf
    David Ahern 提交于
    stable inclusion
    from stable-5.10.46
    commit 0239c439cedcc13c57f6d6e47c36904cdf1da7ca
    bugzilla: 168323
    CVE: NA
    
    --------------------------------
    
    [ Upstream commit b87b04f5 ]
    
    Oliver reported a use case where deleting a VRF device can hang
    waiting for the refcnt to drop to 0. The root cause is that the dst
    is allocated against the VRF device but cached on the loopback
    device.
    
    The use case (added to the selftests) has an implicit VRF crossing
    due to the ordering of the FIB rules (lookup local is before the
    l3mdev rule, but the problem occurs even if the FIB rules are
    re-ordered with local after l3mdev because the VRF table does not
    have a default route to terminate the lookup). The end result is
    is that the FIB lookup returns the loopback device as the nexthop,
    but the ingress device is in a VRF. The mismatch causes the dst
    alloc against the VRF device but then cached on the loopback.
    
    The fix is to bring the trick used for IPv6 (see ip6_rt_get_dev_rcu):
    pick the dst alloc device based the fib lookup result but with checks
    that the result has a nexthop device (e.g., not an unreachable or
    prohibit entry).
    
    Fixes: f5a0aab8 ("net: ipv4: dst for local input routes should use l3mdev if relevant")
    Reported-by: NOliver Herms <oliver.peter.herms@gmail.com>
    Signed-off-by: NDavid Ahern <dsahern@kernel.org>
    Signed-off-by: NDavid S. Miller <davem@davemloft.net>
    Signed-off-by: NSasha Levin <sashal@kernel.org>
    Signed-off-by: NChen Jun <chenjun102@huawei.com>
    Acked-by: NWeilong Chen <chenweilong@huawei.com>
    Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
    2d08e2bf
route.c 89.5 KB