Re: Coverity: __do_sys_pidfd_send_signal(): UNINIT

From: Tycho Andersen
Date: Wed Feb 14 2024 - 13:14:45 EST


On Wed, Feb 14, 2024 at 06:55:55PM +0100, Oleg Nesterov wrote:
> Hi Tycho,
>
> let me repeat just in case, I am fine either way, whatever you and
> Christian prefer. In particular, I agree in advance if you decide
> to not change the current code, it is correct even if it can fool
> the tools.
>
> That said,
>
> On 02/14, Tycho Andersen wrote:
> >
> > On Wed, Feb 14, 2024 at 10:06:41AM +0100, Oleg Nesterov wrote:
> > >
> > > - /* Ensure that only a single signal scope determining flag is set. */
> > > - if (hweight32(flags & PIDFD_SEND_SIGNAL_FLAGS) > 1)
> > > + switch (flags) {
> > > + case 0:
> > > + /* but see the PIDFD_THREAD check below */
> >
> > Why not put that bit inline?
>
> Not sure I understand what does "inline" mean... but let me reply
> anyway.
>
> We want to check the "flags" argument at the start, we do not want to
> delay the "case 0:" check until we have f.file (so that we can check
> f.file->f_flags).

Fair point. I was thinking delaying it would make it simpler, but then
you have to free the file and it's less fast in the EINVAL case. I
also don't have a strong opinion here.

Tycho