From 30e7cfe52973da30a7b580f1c2727632c8cbfd9d Mon Sep 17 00:00:00 2001 From: blue Date: Thu, 18 May 2023 11:48:48 +0000 Subject: [PATCH 1/2] =?UTF-8?q?update=20qtfs/qtfs=5Fserver/qtfs-server.c.?= =?UTF-8?q?=20=E5=8E=BB=E6=8E=89=E4=B8=8D=E5=BF=85=E8=A6=81=E7=9A=84?= =?UTF-8?q?=E5=9C=B0=E5=9D=80=E6=89=93=E5=8D=B0=EF=BC=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=8D=E6=AD=A3=E7=A1=AE=E7=9A=84qtfs=5Ferr=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=EF=BC=8C=E4=B8=BAg=5Fwhitelist=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=AF=BB=E5=86=99=E9=94=81=E4=BF=9D=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: blue --- qtfs/qtfs_server/qtfs-server.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/qtfs/qtfs_server/qtfs-server.c b/qtfs/qtfs_server/qtfs-server.c index 7bedb15..0c14021 100644 --- a/qtfs/qtfs_server/qtfs-server.c +++ b/qtfs/qtfs_server/qtfs-server.c @@ -44,6 +44,7 @@ struct qtfs_server_epoll_s qtfs_epoll = { }; struct whitelist* g_whitelist[QTFS_WHITELIST_MAX]; +rwlock_t g_whitelist_rwlock; long qtfs_server_epoll_thread(struct qtfs_conn_var_s *pvar) { @@ -186,9 +187,7 @@ long qtfs_server_misc_ioctl(struct file *file, unsigned int cmd, unsigned long a return QTERROR; } for (i = 0; i < init_userp.thread_nums; i++) - qtfs_info("userp set idx:%d size:%lu user pointer:%lx %lx", i, - qtfs_userps[i].size, (unsigned long)qtfs_userps[i].userp, - (unsigned long)qtfs_userps[i].userp2); + qtfs_info("userp set idx:%d size:%lu", i, qtfs_userps[i].size); break; case QTFS_IOCTL_THREAD_RUN: pvar = qtfs_conn_get_param(); @@ -275,13 +274,17 @@ long qtfs_server_misc_ioctl(struct file *file, unsigned int cmd, unsigned long a kfree(tmp); return QTERROR; } + write_lock(&g_whitelist_rwlock); if (g_whitelist[tmp->type] != NULL) { kfree(g_whitelist[tmp->type]); } g_whitelist[tmp->type] = tmp; + write_unlock(&g_whitelist_rwlock); + read_lock(&g_whitelist_rwlock) for (i = 0; i < g_whitelist[tmp->type]->len; i++) { - qtfs_err("init %d list:%d %s", tmp->type, i, g_whitelist[tmp->type]->wl[i].path); + qtfs_info("init %d list:%d %s", tmp->type, i, g_whitelist[tmp->type]->wl[i].path); } + read_unlock(&g_whitelist_rwlock) break; case QTFS_IOCTL_ALLINFO: case QTFS_IOCTL_CLEARALL: @@ -306,9 +309,14 @@ static int __init qtfs_server_init(void) qtfs_log_init(qtfs_log_level, sizeof(qtfs_log_level)); if (qtfs_kallsyms_hack_init() != 0) return -1; + rwlock_init(&g_whitelist_rwlock); + + write_lock(&g_whitelist_rwlock); for (i = 0; i < QTFS_WHITELIST_MAX; i++) { g_whitelist[i] = NULL; } + write_unlock(&g_whitelist_rwlock); + qtfs_diag_info = (struct qtinfo *)kmalloc(sizeof(struct qtinfo), GFP_KERNEL); if (qtfs_diag_info == NULL) { qtfs_err("kmalloc qtfs diag info failed."); @@ -370,12 +378,16 @@ static void __exit qtfs_server_exit(void) kfree(qtfs_userps); qtfs_userps = NULL; } + + write_lock(&g_whitelist_rwlock); for (i = 0; i < QTFS_WHITELIST_MAX; i++) { if (g_whitelist[i] != NULL) { kfree(g_whitelist[i]); } } - qtfs_misc_destroy(); + write_unlock(&g_whitelist_rwlock); + + qtfs_misc_destroy(); qtfs_uds_remote_exit(); qtfs_syscall_replace_stop(); qtfs_info("qtfs server exit done.\n"); @@ -392,5 +404,4 @@ module_param_string(qtfs_conn_type, qtfs_conn_type, sizeof(qtfs_conn_type), 0600 module_init(qtfs_server_init); module_exit(qtfs_server_exit); MODULE_AUTHOR("liqiang64@huawei.com"); -MODULE_LICENSE("GPL"); - +MODULE_LICENSE("GPL"); \ No newline at end of file -- Gitee From f1971dced2c4bc4e3139ab2ed9aa0c47904e814f Mon Sep 17 00:00:00 2001 From: blue Date: Thu, 18 May 2023 11:56:43 +0000 Subject: [PATCH 2/2] =?UTF-8?q?update=20qtfs/qtfs=5Fserver/fsops.c.=20?= =?UTF-8?q?=E4=B8=BAg=5Fwhitelist=E7=9A=84=E4=BD=BF=E7=94=A8=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E9=94=81=E4=BF=9D=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: blue --- qtfs/qtfs_server/fsops.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qtfs/qtfs_server/fsops.c b/qtfs/qtfs_server/fsops.c index c1705d6..32624e8 100644 --- a/qtfs/qtfs_server/fsops.c +++ b/qtfs/qtfs_server/fsops.c @@ -49,7 +49,9 @@ bool in_white_list(char *path, int type) { int i, in_wl = -1; + read_lock(&g_whitelist_lock); if (!g_whitelist[type]) { + read_unlock(&g_whitelist_lock); return true; } for (i = 0; i < g_whitelist[type]->len; i++) { @@ -58,6 +60,7 @@ bool in_white_list(char *path, int type) break; } } + read_unlock(&g_whitelist_lock); return in_wl != -1; } -- Gitee