Re: [GIT PULL] timer fixes

From: Borislav Petkov
Date: Sun Aug 14 2022 - 08:54:32 EST


On Sat, Aug 13, 2022 at 01:27:40PM -0700, Linus Torvalds wrote:
> On Sat, Aug 13, 2022 at 9:25 AM Borislav Petkov <bp@xxxxxxxxx> wrote:
> >
> > That task_struct.sighand is marked __rcu and thus noderef and sparse
> > complains:
>
> I think that RCU marking is misleading.
>
> Doing a
>
> git grep -e '->sighand'
>
> shows that we basically never treat that as some kind of RCU pointer.
>
> Adding a
>
> grep -i rcu
>
> to the above shows that we have a couple of places that do this
> carefully, but they are the exception rather than the rule.
>
> I think the issue is that "current->sighand" is always safe (and that
> "me->sighand" is the same thing), and that sighand has RCU-delayed
> freeing so that __lock_task_sighand() can safely try to take the lock
> of another process' sighand.
>
> And we have no real way to explain to sparse that *some* cases are
> fine, others are not and need the sighand lock (after that careful
> __lock_task_sighand thing).

Sounds to me like that sparse check was not such a good idea in the
first place. Especially since the 0day bot is probably warning about all
those cases where we try to lock ->sighand.

It was added by

913292c97d75 ("sched.h: Annotate sighand_struct with __rcu")

Lemme add the involved parties to Cc.

Thx.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette