* [PATCH 7/10] security/selinux/ss: Use kstrdup
@ 2010-05-14 19:30 Julia Lawall
2010-05-14 20:09 ` Eric Paris
2010-05-16 23:01 ` James Morris
0 siblings, 2 replies; 3+ messages in thread
From: Julia Lawall @ 2010-05-14 19:30 UTC (permalink / raw)
To: Stephen Smalley, James Morris, Eric Paris, linux-security-module,
linux-kernel, kernel-janitors
From: Julia Lawall <julia@diku.dk>
Use kstrdup when the goal of an allocation is copy a string into the
allocated region.
The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
expression from,to;
expression flag,E1,E2;
statement S;
@@
- to = kmalloc(strlen(from) + 1,flag);
+ to = kstrdup(from, flag);
... when != \(from = E1 \| to = E1 \)
if (to=NULL || ...) S
... when != \(from = E2 \| to = E2 \)
- strcpy(to, from);
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
---
security/selinux/ss/policydb.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff -u -p a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
--- a/security/selinux/ss/policydb.c
+++ b/security/selinux/ss/policydb.c
@@ -156,12 +156,11 @@ static int roles_init(struct policydb *p
rc = -EINVAL;
goto out_free_role;
}
- key = kmalloc(strlen(OBJECT_R) + 1, GFP_KERNEL);
+ key = kstrdup(OBJECT_R, GFP_KERNEL);
if (!key) {
rc = -ENOMEM;
goto out_free_role;
}
- strcpy(key, OBJECT_R);
rc = hashtab_insert(p->p_roles.table, key, role);
if (rc)
goto out_free_key;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 7/10] security/selinux/ss: Use kstrdup
2010-05-14 19:30 [PATCH 7/10] security/selinux/ss: Use kstrdup Julia Lawall
@ 2010-05-14 20:09 ` Eric Paris
2010-05-16 23:01 ` James Morris
1 sibling, 0 replies; 3+ messages in thread
From: Eric Paris @ 2010-05-14 20:09 UTC (permalink / raw)
To: Julia Lawall
Cc: Stephen Smalley, James Morris, Eric Paris, linux-security-module,
linux-kernel, kernel-janitors
On Fri, 2010-05-14 at 21:30 +0200, Julia Lawall wrote:
> From: Julia Lawall <julia@diku.dk>
>
> Use kstrdup when the goal of an allocation is copy a string into the
> allocated region.
>
> The semantic patch that makes this change is as follows:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @@
> expression from,to;
> expression flag,E1,E2;
> statement S;
> @@
>
> - to = kmalloc(strlen(from) + 1,flag);
> + to = kstrdup(from, flag);
> ... when != \(from = E1 \| to = E1 \)
> if (to=NULL || ...) S
> ... when != \(from = E2 \| to = E2 \)
> - strcpy(to, from);
> // </smpl>
>
> Signed-off-by: Julia Lawall <julia@diku.dk>
Acked-by: Eric Paris <eparis@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 7/10] security/selinux/ss: Use kstrdup
2010-05-14 19:30 [PATCH 7/10] security/selinux/ss: Use kstrdup Julia Lawall
2010-05-14 20:09 ` Eric Paris
@ 2010-05-16 23:01 ` James Morris
1 sibling, 0 replies; 3+ messages in thread
From: James Morris @ 2010-05-16 23:01 UTC (permalink / raw)
To: Julia Lawall
Cc: Stephen Smalley, Eric Paris, linux-security-module, linux-kernel,
kernel-janitors
On Fri, 14 May 2010, Julia Lawall wrote:
> From: Julia Lawall <julia@diku.dk>
>
> Use kstrdup when the goal of an allocation is copy a string into the
> allocated region.
>
Applied to
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6#next
--
James Morris
<jmorris@namei.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-05-16 23:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-14 19:30 [PATCH 7/10] security/selinux/ss: Use kstrdup Julia Lawall
2010-05-14 20:09 ` Eric Paris
2010-05-16 23:01 ` James Morris
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).