From: Jiri Kosina on
On Mon, 19 Oct 2009, Felipe Contreras wrote:

> Commit a0d092f introduced the following warning:
> ipc/msg.c: In function ?msgctl_down?:
> ipc/msg.c:415: warning: ?msqid64? may be used uninitialized in this function
>
> Signed-off-by: Felipe Contreras <felipe.contreras(a)gmail.com>
> ---
> ipc/msg.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/ipc/msg.c b/ipc/msg.c
> index 2ceab7f..085bd58 100644
> --- a/ipc/msg.c
> +++ b/ipc/msg.c
> @@ -412,7 +412,7 @@ static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd,
> struct msqid_ds __user *buf, int version)
> {
> struct kern_ipc_perm *ipcp;
> - struct msqid64_ds msqid64;
> + struct msqid64_ds uninitialized_var(msqid64);
> struct msg_queue *msq;
> int err;

What gcc are you using? I am not getting any warning at least with gcc
"(SUSE Linux) 4.3.1 20080507 (prerelease) [gcc-4_3-branch revision
135036]"

$ make ipc/msg.o
CHK include/linux/version.h
CHK include/linux/utsrelease.h
SYMLINK include/asm -> include/asm-x86
CALL scripts/checksyscalls.sh
CC ipc/msg.o
$

--
Jiri Kosina
SUSE Labs, Novell Inc.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Jiri Kosina on
On Mon, 19 Oct 2009, Felipe Contreras wrote:

> >> ipc/msg.c: In function ?msgctl_down?:
> >> ipc/msg.c:415: warning: ?msqid64? may be used uninitialized in this function
> >>
> >> Signed-off-by: Felipe Contreras <felipe.contreras(a)gmail.com>
> >> ---
> >>  ipc/msg.c |    2 +-
> >>  1 files changed, 1 insertions(+), 1 deletions(-)
> >>
> >> diff --git a/ipc/msg.c b/ipc/msg.c
> >> index 2ceab7f..085bd58 100644
> >> --- a/ipc/msg.c
> >> +++ b/ipc/msg.c
> >> @@ -412,7 +412,7 @@ static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd,
> >>                      struct msqid_ds __user *buf, int version)
> >>  {
> >>       struct kern_ipc_perm *ipcp;
> >> -     struct msqid64_ds msqid64;
> >> +     struct msqid64_ds uninitialized_var(msqid64);
> >>       struct msg_queue *msq;
> >>       int err;
> >
> > What gcc are you using? I am not getting any warning at least with gcc
> > "(SUSE Linux) 4.3.1 20080507 (prerelease) [gcc-4_3-branch revision
> > 135036]"
>
> gcc (GCC) 4.4.1 20090725 (Red Hat 4.4.1-2)
>
> Since I moved to Fedora 11 I get more warnings than other people,
> possibly because gcc 4.4.

Wouldn't it be better just to report this to gcc developers as a bug
instead?

I have verified both with 4.1 and 4.3, and it doesn't emit this
false-positive warning, so there have been gcc versions getting this
right. Ergo gcc developers should rather fix this "regression" and revert
to the old behavior, methinks.

--
Jiri Kosina
SUSE Labs, Novell Inc.
From: Felipe Contreras on
On Mon, Oct 19, 2009 at 5:12 PM, Jiri Kosina <jkosina(a)suse.cz> wrote:
> On Mon, 19 Oct 2009, Felipe Contreras wrote:
>
>> Commit a0d092f introduced the following warning:
>> ipc/msg.c: In function ?msgctl_down?:
>> ipc/msg.c:415: warning: ?msqid64? may be used uninitialized in this function
>>
>> Signed-off-by: Felipe Contreras <felipe.contreras(a)gmail.com>
>> ---
>>  ipc/msg.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/ipc/msg.c b/ipc/msg.c
>> index 2ceab7f..085bd58 100644
>> --- a/ipc/msg.c
>> +++ b/ipc/msg.c
>> @@ -412,7 +412,7 @@ static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd,
>>                      struct msqid_ds __user *buf, int version)
>>  {
>>       struct kern_ipc_perm *ipcp;
>> -     struct msqid64_ds msqid64;
>> +     struct msqid64_ds uninitialized_var(msqid64);
>>       struct msg_queue *msq;
>>       int err;
>
> What gcc are you using? I am not getting any warning at least with gcc
> "(SUSE Linux) 4.3.1 20080507 (prerelease) [gcc-4_3-branch revision
> 135036]"

