Fix SVACE issues 09/171109/3
authorAlexander Aksenov <a.aksenov@samsung.com>
Tue, 20 Feb 2018 16:35:02 +0000 (19:35 +0300)
committerAlexander Aksenov <a.aksenov@samsung.com>
Wed, 28 Feb 2018 16:29:11 +0000 (19:29 +0300)
- add limit for splice data reading;
- remove path memleak from wsp.

Change-Id: I9dc26627f16f912843350ddbc6d1a6028d3643e4
Signed-off-by: Alexander Aksenov <a.aksenov@samsung.com>
modules/driver/driver_to_buffer.c
modules/wsp/wsp.c
modules/wsp/wsp_res.c

index 80683a44f6fc624b9ecc8526e67bab5f102baa21..cbc1edc633e00951f3a5ca62718bd8b182aabff0 100644 (file)
@@ -257,10 +257,11 @@ int driver_to_buffer_fill_spd(struct splice_pipe_desc *spd)
                spd->nr_pages++;
                data_to_splice -= read_from_current_page;
 
-               /* TODO: add check for pipe->buffers exceeding */
-               /* if (spd->nr_pages == pipe->buffers) { */
-               /*      break; */
-               /* } */
+               if (spd->nr_pages > spd->nr_pages_max) {
+                       print_err("Too much data to read! Left : %u\n",
+                                 data_to_splice);
+                       break;
+               }
        }
        return 0;
 }
index 66b8cbe1bad23e564bb08aa50d19c1bfd681526a..9de5e41034e30abf05e82f73f63c8411a00f0b9f 100644 (file)
@@ -99,6 +99,8 @@ static int res_request_handle(struct uprobe *p, struct pt_regs *regs)
                        wsp_msg(WSP_RES_LOAD_BEGIN, id, path);
        }
 
+       kfree(path);
+
        return 0;
 }
 
index 2ad640fc5cde5fde7e699493863a848309955281..fee1adc6a05fdb57dbad47b90c9fa691aeea9eae 100644 (file)
@@ -109,7 +109,13 @@ int wsp_resource_data_add(unsigned long addr, char *path)
        if (p) {
                p->id = __wsp_resource_id();
                p->addr = addr;
-               p->path = path;
+               p->path = kstrndup(path, PATH_MAX, GFP_KERNEL);
+               if (!p->path) {
+                       kfree(p);
+                       ret = -ENOMEM;
+                       goto out;
+               }
+
                list_add_tail(&p->list, &__resources_list);
                ret = p->id;
        }