On Sun, Dec 19, 2021 at 5:40 AM Borislav Petkov wrote: > > Prevent lock contention on the new sigaltstack lock on the common-case > path, when no changes have been made to the alternative signal stack. I pulled this, but I think it's wrong. It checks whether the new ss_size/ss_sp is the same as the old ones, and skips the work if so. But that check is bogus. Why? Because it's comparing the wrong values. It's comparing the values as they are *before* they are fixed up for the SS_DISABLE case. So if the new mode is SS_DISABLE, it's going to compare the values against the old values for ss_size and ss_sp: but those old values will have been reset to 0/NULL. And the new values have not been reset yet before the comparison. So the comparison wil easily fail when it shouldn't. And that's all pointless anyway. If it's SS_DISABLE, there's no point in doing *any* of this. Now, I decided to keep the pull, because this bug only means that the commit isn't actually as effective as it *should* be. Honestly, that do_sigaltstack code is written just about pessimally, and taking the sigaltstack_lock just for the limit checking is all kinds of silly. The SS_DISABLE case shouldn't take the lock at all. And the actual modification of the values shouldn't need any locking at all, since it's all thread-local. I'm not convinced even the limit checking needs the lock, but whatever. I think it could maybe just use "read_once()" or something. I think the attached patch is an improvement, but I did *not* test this, and I'm just throwing this out as a "maybe something like this". Comments? Note: I will throw this patch away after sending it out. If people agree, Linus