]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
dtrace: failing to allocate more ECB space can cause a crash
authorKris Van Hees <kris.van.hees@oracle.com>
Fri, 21 Jul 2017 02:51:44 +0000 (22:51 -0400)
committerTomas Jedlicka <tomas.jedlicka@oracle.com>
Thu, 14 Sep 2017 09:11:59 +0000 (11:11 +0200)
The existing code was not taking into consideration that when the
table of ECBs needs to be expanded, the memory allocation can fail.
This could lead to a NULL pointer access, and a kernel crash.  We
now check the result of the allocation, and bail out if it fails.

Orabug: 26503342
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Reviewed-by: Tomas Jedlicka <tomas.jedlicka@oracle.com>
dtrace/dtrace_ecb.c

index f26c85213aba98724ef4812f11743472100991f5..7b2bd735da6df37c1f9876fb1799287402b77fb2 100644 (file)
@@ -547,6 +547,11 @@ static dtrace_ecb_t *dtrace_ecb_add(dtrace_state_t *state,
                }
 
                ecbs = vzalloc(necbs * sizeof(*ecbs));
+               if (ecbs == NULL) {
+                       kfree(ecb);
+                       return NULL;
+               }
+
                if (oecbs != NULL)
                        memcpy(ecbs, oecbs, state->dts_necbs * sizeof(*ecbs));
 
@@ -591,6 +596,9 @@ static dtrace_ecb_t *dtrace_ecb_create(dtrace_state_t *state,
        ASSERT(state != NULL);
 
        ecb = dtrace_ecb_add(state, probe);
+       if (ecb == NULL)
+               return NULL;
+
        ecb->dte_uarg = desc->dted_uarg;
 
        if ((pred = desc->dted_pred.dtpdd_predicate) != NULL) {