mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Evgeny Kuznetsov <EXT-Eugeny.Kuznetsov@nokia.com>
To: "ext Michał Nazarewicz" <m.nazarewicz@samsung.com>
Cc: akpm@linux-foundation.org, torvalds@linux-foundation.org,
	mingo@elte.hu, gregkh@suse.de, a.p.zijlstra@chello.nl,
	xiaosuo@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] wait: using uninitialized member of wait queue
Date: Tue, 05 Oct 2010 15:00:38 +0400	[thread overview]
Message-ID: <1286276438.24366.42.camel@ekuznets-lx-nokia> (raw)
In-Reply-To: <op.vj3mn1fl7p4s8u@pikus>

Hi,

'wait_queue_t' is passed to prepare_to_wait() function where 'flags' is
used, e.g:
File: /mm/mempool.c
void * mempool_alloc(mempool_t *pool, gfp_t gfp_mask)
{       .....
         .....
	init_wait(&wait);
	prepare_to_wait(&pool->wait, &wait, TASK_UNINTERRUPTIBLE);
	.....
}

Best Regards,
Evgeny

On Tue, 2010-10-05 at 12:41 +0200, ext Michał Nazarewicz wrote:
> On Tue, 05 Oct 2010 10:47:57 +0200, Evgeny Kuznetsov
> <EXT-Eugeny.Kuznetsov@nokia.com> wrote:
> > Member "flags" of "wait_queue_t" struct  is used in several places
> in
> > kernel code without beeing initialized. "flags" is used in bitwise
> operations.
>                        ^^^^^^ -- "being"
> 
> > If "flags" not initialized then unexpected behaviour may have place.
> > Incorrect flags maybe used later in code.
> > Struct "wait_queue_t" is initialized in function "init_wait()". But
> > "init_wait()" do not initialize "flag" member.
>                  ^^ -- does         ^^^^ -- "flags"
> 
> > Added initialization of "wait_queue_t.flags" with zero value into
> "init_wait".
> 
> > diff --git a/include/linux/wait.h b/include/linux/wait.h
> > index 0836ccc..3efc9f3 100644
> > --- a/include/linux/wait.h
> > +++ b/include/linux/wait.h
> > @@ -614,6 +614,7 @@ int wake_bit_function(wait_queue_t *wait,
> unsigned mode, int sync, void *key);
> >               (wait)->private =
> current;                              \
> >               (wait)->func =
> autoremove_wake_function;                \
> >               INIT_LIST_HEAD(&(wait)->task_list);                     \
> > +             (wait)->flags =
> 0;                                      \
> >       } while (0)
> > /**
> 
> I'd turn init_wait() into a static inline.  Otherwise looks good to
> me.
> (Interestingly, init_wait() is used only in 3 places in the kernel and
> none uses flags.)
> 
> -- 
> Best regards,                                        _     _
> | Humble Liege of Serenely Enlightened Majesty of  o' \,=./ `o
> | Computer Science,  Michał "mina86" Nazarewicz       (o o)
> +----[mina86*mina86.com]---[mina86*jabber.org]----ooO--(_)--Ooo-- 


  reply	other threads:[~2010-10-05 11:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-05  8:47 [PATCH 0/1] " Evgeny Kuznetsov
2010-10-05  8:47 ` [PATCH 1/1] " Evgeny Kuznetsov
2010-10-05 10:41   ` Michał Nazarewicz
2010-10-05 11:00     ` Evgeny Kuznetsov [this message]
2010-10-05 11:39       ` Michał Nazarewicz
2010-10-05 15:43 ` [PATCH 0/1] " Linus Torvalds
2010-10-06  6:01   ` Evgeny Kuznetsov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1286276438.24366.42.camel@ekuznets-lx-nokia \
    --to=ext-eugeny.kuznetsov@nokia.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.nazarewicz@samsung.com \
    --cc=mingo@elte.hu \
    --cc=torvalds@linux-foundation.org \
    --cc=xiaosuo@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®