Skip to content

Commit

Permalink
Merge tag 'core_urgent_for_v5.16_rc6' of git://git.kernel.org/pub/scm…
Browse files Browse the repository at this point in the history
…/linux/kernel/git/tip/tip

Pull signal handlign fix from Borislav Petkov:

 - Prevent lock contention on the new sigaltstack lock on the
   common-case path, when no changes have been made to the alternative
   signal stack.

* tag 'core_urgent_for_v5.16_rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  signal: Skip the altstack update when not needed
  • Loading branch information
Linus Torvalds committed Dec 19, 2021
2 parents a4cc5ea + 6c3118c commit c36d891
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -4185,6 +4185,15 @@ do_sigaltstack (const stack_t *ss, stack_t *oss, unsigned long sp,
ss_mode != 0))
return -EINVAL;

/*
* Return before taking any locks if no actual
* sigaltstack changes were requested.
*/
if (t->sas_ss_sp == (unsigned long)ss_sp &&
t->sas_ss_size == ss_size &&
t->sas_ss_flags == ss_flags)
return 0;

sigaltstack_lock();
if (ss_mode == SS_DISABLE) {
ss_size = 0;
Expand Down

0 comments on commit c36d891

Please sign in to comment.