public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] selinux: Use kmemdup instead of kmalloc + memcpy
@ 2013-09-26  2:47 Duan Jiong
  2013-09-26 20:03 ` Paul Moore
  0 siblings, 1 reply; 2+ messages in thread
From: Duan Jiong @ 2013-09-26  2:47 UTC (permalink / raw)
  To: sds, james.l.morris, eparis; +Cc: linux-security-module, linux-kernel



Signed-off-by: Duan Jiong <duanj.fnst@cn.fujitsu.com>
---
 security/selinux/xfrm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/security/selinux/xfrm.c b/security/selinux/xfrm.c
index 425b9f9..5c809c1 100644
--- a/security/selinux/xfrm.c
+++ b/security/selinux/xfrm.c
@@ -268,10 +268,10 @@ int selinux_xfrm_policy_clone(struct xfrm_sec_ctx *old_ctx,
 	if (!old_ctx)
 		return 0;
 
-	new_ctx = kmalloc(sizeof(*old_ctx) + old_ctx->ctx_len, GFP_ATOMIC);
+	new_ctx = kmemdup(old_ctx, sizeof(*old_ctx) + old_ctx->ctx_len,
+			GFP_ATOMIC);
 	if (!new_ctx)
 		return -ENOMEM;
-	memcpy(new_ctx, old_ctx, sizeof(*old_ctx) + old_ctx->ctx_len);
 	atomic_inc(&selinux_xfrm_refcount);
 	*new_ctxp = new_ctx;
 
-- 
1.8.3.1

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

* Re: [PATCH] selinux: Use kmemdup instead of kmalloc + memcpy
  2013-09-26  2:47 [PATCH] selinux: Use kmemdup instead of kmalloc + memcpy Duan Jiong
@ 2013-09-26 20:03 ` Paul Moore
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Moore @ 2013-09-26 20:03 UTC (permalink / raw)
  To: Duan Jiong
  Cc: sds, james.l.morris, eparis, linux-security-module, linux-kernel,
	selinux

On Thursday, September 26, 2013 10:47:52 AM Duan Jiong wrote:
> Signed-off-by: Duan Jiong <duanj.fnst@cn.fujitsu.com>
> ---
>  security/selinux/xfrm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

FYI: SELinux patches should be sent to the SELinux mailing list (I added it to 
the CC list).  You can also CC the LSM list if you like, but they *need* to be 
sent to the SELinux list in the future.

I did some minor whitespace/alignment fixup and merged your patch; it is 
queued up for 3.13.

 * git://git.infradead.org/users/pcmoore/selinux

> diff --git a/security/selinux/xfrm.c b/security/selinux/xfrm.c
> index 425b9f9..5c809c1 100644
> --- a/security/selinux/xfrm.c
> +++ b/security/selinux/xfrm.c
> @@ -268,10 +268,10 @@ int selinux_xfrm_policy_clone(struct xfrm_sec_ctx
> *old_ctx, if (!old_ctx)
>  		return 0;
> 
> -	new_ctx = kmalloc(sizeof(*old_ctx) + old_ctx->ctx_len, GFP_ATOMIC);
> +	new_ctx = kmemdup(old_ctx, sizeof(*old_ctx) + old_ctx->ctx_len,
> +			GFP_ATOMIC);
>  	if (!new_ctx)
>  		return -ENOMEM;
> -	memcpy(new_ctx, old_ctx, sizeof(*old_ctx) + old_ctx->ctx_len);
>  	atomic_inc(&selinux_xfrm_refcount);
>  	*new_ctxp = new_ctx;

-- 
paul moore
www.paul-moore.com


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

end of thread, other threads:[~2013-09-26 20:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-26  2:47 [PATCH] selinux: Use kmemdup instead of kmalloc + memcpy Duan Jiong
2013-09-26 20:03 ` Paul Moore

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