• Kuniyuki Iwashima's avatar
    llc: Check netns in llc_estab_match() and llc_listener_match(). · 97b1d320
    Kuniyuki Iwashima authored
    We will remove this restriction in llc_rcv() in the following patch,
    which means that the protocol handler must be aware of netns.
    
            if (!net_eq(dev_net(dev), &init_net))
                    goto drop;
    
    llc_rcv() fetches llc_type_handlers[llc_pdu_type(skb) - 1] and calls it
    if not NULL.
    
    If the PDU type is LLC_DEST_CONN, llc_conn_handler() is called to pass
    skb to corresponding sockets.  Then, we must look up a proper socket in
    the same netns with skb->dev.
    
    llc_conn_handler() calls __llc_lookup() to look up a established or
    litening socket by __llc_lookup_established() and llc_lookup_listener().
    
    Both functions iterate on a list and call llc_estab_match() or
    llc_listener_match() to check if the socket is the correct destination.
    However, these functions do not check netns.
    
    Also, bind() and connect() call llc_establish_connection(), which
    finally calls __llc_lookup_established(), to check if there is a
    conflicting socket.
    
    Let's test netns in llc_estab_match() and llc_listener_match().
    Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
    Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
    97b1d320
af_llc.c 32.1 KB