Re: [PATCH 0/1] wait: using uninitialized member of wait queue

Evgeny Kuznetsov
2010-10-06T06:05:44Z

On Tue, 2010-10-05 at 08:43 -0700, ext Linus Torvalds wrote:
> On Tue, Oct 5, 2010 at 1:47 AM, Evgeny Kuznetsov
> <EXT-Eugeny.Kuznetsov@nokia.com> wrote:
> >
> > Here is patch which fixes bug in /include/linux/wait.h file.
> > Member "flags" of "wait_queue_t" struct is used in several places in
> > kernel code without beeing initialized. "flags" is used in bitwise
> > operations. If it contain dummy data then incorrect flags may be
> > used later in code.
>
> The patch looks fine, but do you have any case of this actually
> causing problems? Afaik, we do end up initializing the part of the
> flags field we care about (WQ_FLAG_EXCLUSIVE) in prepare_to_wait()
> (and add_wait_queue()), so it looks - from an admittedly very cursory
> read - as if this is a good cleanup but shouldn't actually be the
> cause of any actual bugs.
>
> So I'll apply it, but I just wondered if you had actually seen any
> semantic changes from it?
>
> Linus
I did not see any problems caused by uninitialized flag. But this is
potential unsafe place (in case of future changes).
Also there is initialization of all members but not 'flags' in
init_wait() function. It is logical to initialize all data members.

Thanks,
Regards,
Evgeny