summaryrefslogtreecommitdiffstats
path: root/security/selinux/xfrm.c
diff options
context:
space:
mode:
authorVenkat Yekkirala <vyekkirala@trustedcs.com>2007-07-24 16:53:23 +0200
committerJames Morris <jmorris@namei.org>2007-07-25 18:49:41 +0200
commit910949a66839ff5f59fede5b7cb68ecf1453e22c (patch)
tree6842924dba1c4af0397d06aa4b6363e8c26c220e /security/selinux/xfrm.c
parentMerge branch 'for_paulus' of master.kernel.org:/pub/scm/linux/kernel/git/gala... (diff)
downloadlinux-910949a66839ff5f59fede5b7cb68ecf1453e22c.tar.xz
linux-910949a66839ff5f59fede5b7cb68ecf1453e22c.zip
SELinux: null-terminate context string in selinux_xfrm_sec_ctx_alloc
xfrm_audit_log() expects the context string to be null-terminated which currently doesn't happen with user-supplied contexts. Signed-off-by: Venkat Yekkirala <vyekkirala@TrustedCS.com> Acked-by: Stephen Smalley <sds@tycho.nsa.gov> Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security/selinux/xfrm.c')
-rw-r--r--security/selinux/xfrm.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/security/selinux/xfrm.c b/security/selinux/xfrm.c
index bd8d1ef40a90..ba715f40b658 100644
--- a/security/selinux/xfrm.c
+++ b/security/selinux/xfrm.c
@@ -216,7 +216,7 @@ static int selinux_xfrm_sec_ctx_alloc(struct xfrm_sec_ctx **ctxp,
return -ENOMEM;
*ctxp = ctx = kmalloc(sizeof(*ctx) +
- uctx->ctx_len,
+ uctx->ctx_len + 1,
GFP_KERNEL);
if (!ctx)
@@ -229,6 +229,7 @@ static int selinux_xfrm_sec_ctx_alloc(struct xfrm_sec_ctx **ctxp,
memcpy(ctx->ctx_str,
uctx+1,
ctx->ctx_len);
+ ctx->ctx_str[ctx->ctx_len] = 0;
rc = security_context_to_sid(ctx->ctx_str,
ctx->ctx_len,
&ctx->ctx_sid);