[Xen-devel] [PATCH for-4.13] xen/xsm: flask: Check xmalloc_array() return in security_sid_to_context()

Julien Grall posted 1 patch 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/xen tags/patchew/20191004165646.14482-1-julien.grall@arm.com
xen/xsm/flask/ss/services.c | 2 ++
1 file changed, 2 insertions(+)

[Xen-devel] [PATCH for-4.13] xen/xsm: flask: Check xmalloc_array() return in security_sid_to_context()

Posted by Julien Grall 2 weeks ago
xmalloc_array() may return NULL if there are memory. Rather than trying
to deference it directly, we should check the return value first.

Coverity-ID: 1381852
Signed-off-by: Julien Grall <julien.grall@arm.com>
---
 xen/xsm/flask/ss/services.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/xen/xsm/flask/ss/services.c b/xen/xsm/flask/ss/services.c
index b59928ea8a..42686535f2 100644
--- a/xen/xsm/flask/ss/services.c
+++ b/xen/xsm/flask/ss/services.c
@@ -775,6 +775,8 @@ int security_sid_to_context(u32 sid, char **scontext, u32 *scontext_len)
 
             *scontext_len = strlen(initial_sid_to_string[sid]) + 1;
             scontextp = xmalloc_array(char, *scontext_len);
+            if ( !scontextp )
+                return -ENOMEM;
             strlcpy(scontextp, initial_sid_to_string[sid], *scontext_len);
             *scontext = scontextp;
             goto out;
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH for-4.13] xen/xsm: flask: Check xmalloc_array() return in security_sid_to_context()

Posted by Jürgen Groß 2 weeks ago
On 04.10.19 18:56, Julien Grall wrote:
> xmalloc_array() may return NULL if there are memory. Rather than trying
> to deference it directly, we should check the return value first.
> 
> Coverity-ID: 1381852
> Signed-off-by: Julien Grall <julien.grall@arm.com>

Release-acked-by: Juergen Gross <jgross@suse.com>


Juergen

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel