• D
    neigh: fix possible DoS due to net iface start/stop loop · 2b20b58b
    Denis V. Lunev 提交于
    stable inclusion
    from stable-v5.10.141
    commit c35adafe42bd6c3bf2aca0a3f523dabc38fc23c8
    category: bugfix
    bugzilla: https://gitee.com/openeuler/kernel/issues/I685FC
    
    Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=c35adafe42bd6c3bf2aca0a3f523dabc38fc23c8
    
    --------------------------------
    
    [ Upstream commit 66ba215c ]
    
    Normal processing of ARP request (usually this is Ethernet broadcast
    packet) coming to the host is looking like the following:
    * the packet comes to arp_process() call and is passed through routing
      procedure
    * the request is put into the queue using pneigh_enqueue() if
      corresponding ARP record is not local (common case for container
      records on the host)
    * the request is processed by timer (within 80 jiffies by default) and
      ARP reply is sent from the same arp_process() using
      NEIGH_CB(skb)->flags & LOCALLY_ENQUEUED condition (flag is set inside
      pneigh_enqueue())
    
    And here the problem comes. Linux kernel calls pneigh_queue_purge()
    which destroys the whole queue of ARP requests on ANY network interface
    start/stop event through __neigh_ifdown().
    
    This is actually not a problem within the original world as network
    interface start/stop was accessible to the host 'root' only, which
    could do more destructive things. But the world is changed and there
    are Linux containers available. Here container 'root' has an access
    to this API and could be considered as untrusted user in the hosting
    (container's) world.
    
    Thus there is an attack vector to other containers on node when
    container's root will endlessly start/stop interfaces. We have observed
    similar situation on a real production node when docker container was
    doing such activity and thus other containers on the node become not
    accessible.
    
    The patch proposed doing very simple thing. It drops only packets from
    the same namespace in the pneigh_queue_purge() where network interface
    state change is detected. This is enough to prevent the problem for the
    whole node preserving original semantics of the code.
    
    v2:
    	- do del_timer_sync() if queue is empty after pneigh_queue_purge()
    v3:
    	- rebase to net tree
    
    Cc: "David S. Miller" <davem@davemloft.net>
    Cc: Eric Dumazet <edumazet@google.com>
    Cc: Jakub Kicinski <kuba@kernel.org>
    Cc: Paolo Abeni <pabeni@redhat.com>
    Cc: Daniel Borkmann <daniel@iogearbox.net>
    Cc: David Ahern <dsahern@kernel.org>
    Cc: Yajun Deng <yajun.deng@linux.dev>
    Cc: Roopa Prabhu <roopa@nvidia.com>
    Cc: Christian Brauner <brauner@kernel.org>
    Cc: netdev@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
    Cc: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
    Cc: Konstantin Khorenko <khorenko@virtuozzo.com>
    Cc: kernel@openvz.org
    Cc: devel@openvz.org
    Investigated-by: NAlexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
    Signed-off-by: NDenis V. Lunev <den@openvz.org>
    Signed-off-by: NDavid S. Miller <davem@davemloft.net>
    Signed-off-by: NSasha Levin <sashal@kernel.org>
    Signed-off-by: NJialin Zhang <zhangjialin11@huawei.com>
    Reviewed-by: NZheng Zengkai <zhengzengkai@huawei.com>
    (cherry picked from commit f15147a7)
    2b20b58b
neighbour.c 92.2 KB