lkml.org 
[lkml]   [2008]   [Nov]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 2/2] Add support for in-kernel process creation during restart
Date
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


\
 
 \ /
  Last update: 2008-11-26 06:11    [W:0.064 / U:0.408 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site