mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexey Dobriyan <adobriyan@gmail.com>
To: Andrey Mirkin <major@openvz.org>
Cc: 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: Tue, 25 Nov 2008 03:45:11 +0300	[thread overview]
Message-ID: <20081125004024.GA4440@x200.localdomain> (raw)
In-Reply-To: <1227541175-30301-3-git-send-email-major@openvz.org>

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.

  reply	other threads:[~2008-11-25  0:41 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 [this message]
2008-11-26  5:07       ` Andrey Mirkin
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=20081125004024.GA4440@x200.localdomain \
    --to=adobriyan@gmail.com \
    --cc=containers@lists.linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=major@openvz.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

all inboxes | Powered by JetHome®