• Xie He's avatar
    net: lapb: Add locking to the lapb module · b491e6a7
    Xie He authored
    In the lapb module, the timers may run concurrently with other code in
    this module, and there is currently no locking to prevent the code from
    racing on "struct lapb_cb". This patch adds locking to prevent racing.
    
    1. Add "spinlock_t lock" to "struct lapb_cb"; Add "spin_lock_bh" and
    "spin_unlock_bh" to APIs, timer functions and notifier functions.
    
    2. Add "bool t1timer_stop, t2timer_stop" to "struct lapb_cb" to make us
    able to ask running timers to abort; Modify "lapb_stop_t1timer" and
    "lapb_stop_t2timer" to make them able to abort running timers;
    Modify "lapb_t2timer_expiry" and "lapb_t1timer_expiry" to make them
    abort after they are stopped by "lapb_stop_t1timer", "lapb_stop_t2timer",
    and "lapb_start_t1timer", "lapb_start_t2timer".
    
    3. Let lapb_unregister wait for other API functions and running timers
    to stop.
    
    4. The lapb_device_event function calls lapb_disconnect_request. In
    order to avoid trying to hold the lock twice, add a new function named
    "__lapb_disconnect_request" which assumes the lock is held, and make
    it called by lapb_disconnect_request and lapb_device_event.
    
    Fixes: 1da177e4 ("Linux-2.6.12-rc2")
    Cc: Martin Schiller <ms@dev.tdt.de>
    Signed-off-by: default avatarXie He <xie.he.0141@gmail.com>
    Link: https://lore.kernel.org/r/20210126040939.69995-1-xie.he.0141@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
    b491e6a7
lapb_timer.c 4.69 KB