[LU-16893] Fix cfs_force_sig(sig, task) deadlock on 5.3 and later kernels. Created: 14/Jun/23  Updated: 02/Aug/23  Resolved: 26/Jul/23

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: None
Fix Version/s: Upstream

Type: Bug Priority: Minor
Reporter: Shaun Tancheff Assignee: Shaun Tancheff
Resolution: Fixed Votes: 0
Labels: None

Severity: 3
Rank (Obsolete): 9223372036854775807

 Description   

When HAVE_FORCE_SIG_WITH_TASK is not available cfs_force_sig() is used.

However cfs_force_sig holds a spin lock on 'siglock':

#define cfs_force_sig(sig, task) \
do { \
unsigned long flags;\
\
spin_lock_irqsave(&task->sighand->siglock, flags);\
task->sighand->action[sig - 1].sa.sa_handler = SIG_DFL;\
send_sig(sig, task, 1);\
spin_unlock_irqrestore(&task->sighand->siglock, flags);         \
} while (0)

This causes a dead lock on 'siglock' as do_send_sig_info also takes the same lock.
 

cfs_force_sig(sig, task)
  -> spin_lock_irqsave(&task->sighand->siglock, flags); \
    -> send_sig(.., task,..)
     -> send_sig_info(.., task)
       -> do_send_sig_info(..., task)
         -> lock_task_sighand(task)
           -> __lock_task_sighand(task, flags)
              {
                  sighand = rcu_dereference(task->sighand);
                  spin_lock_irqsave(&sighand->siglock, *flags);
                  ...
              } 

cfs_force_sig() should release the spin lock before calling send_sig()



 Comments   
Comment by Gerrit Updater [ 14/Jun/23 ]

"Shaun Tancheff <shaun.tancheff@hpe.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/51312
Subject: LU-16893 libcfs: cfs_force_sig deadklock on send_sig
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 95d7c82a03e9d888f6c5a1a4a66b21af383d8b6c

Comment by Gerrit Updater [ 27/Jun/23 ]

"Shaun Tancheff <shaun.tancheff@hpe.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/51470
Subject: LU-16893 libcfs: Remove force_sig usage from lfsck
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 58a87c8d409417a45f01ec99b2af0da612764449

Comment by Gerrit Updater [ 19/Jul/23 ]

"Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/c/fs/lustre-release/+/51470/
Subject: LU-16893 libcfs: Remove force_sig usage from lfsck
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: b876e22466a83dacfbbbeb90d841dc917a793666

Comment by Shaun Tancheff [ 26/Jul/23 ]

Issue is resolved on master

Comment by Gerrit Updater [ 02/Aug/23 ]

"xinliang <xinliang.liu@linaro.org>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/51848
Subject: LU-16893 libcfs: Remove force_sig usage from lfsck
Project: fs/lustre-release
Branch: b2_15
Current Patch Set: 1
Commit: 3db7d6c415bf1d2931cd05498c7b3289ef8fd720

Generated at Sat Feb 10 03:30:53 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.