• Xie He's avatar
    net: hdlc_x25: Prevent racing between "x25_close" and "x25_xmit"/"x25_rx" · bf0ffea3
    Xie He authored
    "x25_close" is called by "hdlc_close" in "hdlc.c", which is called by
    hardware drivers' "ndo_stop" function.
    "x25_xmit" is called by "hdlc_start_xmit" in "hdlc.c", which is hardware
    drivers' "ndo_start_xmit" function.
    "x25_rx" is called by "hdlc_rcv" in "hdlc.c", which receives HDLC frames
    from "net/core/dev.c".
    
    "x25_close" races with "x25_xmit" and "x25_rx" because their callers race.
    
    However, we need to ensure that the LAPB APIs called in "x25_xmit" and
    "x25_rx" are called before "lapb_unregister" is called in "x25_close".
    
    This patch adds locking to ensure when "x25_xmit" and "x25_rx" are doing
    their work, "lapb_unregister" is not yet called in "x25_close".
    
    Reasons for not solving the racing between "x25_close" and "x25_xmit" by
    calling "netif_tx_disable" in "x25_close":
    1. We still need to solve the racing between "x25_close" and "x25_rx";
    2. The design of the HDLC subsystem assumes the HDLC hardware drivers
    have full control...
    bf0ffea3
hdlc_x25.c 8.12 KB