From: Michal Hocko <mhocko@suse.cz>
To: Glauber Costa <glommer@parallels.com>
Cc: linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
torvalds@linux-foundation.org,
Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: Re: [PATCH] fork: fix oops after fork failure
Date: Thu, 23 Aug 2012 16:33:12 +0200 [thread overview]
Message-ID: <20120823143312.GA23636@dhcp22.suse.cz> (raw)
In-Reply-To: <1345727326-18730-1-git-send-email-glommer@parallels.com>
On Thu 23-08-12 17:08:46, Glauber Costa wrote:
> When we want to duplicate a new process, dup_task_struct() will undergo
> a series of allocations. If alloc_thread_info_node() fails, we call
> free_task_struct() and return.
>
> This seems right, but it is not. free_task_struct() will not only free
> the task struct from the kmem_cache, but will also call
> arch_release_task_struct(). The problem is that this function is
> supposed to undo whatever arch-specific work done by
> arch_dup_task_struct(), that is not yet called at this point. The
> particular problem I ran accross was that in x86, we will arrive at
> fpu_free() without having ever allocated it.
>
> This code is very ancient, and according to git, it is there since the
> pre-git era. But forks don't fail that often, so that made it well
> hidden.
>
> Signed-off-by: Glauber Costa <glommer@parallels.com>
> Reported-by: Frederic Weisbecker <fweisbec@redhat.com>
> ---
> kernel/fork.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/fork.c b/kernel/fork.c
> index 152d023..b397435 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -299,7 +299,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
>
> ti = alloc_thread_info_node(tsk, node);
> if (!ti) {
> - free_task_struct(tsk);
> + kmem_cache_free(task_struct_cachep, tsk);
What about ia64 (or !CONFIG_ARCH_THREAD_INFO_ALLOCATOR in general) which
doesn't allocate thread_info at all?
> return NULL;
> }
>
> --
> 1.7.11.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2012-08-23 14:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-23 13:08 Glauber Costa
2012-08-23 14:33 ` Michal Hocko [this message]
2012-08-23 14:38 ` Glauber Costa
2012-08-23 14:38 ` Michal Hocko
2012-08-23 14:45 ` Michal Hocko
2012-08-23 14:43 ` Glauber Costa
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=20120823143312.GA23636@dhcp22.suse.cz \
--to=mhocko@suse.cz \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=glommer@parallels.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome