lkml.org 
[lkml]   [2006]   [Jul]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] per-task delay accounting taskstats interface: control exit data through cpumasks]
* Andrew Morton <akpm@osdl.org> 2006-07-06 14:48
> In the interests of keeping this work decoupled from netlink enhancements
> I'd propose the below. Is it bad to modify the data at nla_data()?

Yes, it points into a skb data buffer which may be shared by sitting
on other queues if the message is to be broadcasted. In this case it
would be harmless but the policy is to leave it unmodified. Otherwise
I agree it's better to move forward and not wait for the API change.

> --- a/kernel/taskstats.c~per-task-delay-accounting-taskstats-interface-control-exit-data-through-cpumasks-fix
> +++ a/kernel/taskstats.c
> @@ -299,6 +299,23 @@ cleanup:
> return 0;
> }
>
> +static int parse(struct nlattr *na, cpumask_t *mask)
> +{
> + char *data;
> + int len;
> +
> + if (na == NULL)
> + return 1;
> + len = nla_len(na);
> + if (len > TASKSTATS_CPUMASK_MAXLEN)
> + return -E2BIG;
> + if (len < 1)
> + return -EINVAL;
> + data = nla_data(na);
> + data[len - 1] = '\0';
> + return cpulist_parse(data, *mask);
> +}

Usually this is done by using strlcpy:

Example fro genetlink.c
if (info->attrs[CTRL_ATTR_FAMILY_NAME]) {
char name[GENL_NAMSIZ];

if (nla_strlcpy(name, info->attrs[CTRL_ATTR_FAMILY_NAME],
GENL_NAMSIZ) >= GENL_NAMSIZ)
goto errout;

res = genl_family_find_byname(name);
}
-
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/

\
 
 \ /
  Last update: 2006-07-07 00:43    [W:0.068 / U:0.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site