gcc (GCC) 4.4.1 20090725 (Red Hat 4.4.1-2)

Since I moved to Fedora 11 I get more warnings than other people,
possibly because gcc 4.4.

--
Felipe Contreras
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Jiri Kosina on
On Mon, 19 Oct 2009, Felipe Contreras wrote:

> >> >> ipc/msg.c: In function ?msgctl_down?:
> >> >> ipc/msg.c:415: warning: ?msqid64? may be used uninitialized in this function
> >> >>
> >> >> Signed-off-by: Felipe Contreras <felipe.contreras(a)gmail.com>
> >> >> ---
> >> >>  ipc/msg.c |    2 +-
> >> >>  1 files changed, 1 insertions(+), 1 deletions(-)
> >> >>
> >> >> diff --git a/ipc/msg.c b/ipc/msg.c
> >> >> index 2ceab7f..085bd58 100644
> >> >> --- a/ipc/msg.c
> >> >> +++ b/ipc/msg.c
> >> >> @@ -412,7 +412,7 @@ static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd,
> >> >>                      struct msqid_ds __user *buf, int version)
> >> >>  {
> >> >>       struct kern_ipc_perm *ipcp;
> >> >> -     struct msqid64_ds msqid64;
> >> >> +     struct msqid64_ds uninitialized_var(msqid64);
> >> >>       struct msg_queue *msq;
> >> >>       int err;
[ ... snip ... ]
> > I have verified both with 4.1 and 4.3, and it doesn't emit this
> > false-positive warning, so there have been gcc versions getting this
> > right. Ergo gcc developers should rather fix this "regression" and revert
> > to the old behavior, methinks.
>
> The other possibility is that the bug was in gcc 4.1/4.3, and now 4.4
> finds an actual problem in the code. I will try to dig deeper to see
> what's actually happening... at first glance I don't see who is
> initializing msqid64.

This statement of your makes me wonder why you have submitted the patch in
the first place, as you are apparently not sure whether adding
uninitialized_var() is a valid thing to do or not.

The gcc warning in this case is actually bogus, as msqid64 is touched only
iff cmd == IPC_SET, and in such case, copy_msqid_from_user() initializes
it properly.

--
Jiri Kosina
SUSE Labs, Novell Inc.
From: Felipe Contreras on
On Mon, Oct 19, 2009 at 5:57 PM, Jiri Kosina <jkosina(a)suse.cz> wrote:
> On Mon, 19 Oct 2009, Felipe Contreras wrote:
>
>> >> ipc/msg.c: In function ?msgctl_down?:
>> >> ipc/msg.c:415: warning: ?msqid64? may be used uninitialized in this function
>> >>
>> >> Signed-off-by: Felipe Contreras <felipe.contreras(a)gmail.com>
>> >> ---
>> >>  ipc/msg.c |    2 +-
>> >>  1 files changed, 1 insertions(+), 1 deletions(-)
>> >>
>> >> diff --git a/ipc/msg.c b/ipc/msg.c
>> >> index 2ceab7f..085bd58 100644
>> >> --- a/ipc/msg.c
>> >> +++ b/ipc/msg.c
>> >> @@ -412,7 +412,7 @@ static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd,
>> >>                      struct msqid_ds __user *buf, int version)
>> >>  {
>> >>       struct kern_ipc_perm *ipcp;
>> >> -     struct msqid64_ds msqid64;
>> >> +     struct msqid64_ds uninitialized_var(msqid64);
>> >>       struct msg_queue *msq;
>> >>       int err;
>> >
>> > What gcc are you using? I am not getting any warning at least with gcc
>> > "(SUSE Linux) 4.3.1 20080507 (prerelease) [gcc-4_3-branch revision
>> > 135036]"
>>
>> gcc (GCC) 4.4.1 20090725 (Red Hat 4.4.1-2)
>>
>> Since I moved to Fedora 11 I get more warnings than other people,
>> possibly because gcc 4.4.
>
> Wouldn't it be better just to report this to gcc developers as a bug
> instead?

If it's a gcc bug, yes.

> I have verified both with 4.1 and 4.3, and it doesn't emit this
> false-positive warning, so there have been gcc versions getting this
> right. Ergo gcc developers should rather fix this "regression" and revert
> to the old behavior, methinks.

The other possibility is that the bug was in gcc 4.1/4.3, and now 4.4
finds an actual problem in the code. I will try to dig deeper to see
what's actually happening... at first glance I don't see who is
initializing msqid64.

--
Felipe Contreras
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/