• Kuniyuki Iwashima's avatar
    llc: Check netns in llc_dgram_match(). · 9b64e93e
    Kuniyuki Iwashima authored
    We will remove this restriction in llc_rcv() soon, 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_SAP, llc_sap_handler() is called to pass skb
    to corresponding sockets.  Then, we must look up a proper socket in the
    same netns with skb->dev.
    
    If the destination is a multicast address, llc_sap_handler() calls
    llc_sap_mcast().  It calculates a hash based on DSAP and skb->dev->ifindex,
    iterates on a socket list, and calls llc_mcast_match() to check if the
    socket is the correct destination.  Then, llc_mcast_match() checks if
    skb->dev matches with llc_sk(sk)->dev.  So, we need not check netns here.
    
    OTOH, if the destination is a unicast address, llc_sap_handler() calls
    llc_lookup_dgram() to look up a socket, but it does not check the netns.
    
    Therefore, we need to add netns check in llc_lookup_dgram().
    Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
    Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
    9b64e93e
llc_sap.c 11.5 KB