• Xie He's avatar
    net: hdlc: In hdlc_rcv, check to make sure dev is an HDLC device · 01c4ceae
    Xie He authored
    The hdlc_rcv function is used as hdlc_packet_type.func to process any
    skb received in the kernel with skb->protocol == htons(ETH_P_HDLC).
    The purpose of this function is to provide second-stage processing for
    skbs not assigned a "real" L3 skb->protocol value in the first stage.
    
    This function assumes the device from which the skb is received is an
    HDLC device (a device created by this module). It assumes that
    netdev_priv(dev) returns a pointer to "struct hdlc_device".
    
    However, it is possible that some driver in the kernel (not necessarily
    in our control) submits a received skb with skb->protocol ==
    htons(ETH_P_HDLC), from a non-HDLC device. In this case, the skb would
    still be received by hdlc_rcv. This will cause problems.
    
    hdlc_rcv should be able to recognize and drop invalid skbs. It should
    first make sure "dev" is actually an HDLC device, before starting its
    processing. This patch adds this check to hdlc_rcv.
    
    Fixes: 1da177e4 ("Linux-2.6.12-rc2")
    Cc: Krzysztof Halasa <khc@pm.waw.pl>
    Signed-off-by: default avatarXie He <xie.he.0141@gmail.com>
    Link: https://lore.kernel.org/r/20201020013152.89259-1-xie.he.0141@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
    01c4ceae
hdlc.c 8.17 KB