public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 5/5] security/selinux/ss: correct size computation
@ 2009-12-06  9:16 Julia Lawall
  2009-12-07 15:02 ` Eric Paris
  2009-12-07 22:11 ` James Morris
  0 siblings, 2 replies; 3+ messages in thread
From: Julia Lawall @ 2009-12-06  9:16 UTC (permalink / raw)
  To: Stephen Smalley, James Morris, Eric Paris, linux-security-module,
	linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>

The size argument to kcalloc should be the size of desired structure,
not the pointer to it.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@expression@
expression *x;
@@

x =
 <+...
-sizeof(x)
+sizeof(*x)
...+>// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 security/selinux/ss/services.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff -u -p a/security/selinux/ss/services.c b/security/selinux/ss/services.c
--- a/security/selinux/ss/services.c
+++ b/security/selinux/ss/services.c
@@ -2555,7 +2555,7 @@ int security_get_classes(char ***classes
 	read_lock(&policy_rwlock);
 
 	*nclasses = policydb.p_classes.nprim;
-	*classes = kcalloc(*nclasses, sizeof(*classes), GFP_ATOMIC);
+	*classes = kcalloc(*nclasses, sizeof(**classes), GFP_ATOMIC);
 	if (!*classes)
 		goto out;
 
@@ -2602,7 +2602,7 @@ int security_get_permissions(char *class
 	}
 
 	*nperms = match->permissions.nprim;
-	*perms = kcalloc(*nperms, sizeof(*perms), GFP_ATOMIC);
+	*perms = kcalloc(*nperms, sizeof(**perms), GFP_ATOMIC);
 	if (!*perms)
 		goto out;
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 5/5] security/selinux/ss: correct size computation
  2009-12-06  9:16 [PATCH 5/5] security/selinux/ss: correct size computation Julia Lawall
@ 2009-12-07 15:02 ` Eric Paris
  2009-12-07 22:11 ` James Morris
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Paris @ 2009-12-07 15:02 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Stephen Smalley, James Morris, linux-security-module,
	linux-kernel, kernel-janitors

On Sun, 2009-12-06 at 10:16 +0100, Julia Lawall wrote:
> From: Julia Lawall <julia@diku.dk>
> 
> The size argument to kcalloc should be the size of desired structure,
> not the pointer to it.
> 
> The semantic patch that makes this change is as follows:
> (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @expression@
> expression *x;
> @@
> 
> x =
>  <+...
> -sizeof(x)
> +sizeof(*x)
> ...+>// </smpl>
> 
> Signed-off-by: Julia Lawall <julia@diku.dk>

Acked-by: Eric Paris <eparis@redhat.com>

no real hurry, to get this in, the sizeof() is the same in either case,
but it should be fixed.


> 
> ---
>  security/selinux/ss/services.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff -u -p a/security/selinux/ss/services.c b/security/selinux/ss/services.c
> --- a/security/selinux/ss/services.c
> +++ b/security/selinux/ss/services.c
> @@ -2555,7 +2555,7 @@ int security_get_classes(char ***classes
>  	read_lock(&policy_rwlock);
>  
>  	*nclasses = policydb.p_classes.nprim;
> -	*classes = kcalloc(*nclasses, sizeof(*classes), GFP_ATOMIC);
> +	*classes = kcalloc(*nclasses, sizeof(**classes), GFP_ATOMIC);
>  	if (!*classes)
>  		goto out;
>  
> @@ -2602,7 +2602,7 @@ int security_get_permissions(char *class
>  	}
>  
>  	*nperms = match->permissions.nprim;
> -	*perms = kcalloc(*nperms, sizeof(*perms), GFP_ATOMIC);
> +	*perms = kcalloc(*nperms, sizeof(**perms), GFP_ATOMIC);
>  	if (!*perms)
>  		goto out;
>  



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 5/5] security/selinux/ss: correct size computation
  2009-12-06  9:16 [PATCH 5/5] security/selinux/ss: correct size computation Julia Lawall
  2009-12-07 15:02 ` Eric Paris
@ 2009-12-07 22:11 ` James Morris
  1 sibling, 0 replies; 3+ messages in thread
From: James Morris @ 2009-12-07 22:11 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Stephen Smalley, Eric Paris, linux-security-module, linux-kernel,
	kernel-janitors

On Sun, 6 Dec 2009, Julia Lawall wrote:

> From: Julia Lawall <julia@diku.dk>
> 
> The size argument to kcalloc should be the size of desired structure,
> not the pointer to it.
> 
> The semantic patch that makes this change is as follows:
> (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @expression@
> expression *x;
> @@
> 
> x =
>  <+...
> -sizeof(x)
> +sizeof(*x)
> ...+>// </smpl>
> 
> Signed-off-by: Julia Lawall <julia@diku.dk>


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:[~2009-12-07 22:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-06  9:16 [PATCH 5/5] security/selinux/ss: correct size computation Julia Lawall
2009-12-07 15:02 ` Eric Paris
2009-12-07 22:11 ` James Morris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox