From: Mandeep Singh Baines <msb-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
To: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Jiri Kosina <jkosina-AlSwsSmVLrQ@public.gmane.org>,
Mandeep Singh Baines
<msb-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Paul Menage <paul-inf54ven1CmVyaH7bEyXVA@public.gmane.org>,
Kay Sievers <kay.sievers-tD+1rO4QERM@public.gmane.org>
Subject: Re: [PATCH for-3.4-fixes] cgroup: cgroup_attach_task() could return -errno after success
Date: Thu, 29 Mar 2012 11:11:04 -0700 [thread overview]
Message-ID: <20120329181104.GC27051@google.com> (raw)
In-Reply-To: <20120329162620.GD28941-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
Tejun Heo (tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org) wrote:
> 61d1d219c4 "cgroup: remove extra calls to find_existing_css_set" made
> cgroup_task_migrate() return void. An unfortunate side effect was
> that cgroup_attach_task() was depending on that function's return
> value to clear its @retval on the success path. On cgroup mounts
> without any subsystem with ->can_attach() callback,
> cgroup_attach_task() ended up returning @retval without initializing
> it on success.
>
> For some reason, gcc failed to warn about it and it didn't cause
> cgroup_attach_task() to return non-zero value in many cases, probably
> due to difference in register allocation. When the problem
> materializes, systemd fails to populate /systemd cgroup mount and
> fails to boot.
>
> Fix it by initializing @retval to zero on declaration.
>
> Signed-off-by: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Reviewed-by: Mandeep Singh Baines <msb-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
> Reported-by: Jiri Kosina <jkosina-AlSwsSmVLrQ@public.gmane.org>
> LKML-Reference: <alpine.LNX.2.00.1203282354440.25526-ztGlSCb7Y1iN3ZZ/Hiejyg@public.gmane.org>
> ---
> Jiri, can you please confirm the fix?
>
> Thanks.
>
> kernel/cgroup.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
> index f4ea4b6..ed64cca 100644
> --- a/kernel/cgroup.c
> +++ b/kernel/cgroup.c
> @@ -1883,7 +1883,7 @@ static void cgroup_task_migrate(struct cgroup *cgrp, struct cgroup *oldcgrp,
> */
> int cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk)
> {
> - int retval;
> + int retval = 0;
> struct cgroup_subsys *ss, *failed_ss = NULL;
> struct cgroup *oldcgrp;
> struct cgroupfs_root *root = cgrp->root;
WARNING: multiple messages have this Message-ID (diff)
From: Mandeep Singh Baines <msb@chromium.org>
To: Tejun Heo <tj@kernel.org>
Cc: Jiri Kosina <jkosina@suse.cz>,
Mandeep Singh Baines <msb@chromium.org>,
lizefan@huawei.com, linux-kernel@vger.kernel.org,
cgroups@vger.kernel.org, Paul Menage <paul@paulmenage.org>,
Kay Sievers <kay.sievers@vrfy.org>
Subject: Re: [PATCH for-3.4-fixes] cgroup: cgroup_attach_task() could return -errno after success
Date: Thu, 29 Mar 2012 11:11:04 -0700 [thread overview]
Message-ID: <20120329181104.GC27051@google.com> (raw)
In-Reply-To: <20120329162620.GD28941@google.com>
Tejun Heo (tj@kernel.org) wrote:
> 61d1d219c4 "cgroup: remove extra calls to find_existing_css_set" made
> cgroup_task_migrate() return void. An unfortunate side effect was
> that cgroup_attach_task() was depending on that function's return
> value to clear its @retval on the success path. On cgroup mounts
> without any subsystem with ->can_attach() callback,
> cgroup_attach_task() ended up returning @retval without initializing
> it on success.
>
> For some reason, gcc failed to warn about it and it didn't cause
> cgroup_attach_task() to return non-zero value in many cases, probably
> due to difference in register allocation. When the problem
> materializes, systemd fails to populate /systemd cgroup mount and
> fails to boot.
>
> Fix it by initializing @retval to zero on declaration.
>
> Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Mandeep Singh Baines <msb@chromium.org>
> Reported-by: Jiri Kosina <jkosina@suse.cz>
> LKML-Reference: <alpine.LNX.2.00.1203282354440.25526@pobox.suse.cz>
> ---
> Jiri, can you please confirm the fix?
>
> Thanks.
>
> kernel/cgroup.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
> index f4ea4b6..ed64cca 100644
> --- a/kernel/cgroup.c
> +++ b/kernel/cgroup.c
> @@ -1883,7 +1883,7 @@ static void cgroup_task_migrate(struct cgroup *cgrp, struct cgroup *oldcgrp,
> */
> int cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk)
> {
> - int retval;
> + int retval = 0;
> struct cgroup_subsys *ss, *failed_ss = NULL;
> struct cgroup *oldcgrp;
> struct cgroupfs_root *root = cgrp->root;
next prev parent reply other threads:[~2012-03-29 18:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-28 22:01 cgroups commit 61d1d219c4 breaks systemd Jiri Kosina
2012-03-28 22:01 ` Jiri Kosina
[not found] ` <alpine.LNX.2.00.1203282354440.25526-ztGlSCb7Y1iN3ZZ/Hiejyg@public.gmane.org>
2012-03-29 16:04 ` Tejun Heo
2012-03-29 16:04 ` Tejun Heo
[not found] ` <20120329160433.GC28941-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2012-03-29 16:26 ` [PATCH for-3.4-fixes] cgroup: cgroup_attach_task() could return -errno after success Tejun Heo
2012-03-29 16:26 ` Tejun Heo
[not found] ` <20120329162620.GD28941-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2012-03-29 18:11 ` Mandeep Singh Baines [this message]
2012-03-29 18:11 ` Mandeep Singh Baines
2012-03-30 0:37 ` Li Zefan
2012-03-30 0:37 ` Li Zefan
2012-03-30 8:38 ` Jiri Kosina
2012-03-30 8:38 ` Jiri Kosina
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=20120329181104.GC27051@google.com \
--to=msb-f7+t8e8rja9g9huczpvpmw@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=jkosina-AlSwsSmVLrQ@public.gmane.org \
--cc=kay.sievers-tD+1rO4QERM@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
--cc=paul-inf54ven1CmVyaH7bEyXVA@public.gmane.org \
--cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.