From: Andrey Mirkin <major@openvz.org>
To: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Andrey Mirkin <major@openvz.org>,
orenl@cs.columbia.edu, containers@lists.linux-foundation.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] Add support for in-kernel process creation during restart
Date: Wed, 26 Nov 2008 09:07:43 +0400 [thread overview]
Message-ID: <200811260807.45094.major@openvz.org> (raw)
In-Reply-To: <20081125004024.GA4440@x200.localdomain>
On Tuesday 25 November 2008 03:45 Alexey Dobriyan wrote:
> On Mon, Nov 24, 2008 at 06:39:35PM +0300, Andrey Mirkin wrote:
> > +static int cr_rstr_task_struct(struct cr_ctx *ctx, struct cr_hdr_task
> > *ht) +{
> > + struct task_struct *t = current;
> > + char *buf;
> > + int ret = -EINVAL;
> > +
> > + /* upper limit for task_comm_len to prevent DoS */
> > + if (ht->task_comm_len < 0 || ht->task_comm_len > PAGE_SIZE)
> > + goto out;
> > +
> > + buf = kmalloc(ht->task_comm_len, GFP_KERNEL);
> > + if (!buf)
> > + goto out;
> > + ret = cr_read_string(ctx, buf, ht->task_comm_len);
> > + if (!ret) {
> > + /* if t->comm is too long, silently truncate */
> > + memset(t->comm, 0, TASK_COMM_LEN);
> > + memcpy(t->comm, buf, min(ht->task_comm_len, TASK_COMM_LEN));
> > + }
> > + kfree(buf);
> > +
> > + /* FIXME: restore remaining relevant task_struct fields */
> > +out:
> > + return ret;
> > +}
>
> ->comm is only 16 bytes wide, you can just use on-stack variable.
Yes, you right here.
But who knows how it can be changed later.
Also we have almost the same function for process restore from user space.
In next version I will use it instead of introducing new one.
Andrey
next prev parent reply other threads:[~2008-11-26 5:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-24 15:39 [PATCH 0/2] In-kernel process restart Andrey Mirkin
2008-11-24 15:39 ` [PATCH 1/2] Add flags for user-space and in-kernel process creation Andrey Mirkin
2008-11-24 15:39 ` [PATCH 2/2] Add support for in-kernel process creation during restart Andrey Mirkin
2008-11-25 0:45 ` Alexey Dobriyan
2008-11-26 5:07 ` Andrey Mirkin [this message]
2008-11-25 20:17 ` Oren Laadan
2008-11-26 11:58 ` Andrey Mirkin
2008-11-24 16:02 ` [PATCH 1/2] Add flags for user-space and in-kernel process creation Louis Rilling
2008-11-26 4:55 ` Andrey Mirkin
2008-11-25 20:02 ` [PATCH 0/2] In-kernel process restart Oren Laadan
2008-11-26 11:44 ` Andrey Mirkin
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=200811260807.45094.major@openvz.org \
--to=major@openvz.org \
--cc=adobriyan@gmail.com \
--cc=containers@lists.linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=orenl@cs.columbia.edu \
/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