From: Oleg Nesterov <oleg@redhat.com>
To: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>,
Paul Menage <paul@paulmenage.org>,
linux-kernel@vger.kernel.org,
Sebastian Ott <sebott@linux.vnet.ibm.com>
Subject: Re: cgroup_release_agent() with call_usermodehelper() with UMH_WAIT_EXEC may crash
Date: Fri, 3 Feb 2012 17:04:54 +0100 [thread overview]
Message-ID: <20120203160454.GA3092@redhat.com> (raw)
In-Reply-To: <20120203154411.GB2471@osiris.boeblingen.de.ibm.com>
On 02/03, Heiko Carstens wrote:
>
> setup_new_exec(...)
> [...]
> name = bprm->filename;
>
> /* Copies the binary name from after last slash */
> for (i=0; (ch = *(name++)) != '\0';) { <-- crashes here
> if (ch == '/')
Ough, and this happens after flush_old_exec()...
> Looking into the dump I was able to tell that the piece of memory got freed
> by cgroup_release_agent().
> Which has the following code sequence:
>
> static void cgroup_release_agent(struct work_struct *work)
> {
> [...]
> agentbuf = kstrdup(cgrp->root->release_agent_path, GFP_KERNEL);
> [...]
> i = 0;
> argv[i++] = agentbuf;
> [...]
> call_usermodehelper(argv[0], argv, envp, UMH_WAIT_EXEC);
> [...]
> kfree(agentbuf);
> [...]
> }
>
> So obviously cgroup_release_agent() freed the filename before do_execve()
> was finished.
Good catch.
> So the question is: what is broken? The cgroup stuff which doesn't take
> into account that the passed path may still be in use and hence can't
> be freed (simple fix would be to simply use UMH_WAIT_PROC instead).
> Or is it that call_usermodehelper() still uses the passed path after
> it returned?
Well, it seems that do_coredump() has the same problem.
Can't we simply move that code into flush_old_exec() ? (wrapped into
the new helper).
Oleg.
next prev parent reply other threads:[~2012-02-03 16:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-03 15:44 cgroup_release_agent() with call_usermodehelper() with UMH_WAIT_EXEC may crash Heiko Carstens
2012-02-03 16:04 ` Oleg Nesterov [this message]
2012-02-03 16:48 ` Linus Torvalds
2012-02-04 10:03 ` Heiko Carstens
2012-02-04 15:16 ` Linus Torvalds
2012-02-05 4:12 ` Heiko Carstens
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=20120203160454.GA3092@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=heiko.carstens@de.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paul@paulmenage.org \
--cc=sebott@linux.vnet.ibm.com \
--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