storaged could cause heap use after free 42/198842/5 accepted/tizen/unified/20190131.161526 submit/tizen/20190131.065956
authorpr.jung <pr.jung@samsung.com>
Wed, 30 Jan 2019 08:35:27 +0000 (17:35 +0900)
committerpr.jung <pr.jung@samsung.com>
Thu, 31 Jan 2019 06:01:51 +0000 (15:01 +0900)
- Call free() on remove_operation()(Thread)
- Access op->op on add_operation()(Main thread)

Change-Id: Iee3b3a545a04889d79f1d696dadce9d842769259
Signed-off-by: pr.jung <pr.jung@samsung.com>
src/block/block.c

index 2093858..100e9cb 100644 (file)
@@ -2025,6 +2025,14 @@ static int add_operation(struct block_device *bdev,
        op->data = data;
        op->invocation = invocation;
 
+       /* Need to disble app2ext whenever unmounting mmc */
+       if (operation == BLOCK_DEV_UNMOUNT &&
+               bdev->data->state == BLOCK_MOUNT &&
+               bdev->data->block_type == BLOCK_MMC_DEV &&
+               bdev->data->primary)
+               if (app2ext_disable_all_external_pkgs() < 0)
+                       _E("app2ext_disable_all_external_pkgs() failed");
+
        /* LOCK
         * during adding queue and checking the queue length */
        pthread_mutex_lock(&(th_manager[thread_id].mutex));
@@ -2042,15 +2050,6 @@ static int add_operation(struct block_device *bdev,
        pthread_mutex_unlock(&(th_manager[thread_id].mutex));
        /* UNLOCK */
 
-       /* Need to disble app2ext whenever unmounting mmc */
-       if (op->op == BLOCK_DEV_UNMOUNT &&
-               bdev->data->state == BLOCK_MOUNT &&
-               bdev->data->block_type == BLOCK_MMC_DEV &&
-               bdev->data->primary)
-               if (app2ext_disable_all_external_pkgs() < 0)
-                       _E("app2ext_disable_all_external_pkgs() failed");
-
-
        if (!start_th) {
                _D("Start New thread for block device");
                th_manager[thread_id].start_th = true;