From ce827b688bcd4a265701c3b4061dcc52887b0835 Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Wed, 10 Oct 2018 19:49:26 +0300 Subject: [PATCH 01/16] preload: fix 'dentry' leak Change-Id: I9fc3be48fd8814bc46a222198e2c747da4233479 Signed-off-by: Vyacheslav Cherkashin --- modules/preload/preload_module.c | 8 ++++++++ modules/preload/preload_process.c | 12 ++++++++++++ modules/preload/preload_process.h | 3 +++ 3 files changed, 23 insertions(+) diff --git a/modules/preload/preload_module.c b/modules/preload/preload_module.c index 41a7d4a..9077c80 100644 --- a/modules/preload/preload_module.c +++ b/modules/preload/preload_module.c @@ -560,6 +560,10 @@ static int pm_init(void) if (ret) goto out_err; + ret = pp_init(); + if (ret) + goto process_init_fail; + ret = pc_init(); if (ret) goto control_init_fail; @@ -581,6 +585,9 @@ threads_init_fail: pc_exit(); control_init_fail: + pp_exit(); + +process_init_fail: pd_exit(); out_err: @@ -592,6 +599,7 @@ static void pm_exit(void) unregister_preload_probes(); pt_exit(); pc_exit(); + pp_exit(); pd_exit(); } diff --git a/modules/preload/preload_process.c b/modules/preload/preload_process.c index 54ecbf5..538fa71 100644 --- a/modules/preload/preload_process.c +++ b/modules/preload/preload_process.c @@ -457,3 +457,15 @@ int pp_set_init_offset(unsigned long off) return 0; } + +int pp_init(void) +{ + return 0; +} + +void pp_exit(void) +{ + swap_dput(_pthread_init.dentry); + _pthread_init.dentry = NULL; + _pthread_init.off = 0; +} diff --git a/modules/preload/preload_process.h b/modules/preload/preload_process.h index 5799f9c..62fa576 100644 --- a/modules/preload/preload_process.h +++ b/modules/preload/preload_process.h @@ -16,4 +16,7 @@ void pp_disable(void); int pp_set_pthread_path(const char *path); int pp_set_init_offset(unsigned long off); +int pp_init(void); +void pp_exit(void); + #endif /* __PRELOAD_PROCESS_H__ */ -- 2.7.4 From 187b57aacfe01aa762897a5c2c5a84e841d8bfd9 Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Thu, 11 Oct 2018 13:44:04 +0300 Subject: [PATCH 02/16] wsp: remove module Change-Id: I7b3f86a91b841f774f4ce3436e3551a3e913804b Signed-off-by: Vyacheslav Cherkashin --- modules/Kbuild | 1 - modules/pack.sh | 1 - modules/wsp/Kbuild | 8 - modules/wsp/wsp.c | 400 ---------------------------------------------- modules/wsp/wsp.h | 47 ------ modules/wsp/wsp_debugfs.c | 264 ------------------------------ modules/wsp/wsp_debugfs.h | 34 ---- modules/wsp/wsp_module.c | 35 ---- modules/wsp/wsp_msg.c | 139 ---------------- modules/wsp/wsp_msg.h | 45 ------ modules/wsp/wsp_res.c | 162 ------------------- modules/wsp/wsp_res.h | 40 ----- 12 files changed, 1176 deletions(-) delete mode 100644 modules/wsp/Kbuild delete mode 100644 modules/wsp/wsp.c delete mode 100644 modules/wsp/wsp.h delete mode 100644 modules/wsp/wsp_debugfs.c delete mode 100644 modules/wsp/wsp_debugfs.h delete mode 100644 modules/wsp/wsp_module.c delete mode 100644 modules/wsp/wsp_msg.c delete mode 100644 modules/wsp/wsp_msg.h delete mode 100644 modules/wsp/wsp_res.c delete mode 100644 modules/wsp/wsp_res.h diff --git a/modules/Kbuild b/modules/Kbuild index 33154ad..d23e88c 100644 --- a/modules/Kbuild +++ b/modules/Kbuild @@ -19,7 +19,6 @@ obj-m := master/ \ retprobe/ \ preload/ \ fbiprobe/ \ - wsp/ \ nsp/ \ task_ctx/ \ got_patcher/ diff --git a/modules/pack.sh b/modules/pack.sh index 002f70d..b00f804 100755 --- a/modules/pack.sh +++ b/modules/pack.sh @@ -29,7 +29,6 @@ modules="master/swap_master.ko loader/swap_loader.ko preload/swap_preload.ko fbiprobe/swap_fbiprobe.ko - wsp/swap_wsp.ko nsp/swap_nsp.ko task_ctx/swap_taskctx.ko got_patcher/swap_gtp.ko" diff --git a/modules/wsp/Kbuild b/modules/wsp/Kbuild deleted file mode 100644 index 580bb29..0000000 --- a/modules/wsp/Kbuild +++ /dev/null @@ -1,8 +0,0 @@ -EXTRA_CFLAGS := $(extra_cflags) - -obj-m := swap_wsp.o -swap_wsp-y := wsp_module.o \ - wsp_msg.o \ - wsp_debugfs.o \ - wsp.o \ - wsp_res.o diff --git a/modules/wsp/wsp.c b/modules/wsp/wsp.c deleted file mode 100644 index 9de5e41..0000000 --- a/modules/wsp/wsp.c +++ /dev/null @@ -1,400 +0,0 @@ -/* - * @author Vyacheslav Cherkashin - * - * @section LICENSE - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * - * @section COPYRIGHT - * - * Copyright (C) Samsung Electronics, 2015 - * - * @section DESCRIPTION - * - * Web startup profiling - */ - -#include -#include -#include -#include "wsp.h" -#include "wsp_res.h" -#include "wsp_msg.h" - -struct wsp_probe { - const char *name; - struct probe_new probe; -}; - -struct wsp_bin { - const char *name; - unsigned long cnt; - struct wsp_probe *probe_array; -}; - -static char *webapp_path; -static char *chromium_path; - -#define WSP_PROBE_MAKE(_name_, _offset_, _desc_) \ -{ \ - .name = (_name_), \ - .probe.offset = (_offset_), \ - .probe.desc = (_desc_) \ -} - -/* - * res_request - */ -/* blink::ResourceLoader.m_request.m_url */ -#define URL_OFFSET 84 -/* base::String.m_impl.m_ptr */ -#define URL_LEN_OFFSET 4 -#define URL_DATA_OFFSET 12 - -static char *path_get_from_object(unsigned long ptr) -{ - char *path; - unsigned long url, len, ret; - - get_user(url, (unsigned long __user *)(ptr + URL_OFFSET)); - get_user(len, (unsigned long __user *)(url + URL_LEN_OFFSET)); - path = kzalloc(len + 1, GFP_KERNEL); - if (!path) - return NULL; - - ret = copy_from_user(path, - (const void __user *)(url + URL_DATA_OFFSET), - len); - if (ret) { - kfree(path); - path = NULL; - } else { - path[len] = '\0'; - } - - return path; -} - -static int res_request_handle(struct uprobe *p, struct pt_regs *regs) -{ - unsigned long ptr; - char *path; - - ptr = (unsigned long)swap_get_uarg(regs, 0); - path = path_get_from_object(ptr); - if (path) { - int id = wsp_resource_data_add(ptr, path); - if (id >= 0) - wsp_msg(WSP_RES_LOAD_BEGIN, id, path); - } - - kfree(path); - - return 0; -} - -static struct probe_desc res_request = MAKE_UPROBE(res_request_handle); - -/* - * res_finish - */ -static int res_finish_ehandle(struct uretprobe_instance *ri, - struct pt_regs *regs) -{ - int id; - unsigned long ptr = (unsigned long)swap_get_uarg(regs, 0); - - id = wsp_resource_data_id(ptr); - if (id >= 0) { - *(unsigned long *)ri->data = ptr; - wsp_msg(WSP_RES_PROC_BEGIN, id, NULL); - } - - return 0; -} - -static int res_finish_rhandle(struct uretprobe_instance *ri, - struct pt_regs *regs) -{ - int id; - unsigned long ptr; - - ptr = *(unsigned long *)ri->data; - id = wsp_resource_data_id(ptr); - if (id >= 0) { - wsp_msg(WSP_RES_PROC_END, id, NULL); - wsp_msg(WSP_RES_LOAD_END, id, NULL); - wsp_resource_data_del(ptr); - } - - return 0; -} - -static struct probe_desc res_finish = - MAKE_URPROBE(res_finish_ehandle, res_finish_rhandle, - sizeof(unsigned long)); - -/* - * redraw - */ -static int redraw_eh(struct uretprobe_instance *ri, struct pt_regs *regs) -{ - wsp_msg(WSP_DRAW_BEGIN, 0, NULL); - - return 0; -} - -static int redraw_rh(struct uretprobe_instance *ri, struct pt_regs *regs) -{ - wsp_msg(WSP_DRAW_END, 0, NULL); - - return 0; -} - -static struct probe_desc redraw = MAKE_URPROBE(redraw_eh, redraw_rh, 0); - -/* blink::ResourceLoader::start() */ -#define RES_REQ "_ZN5blink14ResourceLoader5startEv" -/* blink::ResourceLoader::didFinishLoading(WebURLLoader*, double , int64_t) */ -#define RES_FINISH "_ZN5blink14ResourceLoader16didFinishLoadingEPNS_12WebURLLoaderEdx" - -/* content::RenderWidget::DidCommitAndDrawCompositorFrame */ -#define REDRAW "_ZN7content23CompositorOutputSurface11SwapBuffersEPN2cc15CompositorFrameE" - -static struct wsp_probe __probe_array[] = { - /* res */ - WSP_PROBE_MAKE(RES_REQ, 0, &res_request), - WSP_PROBE_MAKE(RES_FINISH, 0, &res_finish), - - /* redraw */ - WSP_PROBE_MAKE(REDRAW, 0, &redraw), -}; - -static struct wsp_bin chromium_bin = { - .name = NULL, - .probe_array = __probe_array, - .cnt = ARRAY_SIZE(__probe_array) -}; - -/* check chromium_bin array on init address */ -static bool wsp_is_addr_init(void) -{ - int i; - - for (i = 0; i < chromium_bin.cnt; ++i) - if (chromium_bin.probe_array[i].probe.offset == 0) - return false; - - return true; -} - -static int wsp_bin_register(struct pf_group *pfg, struct wsp_bin *bin) -{ - int i, ret; - struct dentry *dentry; - - dentry = dentry_by_path(bin->name); - if (!dentry) { - pr_err("dentry not found (path='%s'\n", bin->name); - return -EINVAL; - } - - for (i = 0; i < bin->cnt; ++i) { - struct wsp_probe *p = &bin->probe_array[i]; - - ret = pin_register(&p->probe, pfg, dentry); - if (ret) { - pr_err("failed to register WSP probe (%lx:%d)\n", - p->probe.offset, ret); - return ret; - } - } - - return 0; -} - -static void wsp_bin_unregister(struct pf_group *pfg, struct wsp_bin *bin) -{ - int i; - struct dentry *dentry; - - dentry = dentry_by_path(bin->name); - if (!dentry) { - pr_err("dentry not found (path='%s'\n", bin->name); - return; - } - - for (i = 0; i < bin->cnt; ++i) { - struct wsp_probe *p = &bin->probe_array[i]; - - pin_unregister(&p->probe, pfg); - } -} - -static char *do_set_path(char *path, size_t len) -{ - char *p; - - p = kmalloc(len, GFP_KERNEL); - if (!p) - return NULL; - - strncpy(p, path, len); - return p; -} - -static void do_free_path(char **dest) -{ - kfree(*dest); - *dest = NULL; -} - -static struct pf_group *g_pfg; - -static int wsp_app_register(void) -{ - struct dentry *dentry; - - if (!webapp_path || !chromium_path) { - pr_err("WSP: some required paths are not set!\n"); - return -EINVAL; - } - - chromium_bin.name = chromium_path; - - dentry = dentry_by_path(webapp_path); - if (!dentry) { - pr_err("dentry not found (path='%s'\n", webapp_path); - return -EINVAL; - } - - g_pfg = get_pf_group_by_dentry(dentry, (void *)dentry); - if (!g_pfg) { - pr_err("WSP: g_pfg is NULL (by dentry=%p)\n", dentry); - return -ENOMEM; - } - - return wsp_bin_register(g_pfg, &chromium_bin); -} - -static void wsp_app_unregister(void) -{ - if (!chromium_bin.name) { - pr_err("WSP: chromium path is not initialized\n"); - return; - } - - wsp_bin_unregister(g_pfg, &chromium_bin); - put_pf_group(g_pfg); -} - -static int do_wsp_on(void) -{ - int ret; - - ret = wsp_res_init(); - if (ret) - return ret; - - ret = wsp_app_register(); - if (ret) - wsp_res_exit(); - - return ret; -} - -static int do_wsp_off(void) -{ - wsp_app_unregister(); - wsp_res_exit(); - - return 0; -} - -static enum wsp_mode g_mode = WSP_OFF; -static DEFINE_MUTEX(g_mode_mutex); - -int wsp_set_addr(const char *name, unsigned long offset) -{ - int i, ret = 0; - - if (mutex_trylock(&g_mode_mutex) == 0) - return -EBUSY; - - for (i = 0; i < chromium_bin.cnt; ++i) { - if (!strcmp(name, chromium_bin.probe_array[i].name)) { - chromium_bin.probe_array[i].probe.offset = offset; - goto unlock; - } - } - - ret = -EINVAL; - -unlock: - mutex_unlock(&g_mode_mutex); - return ret; -} - -int wsp_set_mode(enum wsp_mode mode) -{ - int ret = -EINVAL; - - if (g_mode == mode) - return -EBUSY; - - mutex_lock(&g_mode_mutex); - switch (mode) { - case WSP_ON: - ret = wsp_is_addr_init() ? do_wsp_on() : -EPERM; - break; - case WSP_OFF: - ret = do_wsp_off(); - break; - } - - if (!ret) - g_mode = mode; - - mutex_unlock(&g_mode_mutex); - return ret; -} - -enum wsp_mode wsp_get_mode(void) -{ - return g_mode; -} - -void wsp_set_webapp_path(char *path, size_t len) -{ - do_free_path(&webapp_path); - webapp_path = do_set_path(path, len); -} - -void wsp_set_chromium_path(char *path, size_t len) -{ - do_free_path(&chromium_path); - chromium_path = do_set_path(path, len); -} - -int wsp_init(void) -{ - return 0; -} - -void wsp_exit(void) -{ - wsp_set_mode(WSP_OFF); - do_free_path(&webapp_path); - do_free_path(&chromium_path); -} diff --git a/modules/wsp/wsp.h b/modules/wsp/wsp.h deleted file mode 100644 index 8b45e1d..0000000 --- a/modules/wsp/wsp.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef _WSP_H -#define _WSP_H - -/* - * @author Vyacheslav Cherkashin - * - * @section LICENSE - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * - * @section COPYRIGHT - * - * Copyright (C) Samsung Electronics, 2015 - * - * @section DESCRIPTION - * - * Web startup profiling - */ - -enum wsp_mode { - WSP_ON, - WSP_OFF -}; - -int wsp_set_addr(const char *name, unsigned long offset); - -int wsp_set_mode(enum wsp_mode mode); -enum wsp_mode wsp_get_mode(void); - -void wsp_set_webapp_path(char *path, size_t len); -void wsp_set_chromium_path(char *path, size_t len); - -int wsp_init(void); -void wsp_exit(void); - -#endif /* _WSP_H */ diff --git a/modules/wsp/wsp_debugfs.c b/modules/wsp/wsp_debugfs.c deleted file mode 100644 index c117f75..0000000 --- a/modules/wsp/wsp_debugfs.c +++ /dev/null @@ -1,264 +0,0 @@ -/* - * @author Vyacheslav Cherkashin - * - * @section LICENSE - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * - * @section COPYRIGHT - * - * Copyright (C) Samsung Electronics, 2015 - * - * @section DESCRIPTION - * - * Web startup profiling - */ - -#include -#include -#include -#include -#include "wsp.h" -#include "wsp_debugfs.h" - -static int do_write_cmd(const char *buf, size_t count) -{ - int n, ret = 0; - char *name; - unsigned long offset; - - name = kmalloc(count, GFP_KERNEL); - if (!name) - return -ENOMEM; - - n = sscanf(buf, "%lx %1024s", &offset, name); - if (n != 2) { - ret = -EINVAL; - goto free_name; - } - - ret = wsp_set_addr(name, offset); - -free_name: - kfree(name); - return ret; -} - -/* ============================================================================ - * === DEBUGFS FOR CMD === - * ============================================================================ - */ -static ssize_t write_cmd(struct file *file, const char __user *user_buf, - size_t count, loff_t *ppos) -{ - enum { max_count = 1024 }; - int ret; - char *buf; - - if (count > max_count) - return -ENOMEM; - - buf = kmalloc(count + 1, GFP_KERNEL); - if (!buf) - return -ENOMEM; - - if (copy_from_user(buf, user_buf, count)) { - ret = -EFAULT; - goto free_buf; - } - - buf[count] = '\0'; - ret = do_write_cmd(buf, count); - -free_buf: - kfree(buf); - return ret ? ret : count; -} - -static const struct file_operations fops_cmd = { - .write = write_cmd, - .llseek = default_llseek, -}; - -/* ============================================================================ - * === DEBUGFS FOR ENABLE === - * ============================================================================ - */ -static ssize_t read_enabled(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) -{ - char buf[2]; - - buf[0] = wsp_get_mode() == WSP_OFF ? '0' : '1'; - buf[1] = '\n'; - - return simple_read_from_buffer(user_buf, count, ppos, buf, 2); -} - -static ssize_t write_enabled(struct file *file, const char __user *user_buf, - size_t count, loff_t *ppos) -{ - int ret = 0; - char buf[32]; - size_t buf_size; - - buf_size = min(count, (sizeof(buf) - 1)); - if (copy_from_user(buf, user_buf, buf_size)) - return -EFAULT; - - buf[buf_size] = '\0'; - switch (buf[0]) { - case '1': - ret = wsp_set_mode(WSP_ON); - break; - case '0': - ret = wsp_set_mode(WSP_OFF); - break; - default: - return -EINVAL; - } - - if (ret) - return ret; - - return count; -} - -static const struct file_operations fops_enabled = { - .read = read_enabled, - .write = write_enabled, - .llseek = default_llseek, -}; - -/* ============================================================================ - * === DEBUGFS FOR WEBAPP_PATH === - * ============================================================================ - */ -static ssize_t write_webapp_path(struct file *file, - const char __user *user_buf, - size_t len, loff_t *ppos) -{ - ssize_t ret; - char *path; - - path = kmalloc(len, GFP_KERNEL); - if (!path) { - ret = -ENOMEM; - goto write_webapp_path_failed; - } - - if (copy_from_user(path, user_buf, len)) { - ret = -EINVAL; - goto write_webapp_path_failed; - } - - path[len - 1] = '\0'; - wsp_set_webapp_path(path, len); - - ret = len; - -write_webapp_path_failed: - kfree(path); - - return ret; -} - -static const struct file_operations fops_webapp_path = { - .write = write_webapp_path -}; - -/* ============================================================================ - * === DEBUGFS FOR EWEBKIT_PATH === - * ============================================================================ - */ -static ssize_t write_ewebkit_path(struct file *file, - const char __user *user_buf, - size_t len, loff_t *ppos) -{ - ssize_t ret; - char *path; - - path = kmalloc(len, GFP_KERNEL); - if (!path) { - ret = -ENOMEM; - goto write_ewebkit_path_failed; - } - - if (copy_from_user(path, user_buf, len)) { - ret = -EINVAL; - goto write_ewebkit_path_failed; - } - - path[len - 1] = '\0'; - - wsp_set_chromium_path(path, len); - - ret = len; - -write_ewebkit_path_failed: - kfree(path); - - return ret; -} - -static const struct file_operations fops_ewebkit_path = { - .write = write_ewebkit_path -}; - -static struct dentry *wsp_dir; - -void wsp_debugfs_exit(void) -{ - debugfs_remove_recursive(wsp_dir); - wsp_dir = NULL; -} - -int wsp_debugfs_init(void) -{ - struct dentry *dentry; - - dentry = swap_debugfs_getdir(); - if (!dentry) - return -ENOENT; - - wsp_dir = swap_debugfs_create_dir("wsp", dentry); - if (!wsp_dir) - return -ENOMEM; - - dentry = swap_debugfs_create_file("enabled", 0600, wsp_dir, NULL, - &fops_enabled); - if (!dentry) - goto fail; - - dentry = swap_debugfs_create_file("cmd", 0600, wsp_dir, NULL, - &fops_cmd); - if (!dentry) - goto fail; - - dentry = swap_debugfs_create_file("webapp_path", 0600, wsp_dir, NULL, - &fops_webapp_path); - if (!dentry) - goto fail; - - dentry = swap_debugfs_create_file("ewebkit_path", 0600, wsp_dir, NULL, - &fops_ewebkit_path); - if (!dentry) - goto fail; - - return 0; - -fail: - wsp_debugfs_exit(); - return -ENOMEM; -} diff --git a/modules/wsp/wsp_debugfs.h b/modules/wsp/wsp_debugfs.h deleted file mode 100644 index db3ea17..0000000 --- a/modules/wsp/wsp_debugfs.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef _WSP_DEBUGFS_H -#define _WSP_DEBUGFS_H - -/* - * @author Vyacheslav Cherkashin - * - * @section LICENSE - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * - * @section COPYRIGHT - * - * Copyright (C) Samsung Electronics, 2015 - * - * @section DESCRIPTION - * - * Web startup profiling - */ - -int wsp_debugfs_init(void); -void wsp_debugfs_exit(void); - -#endif /* _WSP_DEBUGFS_H */ diff --git a/modules/wsp/wsp_module.c b/modules/wsp/wsp_module.c deleted file mode 100644 index 2c5d490..0000000 --- a/modules/wsp/wsp_module.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * @author Vyacheslav Cherkashin - * - * @section LICENSE - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * - * @section COPYRIGHT - * - * Copyright (C) Samsung Electronics, 2015 - * - * @section DESCRIPTION - * - * Web startup profiling - */ - -#include -#include "wsp.h" -#include "wsp_debugfs.h" - -SWAP_LIGHT_INIT_MODULE(NULL, wsp_init, wsp_exit, - wsp_debugfs_init, wsp_debugfs_exit); - -MODULE_LICENSE("GPL"); diff --git a/modules/wsp/wsp_msg.c b/modules/wsp/wsp_msg.c deleted file mode 100644 index a0532cd..0000000 --- a/modules/wsp/wsp_msg.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - * wsp/wsp_msg.c - * @author Vyacheslav Cherkashin - * - * @section LICENSE - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * - * @section COPYRIGHT - * - * Copyright (C) Samsung Electronics, 2015 - * - * @section DESCRIPTION - * - * Web startup profiling - */ - -#include -#include -#include -#include "wsp_msg.h" - -/* - * MSG_WSP (payload): - * +-------------+----------+----------+ - * | name | type | length | - * +-------------+----------+----------+ - * | PID | int | 4 | - * | wsp_id | int | 4 | - * | wsp_payload | variable | variable | - * +-------------+----------+----------+ - - * wsp_id: - * - WSP_RES_LOAD_BEGIN = 0x0001 - * - WSP_RES_LOAD_END = 0x0002 - * - WSP_RES_PROC_BEGIN = 0x0003 - * - WSP_RES_PROC_END = 0x0004 - * - WSP_DRAW_BEGIN = 0x0005 - * - WSP_DRAW_END = 0x0006 - * - * wsp_payload: - * - * 1. WSP_RES_LOAD_BEGIN: - * +--------+--------+----------+ - * | name | type | length | - * +--------+--------+----------+ - * | res_id | int | 4 | - * | path | string | variable | - * +--------+--------+----------+ - * - * 2. WSP_RES_LOAD_END, WSP_RES_PROC_BEGIN, WSP_RES_PROC_END: - * +--------+--------+----------+ - * | name | type | length | - * +--------+--------+----------+ - * | res_id | int | 4 | - * +--------+--------+----------+ - * - * 3. WSP_DRAW_BEGIN, WSP_DRAW_END: - * no wsp_payload - */ - -static int pack_wsp_msg(void *data, size_t size, enum wsp_id id, - u32 res_id, const char *path) -{ - size_t len; - const size_t old_size = size; - - /* write PID */ - *(u32 *)data = (u32)current->tgid; - data += 4; - size -= 4; - - /* write wsp_id */ - *(u32 *)data = (u32)id; - data += 4; - size -= 4; - - /* pack wsp_payload */ - switch (id) { - case WSP_RES_LOAD_BEGIN: - len = strlen(path) + 1; - if (size < len + 4) - return -ENOMEM; - - /* '+ 4' - skip space for res_id */ - memcpy(data + 4, path, len); - size -= len; - case WSP_RES_LOAD_END: - case WSP_RES_PROC_BEGIN: - case WSP_RES_PROC_END: - /* write res_id */ - *(u32 *)data = res_id; - size -= 4; - break; - - case WSP_DRAW_BEGIN: - case WSP_DRAW_END: - break; - - default: - pr_err("unknown wsp_id: id=%u\n", (unsigned int)id); - return -EINVAL; - } - - return old_size - size; -} - -void wsp_msg(enum wsp_id id, u32 res_id, const char *path) -{ - int ret; - void *data; - size_t size; - struct swap_msg *m; - - m = swap_msg_get(MSG_WSP); - data = swap_msg_payload(m); - size = swap_msg_size(m); - ret = pack_wsp_msg(data, size, id, res_id, path); - if (ret < 0) { - pr_err("error MSG_WSP packing, ret=%d\n", ret); - goto put_msg; - } - - swap_msg_flush(m, ret); - -put_msg: - swap_msg_put(m); -} diff --git a/modules/wsp/wsp_msg.h b/modules/wsp/wsp_msg.h deleted file mode 100644 index fc02009..0000000 --- a/modules/wsp/wsp_msg.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef _WSP_MSG_H -#define _WSP_MSG_H - -/* - * wsp/wsp_msg.h - * @author Vyacheslav Cherkashin - * - * @section LICENSE - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * - * @section COPYRIGHT - * - * Copyright (C) Samsung Electronics, 2015 - * - * @section DESCRIPTION - * - * Web startup profiling - */ - -#include - -enum wsp_id { - WSP_RES_LOAD_BEGIN = 0x0001, - WSP_RES_LOAD_END = 0x0002, - WSP_RES_PROC_BEGIN = 0x0003, - WSP_RES_PROC_END = 0x0004, - WSP_DRAW_BEGIN = 0x0005, - WSP_DRAW_END = 0x0006 -}; - -void wsp_msg(enum wsp_id id, u32 res_id, const char *path); - -#endif /* _WSP_MSG_H */ diff --git a/modules/wsp/wsp_res.c b/modules/wsp/wsp_res.c deleted file mode 100644 index fee1adc..0000000 --- a/modules/wsp/wsp_res.c +++ /dev/null @@ -1,162 +0,0 @@ -/* - * @author Vyacheslav Cherkashin - * - * @section LICENSE - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * - * @section COPYRIGHT - * - * Copyright (C) Samsung Electronics, 2015 - * - * @section DESCRIPTION - * - * Web startup profiling - */ - -#include -#include -#include -#include "wsp_res.h" - -static atomic_t __resource_id = ATOMIC_INIT(0); - -static inline int __wsp_resource_id(void) -{ - return atomic_inc_return(&__resource_id); -} - -struct wsp_resource_data { - struct list_head list; - int id; - unsigned long addr; - char *path; -}; - -static LIST_HEAD(__resources_list); -static DEFINE_MUTEX(__resources_mutex); - -static struct wsp_resource_data *wsp_resource_data_alloc(void) -{ - struct wsp_resource_data *p; - - p = kzalloc(sizeof(*p), GFP_KERNEL); - if (!p) - return NULL; - - INIT_LIST_HEAD(&p->list); - - return p; -} - -static void wsp_resource_data_free(struct wsp_resource_data *p) -{ - if (!p) - return; - - kfree(p->path); - kfree(p); -} - -static struct wsp_resource_data *wsp_resource_data_find(unsigned long addr) -{ - struct wsp_resource_data *p; - - list_for_each_entry(p, &__resources_list, list) - if (p->addr == addr) - return p; - - return NULL; -} - -int wsp_resource_data_id(unsigned long addr) -{ - int ret = -1; - struct wsp_resource_data *p; - - mutex_lock(&__resources_mutex); - p = wsp_resource_data_find(addr); - if (p) - ret = p->id; - mutex_unlock(&__resources_mutex); - - return ret; -} - -int wsp_resource_data_add(unsigned long addr, char *path) -{ - int ret = -1; - struct wsp_resource_data *p; - - mutex_lock(&__resources_mutex); - p = wsp_resource_data_find(addr); - if (p) { - ret = p->id; - goto out; - } - p = wsp_resource_data_alloc(); - if (p) { - p->id = __wsp_resource_id(); - p->addr = addr; - 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; - } - -out: - mutex_unlock(&__resources_mutex); - - return ret; -} - -void wsp_resource_data_del(unsigned long addr) -{ - struct wsp_resource_data *p; - - mutex_lock(&__resources_mutex); - p = wsp_resource_data_find(addr); - if (p) { - list_del(&p->list); - wsp_resource_data_free(p); - } - - mutex_unlock(&__resources_mutex); -} - -/* ============================================================================ - * = init/exit() = - * ============================================================================ - */ -int wsp_res_init(void) -{ - return 0; -} - -void wsp_res_exit(void) -{ - struct wsp_resource_data *p, *tmp; - - mutex_lock(&__resources_mutex); - list_for_each_entry_safe(p, tmp, &__resources_list, list) { - list_del(&p->list); - wsp_resource_data_free(p); - } - mutex_unlock(&__resources_mutex); -} diff --git a/modules/wsp/wsp_res.h b/modules/wsp/wsp_res.h deleted file mode 100644 index 9c13478..0000000 --- a/modules/wsp/wsp_res.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef _WSP_TDATA_H -#define _WSP_TDATA_H - -/* - * @author Vyacheslav Cherkashin - * - * @section LICENSE - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * - * @section COPYRIGHT - * - * Copyright (C) Samsung Electronics, 2015 - * - * @section DESCRIPTION - * - * Web startup profiling - */ - -#include - -int wsp_resource_data_add(unsigned long addr, char *path); -void wsp_resource_data_del(unsigned long addr); -int wsp_resource_data_id(unsigned long addr); - -int wsp_res_init(void); -void wsp_res_exit(void); - -#endif /* _WSP_TDATA_H */ -- 2.7.4 From 7dd20e35b849a80b4209c5f928350af6a64ca928 Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Thu, 11 Oct 2018 22:27:49 +0300 Subject: [PATCH 03/16] Remove web profiling legacy code Change-Id: I7c5040a2e67da08a286c7ac566a8257d6bda98e6 Signed-off-by: Vyacheslav Cherkashin --- modules/parser/msg_cmd.c | 28 ---------------------------- modules/parser/msg_cmd.h | 2 -- modules/parser/swap_msg_parser.c | 13 ------------- modules/writer/swap_msg.h | 2 -- 4 files changed, 45 deletions(-) diff --git a/modules/parser/msg_cmd.c b/modules/parser/msg_cmd.c index 3572345..d3fef3f 100644 --- a/modules/parser/msg_cmd.c +++ b/modules/parser/msg_cmd.c @@ -29,7 +29,6 @@ #include -#include #include #include "msg_parser.h" #include "msg_buf.h" @@ -40,8 +39,6 @@ #include -static int wrt_launcher_port; - static int set_config(struct conf_data *conf) { int ret; @@ -219,31 +216,6 @@ int msg_swap_inst_remove(struct msg_buf *mb) return app_list_unreg(&app_head); } -void set_wrt_launcher_port(int port) -{ - wrt_launcher_port = port; -} -EXPORT_SYMBOL_GPL(set_wrt_launcher_port); - -#define GET_PORT_DELAY 100 /* msec */ -#define GET_PORT_TIMEOUT 10000 /* msec */ - -int get_wrt_launcher_port(void) -{ - int port; - int timeout = GET_PORT_TIMEOUT; - - do { - port = wrt_launcher_port; - timeout -= GET_PORT_DELAY; - mdelay(GET_PORT_DELAY); - } while (!port && timeout > 0); - - set_wrt_launcher_port(0); - - return port; -} - /** * @brief Initializes commands handling. * diff --git a/modules/parser/msg_cmd.h b/modules/parser/msg_cmd.h index e078169..4317b6c 100644 --- a/modules/parser/msg_cmd.h +++ b/modules/parser/msg_cmd.h @@ -40,7 +40,5 @@ int msg_stop(struct msg_buf *mb); int msg_config(struct msg_buf *mb); int msg_swap_inst_add(struct msg_buf *mb); int msg_swap_inst_remove(struct msg_buf *mb); -int get_wrt_launcher_port(void); -void set_wrt_launcher_port(int port); #endif /* _MSG_CMD_H */ diff --git a/modules/parser/swap_msg_parser.c b/modules/parser/swap_msg_parser.c index eb1abe8..2fd4b4e 100644 --- a/modules/parser/swap_msg_parser.c +++ b/modules/parser/swap_msg_parser.c @@ -56,7 +56,6 @@ enum MSG_ID { MSG_CONFIG = 0x0004, /**< Config message. */ MSG_SWAP_INST_ADD = 0x0008, /**< Swap inst add message. */ MSG_SWAP_INST_REMOVE = 0x0009, /**< Swap inst remove message. */ - MSG_WRT_LAUNCHER_PORT = 0x8001 /**< WRT launcher port. */ }; /** @@ -126,18 +125,6 @@ static int msg_handler(void __user *msg) print_parse_debug("MSG_SWAP_INST_REMOVE. size=%d\n", size); ret = msg_swap_inst_remove(&mb); break; - case MSG_WRT_LAUNCHER_PORT: { - /* TODO: discuss wrt-launcher port transfer */ - int port; - print_parse_debug("MSG_WRT_LAUNCHER_PORT. size=%d\n", size); - port = get_wrt_launcher_port(); - if (copy_to_user(payload, &port, sizeof(port))) { - ret = -EIO; - break; - } - ret = port ? 0 : -EINVAL; - break; - } default: print_err("incorrect message ID [%u]. size=%d\n", msg_id, size); ret = -EINVAL; diff --git a/modules/writer/swap_msg.h b/modules/writer/swap_msg.h index 5d86f95..40a4b83 100644 --- a/modules/writer/swap_msg.h +++ b/modules/writer/swap_msg.h @@ -55,9 +55,7 @@ enum swap_msg_id { MSG_PROC_MAP = 0x0012, MSG_PROC_UNMAP = 0x0013, MSG_PROC_COMM = 0x0014, - MSG_WEB_PROFILING = 0x0015, MSG_NSP = 0x0019, - MSG_WSP = 0x001a, MSG_FBI = 0x0020 }; -- 2.7.4 From 18486d062e89188a4cf8101ef1c7a47c216c7fea Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Mon, 1 Oct 2018 13:27:35 +0300 Subject: [PATCH 04/16] us_manager: remove old dentry manipulation interface Change-Id: Ib68a78ecc5f97bdfb9cc6f8ec022af6dc3350179 Signed-off-by: Vyacheslav Cherkashin --- modules/us_manager/pf/pf_group.c | 20 --------------- modules/us_manager/pf/pf_group.h | 3 --- modules/us_manager/us_common_file.h | 49 ------------------------------------- 3 files changed, 72 deletions(-) delete mode 100644 modules/us_manager/us_common_file.h diff --git a/modules/us_manager/pf/pf_group.c b/modules/us_manager/pf/pf_group.c index 26684ff..be90f3c 100644 --- a/modules/us_manager/pf/pf_group.c +++ b/modules/us_manager/pf/pf_group.c @@ -43,7 +43,6 @@ #include #include #include -#include #include #include @@ -276,25 +275,6 @@ static void subsequent_install(struct task_struct *task, } -/** - * @brief Get dentry struct by path - * - * @param path Path to file - * @return Pointer on dentry struct on NULL - */ -struct dentry *dentry_by_path(const char *path) -{ - struct dentry *d; - - d = swap_get_dentry(path); - if (d) - dput(d); - - return d; -} -EXPORT_SYMBOL_GPL(dentry_by_path); - - int pfg_msg_cb_set(struct pf_group *pfg, struct pfg_msg_cb *msg_cb) { if (pfg->msg_cb) diff --git a/modules/us_manager/pf/pf_group.h b/modules/us_manager/pf/pf_group.h index f5267aa..01749b9 100644 --- a/modules/us_manager/pf/pf_group.h +++ b/modules/us_manager/pf/pf_group.h @@ -43,9 +43,6 @@ struct pfg_msg_cb { }; -/* FIXME: use swap_get_dentry() and swap_put_dentry() */ -struct dentry *dentry_by_path(const char *path); - struct pf_group *get_pf_group_by_dentry(struct dentry *dentry, void *priv); struct pf_group *get_pf_group_by_tgid(pid_t tgid, void *priv); struct pf_group *get_pf_group_by_comm(char *comm, void *priv); diff --git a/modules/us_manager/us_common_file.h b/modules/us_manager/us_common_file.h deleted file mode 100644 index f18b6ce..0000000 --- a/modules/us_manager/us_common_file.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SWAP uprobe manager - * modules/us_manager/us_manager_common_file.h - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Copyright (C) Samsung Electronics, 2017 - * - * 2017 Alexander Aksenov: SWAP us_manager implement - * - */ - -#ifndef __US_MANAGER_COMMON_FILE_H__ -#define __US_MANAGER_COMMON_FILE_H__ - -#include -#include - -static inline struct dentry *swap_get_dentry(const char *filepath) -{ - struct path path; - struct dentry *dentry = NULL; - - if (kern_path(filepath, LOOKUP_FOLLOW, &path) == 0) { - dentry = dget(path.dentry); - path_put(&path); - } - - return dentry; -} - -static inline void swap_put_dentry(struct dentry *dentry) -{ - dput(dentry); -} - -#endif /* __US_MANAGER_COMMON_FILE_H__ */ -- 2.7.4 From dc89ac67f914718151dee04a0610925745f98f04 Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Tue, 27 Nov 2018 13:59:41 +0300 Subject: [PATCH 05/16] Add support kernel v4.14 Change-Id: Id30162600c1c8cfe59a05d5b9cc9131156ee3b91 Signed-off-by: Vyacheslav Cherkashin --- modules/arch/arm/uprobe/swap_uprobe.c | 4 ++++ modules/got_patcher/gt_module.c | 1 + modules/kprobe/swap_td_raw.c | 9 ++++++++- modules/master/wait.h | 10 +++++----- modules/sampler/swap_sampler_module.c | 5 +++++ modules/uprobe/arch/arm/swap-asm/swap_uprobes.c | 4 ++++ modules/us_manager/pf/pf_group.c | 2 ++ modules/us_manager/sspt/sspt_proc.c | 1 + 8 files changed, 30 insertions(+), 6 deletions(-) diff --git a/modules/arch/arm/uprobe/swap_uprobe.c b/modules/arch/arm/uprobe/swap_uprobe.c index c7b2d0f..7955232 100644 --- a/modules/arch/arm/uprobe/swap_uprobe.c +++ b/modules/arch/arm/uprobe/swap_uprobe.c @@ -20,6 +20,10 @@ */ +#include +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) +# include /* for task_pt_regs() */ +#endif #include #include diff --git a/modules/got_patcher/gt_module.c b/modules/got_patcher/gt_module.c index cd6898d..fac053a 100644 --- a/modules/got_patcher/gt_module.c +++ b/modules/got_patcher/gt_module.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include diff --git a/modules/kprobe/swap_td_raw.c b/modules/kprobe/swap_td_raw.c index 9985d06..0715b7c 100644 --- a/modules/kprobe/swap_td_raw.c +++ b/modules/kprobe/swap_td_raw.c @@ -21,7 +21,14 @@ */ -#include +#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0) +# include +#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) */ +# include +#endif /* LINUX_VERSION_CODE */ + #include #include "swap_td_raw.h" diff --git a/modules/master/wait.h b/modules/master/wait.h index bb1ca4b..e003027 100644 --- a/modules/master/wait.h +++ b/modules/master/wait.h @@ -28,10 +28,10 @@ int wait_on_atomic_t(atomic_t *val, int (*action)(atomic_t *), unsigned mode) return out_of_line_wait_on_atomic_t(val, action, mode); } -#else /* LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0) */ - -#include - -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0) */ +#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0) +# include +#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 13, 0) */ +# include +#endif /* LINUX_VERSION_CODE */ #endif /* _SWAP_WAIT_H */ diff --git a/modules/sampler/swap_sampler_module.c b/modules/sampler/swap_sampler_module.c index 1b22646..6ac1aae 100644 --- a/modules/sampler/swap_sampler_module.c +++ b/modules/sampler/swap_sampler_module.c @@ -28,6 +28,11 @@ * Timer-based sampling module. */ +#include +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) +# include /* for task_pt_regs() */ +#endif + #include #include #include diff --git a/modules/uprobe/arch/arm/swap-asm/swap_uprobes.c b/modules/uprobe/arch/arm/swap-asm/swap_uprobes.c index 6da9d14..59e7fa9 100644 --- a/modules/uprobe/arch/arm/swap-asm/swap_uprobes.c +++ b/modules/uprobe/arch/arm/swap-asm/swap_uprobes.c @@ -31,6 +31,10 @@ */ +#include +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) +# include /* need for task_pt_regs() */ +#endif /* LINUX_VERSION_CODE */ #include /* need for asm/traps.h */ #include /* need for asm/traps.h */ diff --git a/modules/us_manager/pf/pf_group.c b/modules/us_manager/pf/pf_group.c index be90f3c..867a971 100644 --- a/modules/us_manager/pf/pf_group.c +++ b/modules/us_manager/pf/pf_group.c @@ -33,6 +33,8 @@ #include #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) # include +# include +# include #endif #include "pf_group.h" #include "proc_filters.h" diff --git a/modules/us_manager/sspt/sspt_proc.c b/modules/us_manager/sspt/sspt_proc.c index c06e26e..e4d9159 100644 --- a/modules/us_manager/sspt/sspt_proc.c +++ b/modules/us_manager/sspt/sspt_proc.c @@ -34,6 +34,7 @@ #include #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) # include +# include #endif #include #include -- 2.7.4 From 4a9f591cc6b2b90b4595d20bf986ad63c2b4a601 Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Thu, 13 Dec 2018 22:42:13 +0300 Subject: [PATCH 06/16] Fix memory corruption in the retprobe module Change-Id: Iee6a46fc8c7190a200de0bf94d47e1989e6238f3 Signed-off-by: Vyacheslav Cherkashin --- modules/retprobe/retprobe.c | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/retprobe/retprobe.c b/modules/retprobe/retprobe.c index 9a47ef9..bbefdc4 100644 --- a/modules/retprobe/retprobe.c +++ b/modules/retprobe/retprobe.c @@ -113,7 +113,6 @@ static void retprobe_init(struct sspt_ip *ip) static void retprobe_uninit(struct sspt_ip *ip) { - retprobe_cleanup(&ip->desc->info); } -- 2.7.4 From 8f4c00d2c10af73bed32247f5d0023edac74ae98 Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Thu, 13 Dec 2018 22:46:15 +0300 Subject: [PATCH 07/16] Fix memory corruption in the fbiprobe module Change-Id: I78ff0c4f425d243477181128e7e5bf6a1095e055 Signed-off-by: Vyacheslav Cherkashin --- modules/fbiprobe/fbiprobe.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/fbiprobe/fbiprobe.c b/modules/fbiprobe/fbiprobe.c index 42f5223..fc07fba 100644 --- a/modules/fbiprobe/fbiprobe.c +++ b/modules/fbiprobe/fbiprobe.c @@ -313,8 +313,6 @@ void fbi_probe_init(struct sspt_ip *ip) void fbi_probe_uninit(struct sspt_ip *ip) { - if (ip != NULL) - fbi_probe_cleanup(&ip->desc->info); } static int fbi_probe_register_probe(struct sspt_ip *ip) -- 2.7.4 From 6cfcfbfe683e2b75e88f22820f63224bb3a5cb0b Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Thu, 13 Dec 2018 22:49:50 +0300 Subject: [PATCH 08/16] Remove dead code Fields the copy and the cleanup in probe_iface structure already do not used. Therefore, remove them from all source code. Change-Id: Iaa72ddf5bfb999fc07292cf7505ec07320c4380d Signed-off-by: Vyacheslav Cherkashin --- modules/fbiprobe/fbiprobe.c | 70 ----------------------------- modules/preload/preload_probe.c | 39 ---------------- modules/retprobe/retprobe.c | 26 ----------- modules/us_manager/probes/probe_info_new.c | 22 --------- modules/us_manager/probes/register_probes.h | 2 - 5 files changed, 159 deletions(-) diff --git a/modules/fbiprobe/fbiprobe.c b/modules/fbiprobe/fbiprobe.c index fc07fba..c0ce923 100644 --- a/modules/fbiprobe/fbiprobe.c +++ b/modules/fbiprobe/fbiprobe.c @@ -288,24 +288,6 @@ static int fbi_probe_handler(struct uprobe *p, struct pt_regs *regs) } /* FBI probe interfaces */ -void fbi_probe_cleanup(struct probe_info *probe_i) -{ - uint8_t i; - struct fbi_info *fbi_i = &(probe_i->fbi_i); - - for (i = 0; i != fbi_i->var_count; i++) { - if (fbi_i->vars[i].steps != NULL) { - if (fbi_i->vars[i].steps != NULL) - kfree(fbi_i->vars[i].steps); - fbi_i->vars[i].steps = NULL; - fbi_i->vars[i].steps_count = 0; - } - } - - kfree(fbi_i->vars); - fbi_i->vars = NULL; -} - void fbi_probe_init(struct sspt_ip *ip) { ip->uprobe.pre_handler = (uprobe_pre_handler_t)fbi_probe_handler; @@ -330,56 +312,6 @@ static struct uprobe *fbi_probe_get_uprobe(struct sspt_ip *ip) return &ip->uprobe; } -int fbi_probe_copy(struct probe_info *dest, const struct probe_info *source) -{ - uint8_t steps_count; - size_t steps_size; - size_t vars_size; - struct fbi_var_data *vars; - struct fbi_step *steps_source; - struct fbi_step *steps_dest = NULL; - uint8_t i, n; - int ret = 0; - - memcpy(dest, source, sizeof(*source)); - - vars_size = source->fbi_i.var_count * sizeof(*source->fbi_i.vars); - vars = kmalloc(vars_size, GFP_KERNEL); - if (vars == NULL) - return -ENOMEM; - - memcpy(vars, source->fbi_i.vars, vars_size); - - for (i = 0; i != source->fbi_i.var_count; i++) { - steps_dest = NULL; - steps_count = vars[i].steps_count; - steps_size = sizeof(*steps_source) * steps_count; - steps_source = vars[i].steps; - - if (steps_size != 0 && steps_source != NULL) { - steps_dest = kmalloc(steps_size, GFP_KERNEL); - if (steps_dest == NULL) { - print_err("can not alloc data\n"); - n = i; - ret = -ENOMEM; - goto err; - } - - memcpy(steps_dest, steps_source, steps_size); - } - vars[i].steps = steps_dest; - } - - dest->fbi_i.vars = vars; - - return ret; -err: - for (i = 0; i < n; i++) - kfree(vars[i].steps); - kfree(vars); - return ret; -} - /* Register */ static struct probe_iface fbi_probe_iface = { .init = fbi_probe_init, @@ -387,8 +319,6 @@ static struct probe_iface fbi_probe_iface = { .reg = fbi_probe_register_probe, .unreg = fbi_probe_unregister_probe, .get_uprobe = fbi_probe_get_uprobe, - .copy = fbi_probe_copy, - .cleanup = fbi_probe_cleanup }; static int fbiprobe_init(void) diff --git a/modules/preload/preload_probe.c b/modules/preload/preload_probe.c index 3db3fd0..b5bf767 100644 --- a/modules/preload/preload_probe.c +++ b/modules/preload/preload_probe.c @@ -32,17 +32,6 @@ #include "preload.h" #include "preload_module.h" -static int preload_info_copy(struct probe_info *dest, - const struct probe_info *source) -{ - memcpy(dest, source, sizeof(*source)); - - return 0; -} - -static void preload_info_cleanup(struct probe_info *probe_i) -{ -} static struct uprobe *preload_get_uprobe(struct sspt_ip *ip) { @@ -69,8 +58,6 @@ static void preload_init(struct sspt_ip *ip) static void preload_uninit(struct sspt_ip *ip) { pm_uprobe_exit(ip); - - preload_info_cleanup(&ip->desc->info); } static struct probe_iface preload_iface = { @@ -79,22 +66,8 @@ static struct probe_iface preload_iface = { .reg = preload_register_probe, .unreg = preload_unregister_probe, .get_uprobe = preload_get_uprobe, - .copy = preload_info_copy, - .cleanup = preload_info_cleanup }; -static int get_caller_info_copy(struct probe_info *dest, - const struct probe_info *source) -{ - memcpy(dest, source, sizeof(*source)); - - return 0; -} - -static void get_caller_info_cleanup(struct probe_info *probe_i) -{ -} - static struct uprobe *get_caller_get_uprobe(struct sspt_ip *ip) { return &ip->uprobe; @@ -118,8 +91,6 @@ static void get_caller_init(struct sspt_ip *ip) static void get_caller_uninit(struct sspt_ip *ip) { pm_get_caller_exit(ip); - - get_caller_info_cleanup(&ip->desc->info); } static struct probe_iface get_caller_iface = { @@ -128,8 +99,6 @@ static struct probe_iface get_caller_iface = { .reg = get_caller_register_probe, .unreg = get_caller_unregister_probe, .get_uprobe = get_caller_get_uprobe, - .copy = get_caller_info_copy, - .cleanup = get_caller_info_cleanup }; static void get_call_type_init(struct sspt_ip *ip) @@ -140,8 +109,6 @@ static void get_call_type_init(struct sspt_ip *ip) static void get_call_type_uninit(struct sspt_ip *ip) { pm_get_call_type_exit(ip); - - get_caller_info_cleanup(&ip->desc->info); } static struct probe_iface get_call_type_iface = { @@ -150,8 +117,6 @@ static struct probe_iface get_call_type_iface = { .reg = get_caller_register_probe, .unreg = get_caller_unregister_probe, .get_uprobe = get_caller_get_uprobe, - .copy = get_caller_info_copy, - .cleanup = get_caller_info_cleanup }; static void write_msg_init(struct sspt_ip *ip) @@ -167,8 +132,6 @@ static int write_msg_reg(struct sspt_ip *ip) static void write_msg_uninit(struct sspt_ip *ip) { pm_write_msg_exit(ip); - - get_caller_info_cleanup(&ip->desc->info); } static struct probe_iface write_msg_iface = { @@ -177,8 +140,6 @@ static struct probe_iface write_msg_iface = { .reg = write_msg_reg, .unreg = get_caller_unregister_probe, .get_uprobe = get_caller_get_uprobe, - .copy = get_caller_info_copy, - .cleanup = get_caller_info_cleanup }; int register_preload_probes(void) diff --git a/modules/retprobe/retprobe.c b/modules/retprobe/retprobe.c index bbefdc4..990c764 100644 --- a/modules/retprobe/retprobe.c +++ b/modules/retprobe/retprobe.c @@ -33,30 +33,6 @@ #include "rp_msg.h" -static int retprobe_copy(struct probe_info *dest, - const struct probe_info *source) -{ - size_t len; - - memcpy(dest, source, sizeof(*source)); - - len = strlen(source->rp_i.args) + 1; - dest->rp_i.args = kmalloc(len, GFP_ATOMIC); - if (dest->rp_i.args == NULL) - return -ENOMEM; - memcpy(dest->rp_i.args, source->rp_i.args, len); - - return 0; -} - - -static void retprobe_cleanup(struct probe_info *probe_i) -{ - kfree(probe_i->rp_i.args); -} - - - static struct uprobe *retprobe_get_uprobe(struct sspt_ip *ip) { return &ip->retprobe.up; @@ -122,8 +98,6 @@ static struct probe_iface retprobe_iface = { .reg = retprobe_register_probe, .unreg = retprobe_unregister_probe, .get_uprobe = retprobe_get_uprobe, - .copy = retprobe_copy, - .cleanup = retprobe_cleanup }; static int mod_init(void) diff --git a/modules/us_manager/probes/probe_info_new.c b/modules/us_manager/probes/probe_info_new.c index 303f332..801acdd 100644 --- a/modules/us_manager/probes/probe_info_new.c +++ b/modules/us_manager/probes/probe_info_new.c @@ -112,15 +112,6 @@ EXPORT_SYMBOL_GPL(pin_unregister); /* * SWAP_NEW_UP */ -static int up_copy(struct probe_info *dst, const struct probe_info *src) -{ - return 0; -} - -static void up_cleanup(struct probe_info *probe_i) -{ -} - static struct uprobe *up_get_uprobe(struct sspt_ip *ip) { return &ip->uprobe; @@ -151,8 +142,6 @@ static struct probe_iface up_iface = { .reg = up_register_probe, .unreg = up_unregister_probe, .get_uprobe = up_get_uprobe, - .copy = up_copy, - .cleanup = up_cleanup }; @@ -162,15 +151,6 @@ static struct probe_iface up_iface = { /* * SWAP_NEW_URP */ -static int urp_copy(struct probe_info *dst, const struct probe_info *src) -{ - return 0; -} - -static void urp_cleanup(struct probe_info *probe_i) -{ -} - static struct uprobe *urp_get_uprobe(struct sspt_ip *ip) { return &ip->retprobe.up; @@ -213,8 +193,6 @@ static struct probe_iface urp_iface = { .reg = urp_register_probe, .unreg = urp_unregister_probe, .get_uprobe = urp_get_uprobe, - .copy = urp_copy, - .cleanup = urp_cleanup }; diff --git a/modules/us_manager/probes/register_probes.h b/modules/us_manager/probes/register_probes.h index f981056..f07bd04 100644 --- a/modules/us_manager/probes/register_probes.h +++ b/modules/us_manager/probes/register_probes.h @@ -11,8 +11,6 @@ struct probe_iface { int (*reg)(struct sspt_ip *); void (*unreg)(struct sspt_ip *, int); struct uprobe *(*get_uprobe)(struct sspt_ip *); - int (*copy)(struct probe_info *, const struct probe_info *); - void (*cleanup)(struct probe_info *); }; int swap_register_probe_type(enum probe_t probe_type, struct probe_iface *pi); -- 2.7.4 From caefd845383a33a2d11b58debbfe4b5a2c40c7d6 Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Wed, 12 Dec 2018 22:24:05 +0300 Subject: [PATCH 09/16] Fix dentry leaks from swap_preload module Add missed call probe_info_unit() for deinitialize 'probe_info' Change-Id: I6c9506e64c6ebd2d90b1b1bde6b029d77defba3b Signed-off-by: Vyacheslav Cherkashin --- modules/us_manager/sspt/sspt_file.c | 8 ++------ modules/us_manager/sspt/sspt_ip.c | 2 ++ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/modules/us_manager/sspt/sspt_file.c b/modules/us_manager/sspt/sspt_file.c index 417c949..95decce 100644 --- a/modules/us_manager/sspt/sspt_file.c +++ b/modules/us_manager/sspt/sspt_file.c @@ -217,18 +217,14 @@ void sspt_file_add_ip(struct sspt_file *file, struct img_ip *img_ip) { unsigned long offset = 0; struct sspt_page *page = NULL; - struct sspt_ip *ip = NULL; offset = img_ip->addr & PAGE_MASK; page = sspt_find_page_or_new(file, offset); if (!page) return; - ip = sspt_ip_create(img_ip, page); - if (!ip) - return; - - probe_info_init(ip->desc->type, ip); + /* Created the "ip" automatically added itself to necessary lists */ + sspt_ip_create(img_ip, page); } void sspt_file_on_each_ip(struct sspt_file *file, diff --git a/modules/us_manager/sspt/sspt_ip.c b/modules/us_manager/sspt/sspt_ip.c index e36f80a..94ce357 100644 --- a/modules/us_manager/sspt/sspt_ip.c +++ b/modules/us_manager/sspt/sspt_ip.c @@ -54,6 +54,7 @@ struct sspt_ip *sspt_ip_create(struct img_ip *img_ip, struct sspt_page *page) ip->offset = img_ip->addr & ~PAGE_MASK; ip->desc = img_ip->desc; atomic_set(&ip->usage, 2); /* for 'img_ip' and 'page' */ + probe_info_init(ip->desc->type, ip); /* add to img_ip list */ img_ip_get(img_ip); @@ -74,6 +75,7 @@ static void sspt_ip_free(struct sspt_ip *ip) { WARN_ON(!list_empty(&ip->list) || !list_empty(&ip->img_list)); + probe_info_uninit(ip->desc->type, ip); kfree(ip); } -- 2.7.4 From f3d111ac868a27c3368c7d72b4920067ed65ce43 Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Fri, 4 Jan 2019 15:34:57 +0900 Subject: [PATCH 10/16] Add the swap-modules-tw3 package build For enabling/disabling build of the swap-modules-tw3 package set BUILD_PACKAGE_TW3 to 1/0. Note: based on the commit 1735096b40f5 ("Add the swap-modules-tw2 package build") and kernel version of tw3 is v4.9.y. Change-Id: I885ff6d81ee4a0947b55200764aeef98156e36d7 Signed-off-by: Seung-Woo Kim --- packaging/baselibs.conf | 7 +++++++ packaging/swap-modules.spec | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/packaging/baselibs.conf b/packaging/baselibs.conf index 456e2ed..96df1a9 100644 --- a/packaging/baselibs.conf +++ b/packaging/baselibs.conf @@ -14,6 +14,13 @@ swap-modules-tw2 preun "rm /opt/swap/sdk" +/ +swap-modules-tw3 + provides "swap-modules" + provides "swap-modules = %{version}-%{release}" + post "ln -s /opt/swap/modules/tw3 /opt/swap/sdk" + preun "rm /opt/swap/sdk" + +/ + swap-modules-rpi3 provides "swap-modules" provides "swap-modules = %{version}-%{release}" diff --git a/packaging/swap-modules.spec b/packaging/swap-modules.spec index c90944d..758f676 100755 --- a/packaging/swap-modules.spec +++ b/packaging/swap-modules.spec @@ -20,6 +20,7 @@ Kernel modules for SWAP %define BUILD_PACKAGE_TM1 1 %define BUILD_PACKAGE_TM2 1 %define BUILD_PACKAGE_TW2 1 +%define BUILD_PACKAGE_TW3 1 %define BUILD_PACKAGE_RPI3 1 %define BUILD_PACKAGE_ODROIDXU3 1 %define BUILD_PACKAGE_EMULATOR32 1 @@ -37,6 +38,7 @@ Kernel modules for SWAP %ifnarch aarch64 %define BUILD_PACKAGE_TM2 0 %define BUILD_PACKAGE_TW2 0 + %define BUILD_PACKAGE_TW3 0 %define BUILD_PACKAGE_RPI3 0 %endif %if ! %{with emulator} @@ -69,6 +71,12 @@ cd modules ./pack.sh /tmp/modules/tw2 %endif +%if %{BUILD_PACKAGE_TW3} + ./build.sh --kernel /boot/kernel/devel/kernel-devel-tw3 --arch arm64 clean + ./build.sh --kernel /boot/kernel/devel/kernel-devel-tw3 --arch arm64 compile + ./pack.sh /tmp/modules/tw3 +%endif + %if %{BUILD_PACKAGE_RPI3} ./build.sh --kernel /boot/kernel/devel/kernel-devel-arm64-rpi3 --arch arm64 clean ./build.sh --kernel /boot/kernel/devel/kernel-devel-arm64-rpi3 --arch arm64 compile @@ -103,6 +111,10 @@ mkdir -p %{buildroot}/opt/swap/modules/ mv /tmp/modules/tw2 %{buildroot}/opt/swap/modules/ %endif +%if %{BUILD_PACKAGE_TW3} + mv /tmp/modules/tw3 %{buildroot}/opt/swap/modules/ +%endif + %if %{BUILD_PACKAGE_RPI3} mv /tmp/modules/rpi3 %{buildroot}/opt/swap/modules/ %endif @@ -182,6 +194,28 @@ rm /opt/swap/sdk %endif # BUILD_PACKAGE_TW2 +%if %{BUILD_PACKAGE_TW3} +%package tw3 +Summary: SWAP modules for TW3 +Provides: swap-modules +Provides: swap-modules = %{version}-%{release} +BuildRequires: kernel-devel-exynos9110-tw3 + +%description tw3 +This package provides SWAP modules for TW3 + +%post tw3 +ln -s /opt/swap/modules/tw3 /opt/swap/sdk + +%preun tw3 +rm /opt/swap/sdk + +%files tw3 +%license LICENSE.GPL-2.0+ +/opt/swap/modules/tw3/ +%endif # BUILD_PACKAGE_TW3 + + %if %{BUILD_PACKAGE_RPI3} %package rpi3 Summary: SWAP modules for RPI3 -- 2.7.4 From 5f8f8147b0c4ab1554279ac4570e96b1ac8c6ba6 Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Wed, 30 Jan 2019 21:28:45 +0300 Subject: [PATCH 11/16] us_manager: fix incorrect counter usage in sspt_proc Change-Id: Ia1b26a2d2f6110187af4efad084e1877e2432eb2 Signed-off-by: Vyacheslav Cherkashin --- modules/us_manager/sspt/sspt_proc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/us_manager/sspt/sspt_proc.c b/modules/us_manager/sspt/sspt_proc.c index e4d9159..9be8813 100644 --- a/modules/us_manager/sspt/sspt_proc.c +++ b/modules/us_manager/sspt/sspt_proc.c @@ -339,9 +339,11 @@ struct sspt_proc *sspt_proc_get_by_task_or_new(struct task_struct *task) kproc = kproc_by_task(leader); if (kproc->proc) - goto out; + return sspt_proc_get(kproc->proc); proc = sspt_proc_create(leader); + if (proc == NULL) + return NULL; spin_lock(&kproc->lock); if (kproc->proc == NULL) { @@ -358,7 +360,6 @@ struct sspt_proc *sspt_proc_get_by_task_or_new(struct task_struct *task) if (proc) sspt_proc_free(proc); -out: return kproc->proc; } -- 2.7.4 From 3be159f09098c595b7a68813a2d72bc0439b0362 Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Fri, 10 May 2019 18:34:20 +0900 Subject: [PATCH 12/16] Add the swap-modules-rpi3 package build for 32-bit arm Currently, only arm64 build for rpi3 is supported, but rpi3 kernel also support 32-bit arm. To support the 32-bit kernel, add the swap-modules-rpi3 package build for 32-bit arm. Note: new arm built rpm is named with arm arch name because already existing arm64 built, arm repackaged rpm file name has aarch64 arch like swap-modules-rpi3-aarch64. Change-Id: Ica1ab4c28f6bbc71e1fb69bc4c2e3f5b39250a44 Signed-off-by: Seung-Woo Kim --- packaging/swap-modules.spec | 46 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/packaging/swap-modules.spec b/packaging/swap-modules.spec index 758f676..37b0a09 100755 --- a/packaging/swap-modules.spec +++ b/packaging/swap-modules.spec @@ -21,7 +21,8 @@ Kernel modules for SWAP %define BUILD_PACKAGE_TM2 1 %define BUILD_PACKAGE_TW2 1 %define BUILD_PACKAGE_TW3 1 -%define BUILD_PACKAGE_RPI3 1 +%define BUILD_PACKAGE_RPI3_ARM64 1 +%define BUILD_PACKAGE_RPI3_ARM32 1 %define BUILD_PACKAGE_ODROIDXU3 1 %define BUILD_PACKAGE_EMULATOR32 1 @@ -34,12 +35,13 @@ Kernel modules for SWAP %ifnarch %arm %define BUILD_PACKAGE_TM1 0 %define BUILD_PACKAGE_ODROIDXU3 0 + %define BUILD_PACKAGE_RPI3_ARM32 0 %endif %ifnarch aarch64 %define BUILD_PACKAGE_TM2 0 %define BUILD_PACKAGE_TW2 0 %define BUILD_PACKAGE_TW3 0 - %define BUILD_PACKAGE_RPI3 0 + %define BUILD_PACKAGE_RPI3_ARM64 0 %endif %if ! %{with emulator} %define BUILD_PACKAGE_EMULATOR32 0 @@ -77,12 +79,18 @@ cd modules ./pack.sh /tmp/modules/tw3 %endif -%if %{BUILD_PACKAGE_RPI3} +%if %{BUILD_PACKAGE_RPI3_ARM64} ./build.sh --kernel /boot/kernel/devel/kernel-devel-arm64-rpi3 --arch arm64 clean ./build.sh --kernel /boot/kernel/devel/kernel-devel-arm64-rpi3 --arch arm64 compile ./pack.sh /tmp/modules/rpi3 %endif +%if %{BUILD_PACKAGE_RPI3_ARM32} + ./build.sh --kernel /boot/kernel/devel/kernel-devel-arm-rpi3 --arch arm clean + ./build.sh --kernel /boot/kernel/devel/kernel-devel-arm-rpi3 --arch arm compile + ./pack.sh /tmp/modules/rpi3-arm32 +%endif + %if %{BUILD_PACKAGE_ODROIDXU3} ./build.sh --kernel /boot/kernel/devel/kernel-devel-arm-odroidxu3 --arch arm clean ./build.sh --kernel /boot/kernel/devel/kernel-devel-arm-odroidxu3 --arch arm compile @@ -115,10 +123,14 @@ mkdir -p %{buildroot}/opt/swap/modules/ mv /tmp/modules/tw3 %{buildroot}/opt/swap/modules/ %endif -%if %{BUILD_PACKAGE_RPI3} +%if %{BUILD_PACKAGE_RPI3_ARM64} mv /tmp/modules/rpi3 %{buildroot}/opt/swap/modules/ %endif +%if %{BUILD_PACKAGE_RPI3_ARM32} + mv /tmp/modules/rpi3-arm32 %{buildroot}/opt/swap/modules/ +%endif + %if %{BUILD_PACKAGE_ODROIDXU3} mv /tmp/modules/odroidxu3 %{buildroot}/opt/swap/modules/ %endif @@ -216,7 +228,7 @@ rm /opt/swap/sdk %endif # BUILD_PACKAGE_TW3 -%if %{BUILD_PACKAGE_RPI3} +%if %{BUILD_PACKAGE_RPI3_ARM64} %package rpi3 Summary: SWAP modules for RPI3 Provides: swap-modules @@ -235,7 +247,29 @@ rm /opt/swap/sdk %files rpi3 %license LICENSE.GPL-2.0+ /opt/swap/modules/rpi3/ -%endif # BUILD_PACKAGE_RPI3 +%endif # BUILD_PACKAGE_RPI3_ARM64 + + +%if %{BUILD_PACKAGE_RPI3_ARM32} +%package rpi3-arm +Summary: SWAP modules for RPI3 +Provides: swap-modules +Provides: swap-modules = %{version}-%{release} +BuildRequires: arm-rpi3-linux-kernel-devel + +%description rpi3-arm +This package provides SWAP modules for RPI3 + +%post rpi3-arm +ln -s /opt/swap/modules/rpi3-arm32 /opt/swap/sdk + +%preun rpi3-arm +rm /opt/swap/sdk + +%files rpi3-arm +%license LICENSE.GPL-2.0+ +/opt/swap/modules/rpi3-arm32/ +%endif # BUILD_PACKAGE_RPI3_ARM32 %if %{BUILD_PACKAGE_ODROIDXU3} -- 2.7.4 From 9dbefa5688afe8ac2ba2a29d3410250b95f17bc0 Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Wed, 22 May 2019 17:12:40 +0900 Subject: [PATCH 13/16] Add support kernel v4.19 Change-Id: Id838ca74209cc3236db0768155aaabbd1e7e4e7e Signed-off-by: Vyacheslav Cherkashin --- modules/arch/arm/probes/compat_arm64.h | 7 +++++++ modules/master/wait.h | 14 ++++++++++++++ modules/parser/usm_msg.c | 20 ++++++++++++++++---- modules/uprobe/arch/arm64/swap-asm/swap_uprobes.c | 1 + 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/modules/arch/arm/probes/compat_arm64.h b/modules/arch/arm/probes/compat_arm64.h index e85766e..bf4d7b9 100644 --- a/modules/arch/arm/probes/compat_arm64.h +++ b/modules/arch/arm/probes/compat_arm64.h @@ -26,6 +26,13 @@ #ifdef CONFIG_ARM64 +# include +# if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0) +# define COMPAT_PSR_MODE_MASK PSR_AA32_MODE_MASK +# define COMPAT_PSR_MODE_USR PSR_AA32_MODE_USR +# define COMPAT_PSR_T_BIT PSR_AA32_T_BIT +# endif /* #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0) */ + # define PSR_T_BIT COMPAT_PSR_T_BIT # define ARM_r0 compat_usr(0) diff --git a/modules/master/wait.h b/modules/master/wait.h index e003027..a23f59c 100644 --- a/modules/master/wait.h +++ b/modules/master/wait.h @@ -32,6 +32,20 @@ int wait_on_atomic_t(atomic_t *val, int (*action)(atomic_t *), unsigned mode) # include #else /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 13, 0) */ # include +# if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0) +# include +static inline void wake_up_atomic_t(atomic_t *val) +{ + wake_up_var(val); +} + +static inline int wait_on_atomic_t(atomic_t *val, int (*action)(atomic_t *), + unsigned mode) +{ + wait_var_event(val, !atomic_read(val)); + return 0; +} +# endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0) */ #endif /* LINUX_VERSION_CODE */ #endif /* _SWAP_WAIT_H */ diff --git a/modules/parser/usm_msg.c b/modules/parser/usm_msg.c index 673fad7..cd96aea 100644 --- a/modules/parser/usm_msg.c +++ b/modules/parser/usm_msg.c @@ -69,9 +69,12 @@ static void kmem_info_fill_common(struct kmem_info *info, struct task_struct *ta static void kmem_info_fill(struct kmem_info *info, struct task_struct *task) { #if defined(CONFIG_ARM) +# if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0) +# define VECTORS_BASE CONFIG_VECTORS_BASE +# endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0) */ info->name = "[vectors]"; - info->start = CONFIG_VECTORS_BASE; - info->end = CONFIG_VECTORS_BASE + PAGE_SIZE; + info->start = VECTORS_BASE; + info->end = VECTORS_BASE + PAGE_SIZE; #elif defined(CONFIG_ARM64) if (test_ti_thread_flag(task_thread_info(task), TIF_32BIT)) { info->name = "[vectors]"; @@ -547,6 +550,16 @@ static int is_file_mode(umode_t mode) return S_ISREG(mode); } +static int do_kernel_getsockname(struct socket *sock, struct sockaddr *addr) +{ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0) + return kernel_getsockname(sock, addr); +#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0) */ + int addrlen; + return kernel_getsockname(sock, addr, &addrlen); +#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0) */ +} + static int pack_osock(void *data, size_t size, int fd, struct file *file, loff_t fsize) { @@ -556,7 +569,6 @@ static int pack_osock(void *data, size_t size, int fd, struct file *file, struct sockaddr *saddr = (struct sockaddr *)&addr; struct sockaddr_in *sin = (struct sockaddr_in *)&addr; int ret_size = sizeof(*pack_sock); - int addrlen; int err; if (size < sizeof(*pack_sock)) @@ -570,7 +582,7 @@ static int pack_osock(void *data, size_t size, int fd, struct file *file, if (!sock) return 0; - kernel_getsockname(sock, saddr, &addrlen); + do_kernel_getsockname(sock, saddr); pack_sock = (struct osock *)data; pack_sock->fd = (u32)fd; diff --git a/modules/uprobe/arch/arm64/swap-asm/swap_uprobes.c b/modules/uprobe/arch/arm64/swap-asm/swap_uprobes.c index d5e2627..09ee042 100644 --- a/modules/uprobe/arch/arm64/swap-asm/swap_uprobes.c +++ b/modules/uprobe/arch/arm64/swap-asm/swap_uprobes.c @@ -22,6 +22,7 @@ #include #include +#include /* needed for asm/traps.h */ #include #include #include -- 2.7.4 From 151a05a5ad16ef6ec3ac86af6005cfddbed30a60 Mon Sep 17 00:00:00 2001 From: Dongkyun Son Date: Mon, 13 Jan 2020 19:23:36 +0900 Subject: [PATCH 14/16] Replace '-Werror' with '-w': Inhibit all warning messages. to ignore kernel warning on GCC9 e.g, include/linux/init.h:342:6: error: 'init_module' specifies less restrictive attribute than its target '__init_mod': 'cold' [-Werror=missing-attributes] [ 27s] 342 | int init_module(void) __attribute__((alias(#initfn))); [ 27s] | ^~~~~~~~~~~ Change-Id: I50242ccd7e154bcdc817d3912e7a20a03a6d8b5f Signed-off-by: Dongkyun Son --- modules/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/build.sh b/modules/build.sh index 5b1e3a5..0a3a9a0 100755 --- a/modules/build.sh +++ b/modules/build.sh @@ -76,7 +76,7 @@ else show_usage_and_exit fi -MCFLAGS="-Werror" +MCFLAGS="-w" CMDLINE_ARGS="" CMDLINE_ARGS="CROSS_COMPILE=${TOOLCHAIN} ARCH=${ARCH} -C ${KERNELDIR}" -- 2.7.4 From c7462563ff366408df34819a941ccb2c4f0ef234 Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Tue, 15 Nov 2022 11:51:54 +0900 Subject: [PATCH 15/16] packaging: Remove rpi3 board support From Tizen 7.5, rpi3 support and its build are removed. So remove swap-modules rpi3 support also. Change-Id: I9e87c269b0dbebde6c5fad45a5bcc539b2041b4a Signed-off-by: Seung-Woo Kim --- packaging/baselibs.conf | 7 ----- packaging/swap-modules.spec | 68 --------------------------------------------- 2 files changed, 75 deletions(-) diff --git a/packaging/baselibs.conf b/packaging/baselibs.conf index 96df1a9..3b2fbdb 100644 --- a/packaging/baselibs.conf +++ b/packaging/baselibs.conf @@ -20,10 +20,3 @@ swap-modules-tw3 post "ln -s /opt/swap/modules/tw3 /opt/swap/sdk" preun "rm /opt/swap/sdk" +/ - -swap-modules-rpi3 - provides "swap-modules" - provides "swap-modules = %{version}-%{release}" - post "ln -s /opt/swap/modules/rpi3 /opt/swap/sdk" - preun "rm /opt/swap/sdk" - +/ diff --git a/packaging/swap-modules.spec b/packaging/swap-modules.spec index 37b0a09..d66c54c 100755 --- a/packaging/swap-modules.spec +++ b/packaging/swap-modules.spec @@ -21,8 +21,6 @@ Kernel modules for SWAP %define BUILD_PACKAGE_TM2 1 %define BUILD_PACKAGE_TW2 1 %define BUILD_PACKAGE_TW3 1 -%define BUILD_PACKAGE_RPI3_ARM64 1 -%define BUILD_PACKAGE_RPI3_ARM32 1 %define BUILD_PACKAGE_ODROIDXU3 1 %define BUILD_PACKAGE_EMULATOR32 1 @@ -35,13 +33,11 @@ Kernel modules for SWAP %ifnarch %arm %define BUILD_PACKAGE_TM1 0 %define BUILD_PACKAGE_ODROIDXU3 0 - %define BUILD_PACKAGE_RPI3_ARM32 0 %endif %ifnarch aarch64 %define BUILD_PACKAGE_TM2 0 %define BUILD_PACKAGE_TW2 0 %define BUILD_PACKAGE_TW3 0 - %define BUILD_PACKAGE_RPI3_ARM64 0 %endif %if ! %{with emulator} %define BUILD_PACKAGE_EMULATOR32 0 @@ -79,18 +75,6 @@ cd modules ./pack.sh /tmp/modules/tw3 %endif -%if %{BUILD_PACKAGE_RPI3_ARM64} - ./build.sh --kernel /boot/kernel/devel/kernel-devel-arm64-rpi3 --arch arm64 clean - ./build.sh --kernel /boot/kernel/devel/kernel-devel-arm64-rpi3 --arch arm64 compile - ./pack.sh /tmp/modules/rpi3 -%endif - -%if %{BUILD_PACKAGE_RPI3_ARM32} - ./build.sh --kernel /boot/kernel/devel/kernel-devel-arm-rpi3 --arch arm clean - ./build.sh --kernel /boot/kernel/devel/kernel-devel-arm-rpi3 --arch arm compile - ./pack.sh /tmp/modules/rpi3-arm32 -%endif - %if %{BUILD_PACKAGE_ODROIDXU3} ./build.sh --kernel /boot/kernel/devel/kernel-devel-arm-odroidxu3 --arch arm clean ./build.sh --kernel /boot/kernel/devel/kernel-devel-arm-odroidxu3 --arch arm compile @@ -123,14 +107,6 @@ mkdir -p %{buildroot}/opt/swap/modules/ mv /tmp/modules/tw3 %{buildroot}/opt/swap/modules/ %endif -%if %{BUILD_PACKAGE_RPI3_ARM64} - mv /tmp/modules/rpi3 %{buildroot}/opt/swap/modules/ -%endif - -%if %{BUILD_PACKAGE_RPI3_ARM32} - mv /tmp/modules/rpi3-arm32 %{buildroot}/opt/swap/modules/ -%endif - %if %{BUILD_PACKAGE_ODROIDXU3} mv /tmp/modules/odroidxu3 %{buildroot}/opt/swap/modules/ %endif @@ -228,50 +204,6 @@ rm /opt/swap/sdk %endif # BUILD_PACKAGE_TW3 -%if %{BUILD_PACKAGE_RPI3_ARM64} -%package rpi3 -Summary: SWAP modules for RPI3 -Provides: swap-modules -Provides: swap-modules = %{version}-%{release} -BuildRequires: arm64-rpi3-linux-kernel-devel - -%description rpi3 -This package provides SWAP modules for RPI3 - -%post rpi3 -ln -s /opt/swap/modules/rpi3 /opt/swap/sdk - -%preun rpi3 -rm /opt/swap/sdk - -%files rpi3 -%license LICENSE.GPL-2.0+ -/opt/swap/modules/rpi3/ -%endif # BUILD_PACKAGE_RPI3_ARM64 - - -%if %{BUILD_PACKAGE_RPI3_ARM32} -%package rpi3-arm -Summary: SWAP modules for RPI3 -Provides: swap-modules -Provides: swap-modules = %{version}-%{release} -BuildRequires: arm-rpi3-linux-kernel-devel - -%description rpi3-arm -This package provides SWAP modules for RPI3 - -%post rpi3-arm -ln -s /opt/swap/modules/rpi3-arm32 /opt/swap/sdk - -%preun rpi3-arm -rm /opt/swap/sdk - -%files rpi3-arm -%license LICENSE.GPL-2.0+ -/opt/swap/modules/rpi3-arm32/ -%endif # BUILD_PACKAGE_RPI3_ARM32 - - %if %{BUILD_PACKAGE_ODROIDXU3} %package odroidxu3 Summary: SWAP modules for ODROIDXU3 -- 2.7.4 From f58ab430e367b438730417438d9de3bc5ca767d8 Mon Sep 17 00:00:00 2001 From: Jaehoon Chung Date: Thu, 17 Nov 2022 13:57:23 +0900 Subject: [PATCH 16/16] packaging: remove unused boards support Remove unused boards support. Odroid-XU3 and TM2 boards didn't support anymore. Before removing linux-exynos, it has to remove these packages. Change-Id: I84a850475c0f3c571a3f46c8b557833e91a0cae9 Signed-off-by: Jaehoon Chung --- packaging/baselibs.conf | 7 ----- packaging/swap-modules.spec | 70 --------------------------------------------- 2 files changed, 77 deletions(-) diff --git a/packaging/baselibs.conf b/packaging/baselibs.conf index 3b2fbdb..f39277f 100644 --- a/packaging/baselibs.conf +++ b/packaging/baselibs.conf @@ -1,12 +1,5 @@ arch aarch64 targets armv7l:aarch64 -swap-modules-tm2 - provides "swap-modules" - provides "swap-modules = %{version}-%{release}" - post "ln -s /opt/swap/modules/tm2 /opt/swap/sdk" - preun "rm /opt/swap/sdk" - +/ - swap-modules-tw2 provides "swap-modules" provides "swap-modules = %{version}-%{release}" diff --git a/packaging/swap-modules.spec b/packaging/swap-modules.spec index d66c54c..0f3fcb6 100755 --- a/packaging/swap-modules.spec +++ b/packaging/swap-modules.spec @@ -18,10 +18,8 @@ Kernel modules for SWAP # 0 - disable # 1 - enable %define BUILD_PACKAGE_TM1 1 -%define BUILD_PACKAGE_TM2 1 %define BUILD_PACKAGE_TW2 1 %define BUILD_PACKAGE_TW3 1 -%define BUILD_PACKAGE_ODROIDXU3 1 %define BUILD_PACKAGE_EMULATOR32 1 @@ -32,10 +30,8 @@ Kernel modules for SWAP %endif %ifnarch %arm %define BUILD_PACKAGE_TM1 0 - %define BUILD_PACKAGE_ODROIDXU3 0 %endif %ifnarch aarch64 - %define BUILD_PACKAGE_TM2 0 %define BUILD_PACKAGE_TW2 0 %define BUILD_PACKAGE_TW3 0 %endif @@ -57,12 +53,6 @@ cd modules ./pack.sh /tmp/modules/tm1 %endif -%if %{BUILD_PACKAGE_TM2} - ./build.sh --kernel /boot/kernel/devel/kernel-devel-arm64-tm2 --arch arm64 clean - ./build.sh --kernel /boot/kernel/devel/kernel-devel-arm64-tm2 --arch arm64 compile - ./pack.sh /tmp/modules/tm2 -%endif - %if %{BUILD_PACKAGE_TW2} ./build.sh --kernel /boot/kernel/devel/kernel-devel-tw2 --arch arm64 clean ./build.sh --kernel /boot/kernel/devel/kernel-devel-tw2 --arch arm64 compile @@ -75,12 +65,6 @@ cd modules ./pack.sh /tmp/modules/tw3 %endif -%if %{BUILD_PACKAGE_ODROIDXU3} - ./build.sh --kernel /boot/kernel/devel/kernel-devel-arm-odroidxu3 --arch arm clean - ./build.sh --kernel /boot/kernel/devel/kernel-devel-arm-odroidxu3 --arch arm compile - ./pack.sh /tmp/modules/odroidxu3 -%endif - %if %{BUILD_PACKAGE_EMULATOR32} ./build.sh --kernel /usr/src/linux-headers --arch i386 clean ./build.sh --kernel /usr/src/linux-headers --arch i386 compile @@ -95,10 +79,6 @@ mkdir -p %{buildroot}/opt/swap/modules/ mv /tmp/modules/tm1 %{buildroot}/opt/swap/modules/ %endif -%if %{BUILD_PACKAGE_TM2} - mv /tmp/modules/tm2 %{buildroot}/opt/swap/modules/ -%endif - %if %{BUILD_PACKAGE_TW2} mv /tmp/modules/tw2 %{buildroot}/opt/swap/modules/ %endif @@ -107,10 +87,6 @@ mkdir -p %{buildroot}/opt/swap/modules/ mv /tmp/modules/tw3 %{buildroot}/opt/swap/modules/ %endif -%if %{BUILD_PACKAGE_ODROIDXU3} - mv /tmp/modules/odroidxu3 %{buildroot}/opt/swap/modules/ -%endif - %if %{BUILD_PACKAGE_EMULATOR32} mv /tmp/modules/emulator32 %{buildroot}/opt/swap/modules/ %endif @@ -137,29 +113,6 @@ rm /opt/swap/sdk /opt/swap/modules/tm1/ %endif # BUILD_PACKAGE_TM1 - -%if %{BUILD_PACKAGE_TM2} -%package tm2 -Summary: SWAP modules for TM2 -Provides: swap-modules -Provides: swap-modules = %{version}-%{release} -BuildRequires: arm64-tm2-linux-kernel-devel - -%description tm2 -This package provides SWAP modules for TM2 - -%post tm2 -ln -s /opt/swap/modules/tm2 /opt/swap/sdk - -%preun tm2 -rm /opt/swap/sdk - -%files tm2 -%license LICENSE.GPL-2.0+ -/opt/swap/modules/tm2/ -%endif # BUILD_PACKAGE_TM2 - - %if %{BUILD_PACKAGE_TW2} %package tw2 Summary: SWAP modules for TW2 @@ -203,29 +156,6 @@ rm /opt/swap/sdk /opt/swap/modules/tw3/ %endif # BUILD_PACKAGE_TW3 - -%if %{BUILD_PACKAGE_ODROIDXU3} -%package odroidxu3 -Summary: SWAP modules for ODROIDXU3 -Provides: swap-modules -Provides: swap-modules = %{version}-%{release} -BuildRequires: arm-odroidxu3-linux-kernel-devel - -%description odroidxu3 -This package provides SWAP modules for ODROIDXU3 - -%post odroidxu3 -ln -s /opt/swap/modules/odroidxu3 /opt/swap/sdk - -%preun odroidxu3 -rm /opt/swap/sdk - -%files odroidxu3 -%license LICENSE.GPL-2.0+ -/opt/swap/modules/odroidxu3/ -%endif # BUILD_PACKAGE_ODROIDXU3 - - %if %{BUILD_PACKAGE_EMULATOR32} %package emulator32 Summary: SWAP modules for Emulator x86 -- 2.7.4