update some bugfix to v1.6
Signed-off-by: liqiang <liqiang64@huawei.com>
This commit is contained in:
parent
76f8894a97
commit
56990640b1
115
0004-fix-rexec-exit-code-bug-and-fix-some-warning.patch
Normal file
115
0004-fix-rexec-exit-code-bug-and-fix-some-warning.patch
Normal file
@ -0,0 +1,115 @@
|
||||
From f624bc7602c459de3cbbcd691309c1c66438d109 Mon Sep 17 00:00:00 2001
|
||||
From: liqiang <liqiang64@huawei.com>
|
||||
Date: Mon, 11 Dec 2023 10:46:07 +0800
|
||||
Subject: [PATCH 04/12] fix rexec exit code bug, and fix some warning
|
||||
|
||||
Signed-off-by: liqiang <liqiang64@huawei.com>
|
||||
---
|
||||
qtfs/qtfs/qtfs-mod.c | 6 +++---
|
||||
qtfs/rexec/rexec.c | 11 ++++++-----
|
||||
qtfs/rexec/rexec_server.c | 6 ++++--
|
||||
3 files changed, 13 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/qtfs/qtfs/qtfs-mod.c b/qtfs/qtfs/qtfs-mod.c
|
||||
index c4ef72c..0b6cd65 100644
|
||||
--- a/qtfs/qtfs/qtfs-mod.c
|
||||
+++ b/qtfs/qtfs/qtfs-mod.c
|
||||
@@ -66,7 +66,7 @@ void *qtfs_remote_run(struct qtfs_conn_var_s *pvar, unsigned int type, unsigned
|
||||
if (ret <= 0) {
|
||||
qtfs_err("qtfs remote run send failed, ret:%d pvar sendlen:%lu.", ret, pvar->vec_send.iov_len);
|
||||
qtinfo_senderrinc(req->type);
|
||||
- return (void *)ret;
|
||||
+ return ERR_PTR(ret);
|
||||
}
|
||||
qtinfo_sendinc(type);
|
||||
|
||||
@@ -100,7 +100,7 @@ retry:
|
||||
}
|
||||
if (retrytimes >= 5 && ret == -EINTR) {
|
||||
qtfs_err("qtfs conn recv get retry signal(%d) too many times, stop retrying, signal:0x%lx", ret, (unsigned long)current->pending.signal.sig[0]);
|
||||
- return (void *)ret;
|
||||
+ return ERR_PTR(ret);
|
||||
}
|
||||
retrytimes++;
|
||||
msleep(1);
|
||||
@@ -109,7 +109,7 @@ retry:
|
||||
if (ret < 0) {
|
||||
qtfs_err("qtfs remote run error, req_type:%u, ret:%d.", req->type, ret);
|
||||
qtinfo_recverrinc(req->type);
|
||||
- return (void *)ret;
|
||||
+ return ERR_PTR(ret);
|
||||
}
|
||||
if (retrytimes > 0)
|
||||
qtfs_debug("qtfs remote run retry times:%lu.", retrytimes);
|
||||
diff --git a/qtfs/rexec/rexec.c b/qtfs/rexec/rexec.c
|
||||
index 060abc5..e24c0ad 100644
|
||||
--- a/qtfs/rexec/rexec.c
|
||||
+++ b/qtfs/rexec/rexec.c
|
||||
@@ -183,7 +183,7 @@ static int rexec_conn_msg(struct rexec_client_event *evt)
|
||||
}
|
||||
} else {
|
||||
char msg[sizeof(struct rexec_msg) + 1];
|
||||
- struct rexec_msg *hs = msg;
|
||||
+ struct rexec_msg *hs = (struct rexec_msg *)msg;
|
||||
char *ok = hs->msg;
|
||||
hs->msgtype = REXEC_HANDSHAKE;
|
||||
hs->msglen = 1;
|
||||
@@ -558,7 +558,7 @@ err_end:
|
||||
static int rexec_handshake_proc(struct rexec_client_event *evt)
|
||||
{
|
||||
char msg[sizeof(struct rexec_msg) + 1];
|
||||
- struct rexec_msg *hs = msg;
|
||||
+ struct rexec_msg *hs = (struct rexec_msg *)msg;
|
||||
int ret = read(evt->fd, hs->msg, 1);
|
||||
if (ret <= 0) {
|
||||
rexec_err("read from handshake pipe failed, ret:%d err:%d", ret, errno);
|
||||
@@ -686,8 +686,9 @@ static void *rexec_pipe_proxy_thread(void *arg)
|
||||
static void *rexec_conn_thread(void *arg)
|
||||
{
|
||||
struct rexec_thread_arg *parg = (struct rexec_thread_arg *)arg;
|
||||
+ int exit_status = rexec_run(parg->efd, parg->connfd, parg->argv);
|
||||
|
||||
- return (void *)rexec_run(parg->efd, parg->connfd, parg->argv);
|
||||
+ pthread_exit((void *)&exit_status);
|
||||
}
|
||||
|
||||
static void rexec_global_var_init()
|
||||
@@ -763,9 +764,9 @@ int main(int argc, char *argv[])
|
||||
connarg.connfd = connfd;
|
||||
connarg.argv = argv;
|
||||
(void)pthread_create(&thrd_conn, NULL, rexec_conn_thread, &connarg);
|
||||
- pthread_join(thrd_conn, (void *)&exit_status);
|
||||
+ pthread_join(thrd_conn, (void **)&exit_status);
|
||||
fclose(rexec_logfile);
|
||||
- exit((int)exit_status);
|
||||
+ exit(*(int *)exit_status);
|
||||
err_end:
|
||||
fclose(rexec_logfile);
|
||||
rexec_logfile = NULL;
|
||||
diff --git a/qtfs/rexec/rexec_server.c b/qtfs/rexec/rexec_server.c
|
||||
index 7182a9e..5e571fd 100644
|
||||
--- a/qtfs/rexec/rexec_server.c
|
||||
+++ b/qtfs/rexec/rexec_server.c
|
||||
@@ -379,7 +379,7 @@ static int rexec_start_new_process(int newconnfd)
|
||||
char *ack;
|
||||
int mypid = getpid();
|
||||
char msg[sizeof(struct rexec_msg) + 1];
|
||||
- struct rexec_msg *pm = msg;
|
||||
+ struct rexec_msg *pm = (struct rexec_msg *)msg;
|
||||
pm->msgtype = REXEC_PIDMAP;
|
||||
pm->msglen = 0;
|
||||
pm->pid = mypid;
|
||||
@@ -443,7 +443,9 @@ err_free:
|
||||
err_to_parent:
|
||||
do {
|
||||
int errpid = -1;
|
||||
- write(pipefd[PIPE_WRITE], &errpid, sizeof(int));
|
||||
+ if (write(pipefd[PIPE_WRITE], &errpid, sizeof(int)) <= 0) {
|
||||
+ rexec_err("write err ack to parent failed, errno:%d", errno);
|
||||
+ }
|
||||
} while (0);
|
||||
|
||||
exit(0);
|
||||
--
|
||||
2.37.1 (Apple Git-137.1)
|
||||
|
||||
28
0005-add-cmake-to-adapt-server-fifo.patch
Normal file
28
0005-add-cmake-to-adapt-server-fifo.patch
Normal file
@ -0,0 +1,28 @@
|
||||
From 0c20dd74f9acc47da17ce0e94c6616b0961f3854 Mon Sep 17 00:00:00 2001
|
||||
From: liqiang <liqiang64@huawei.com>
|
||||
Date: Mon, 11 Dec 2023 11:19:19 +0800
|
||||
Subject: [PATCH 05/12] add cmake to adapt server fifo
|
||||
|
||||
Signed-off-by: liqiang <liqiang64@huawei.com>
|
||||
---
|
||||
qtfs/CMakeLists.txt | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/qtfs/CMakeLists.txt b/qtfs/CMakeLists.txt
|
||||
index 012c8db..4d0e9e3 100644
|
||||
--- a/qtfs/CMakeLists.txt
|
||||
+++ b/qtfs/CMakeLists.txt
|
||||
@@ -18,8 +18,8 @@ target_include_directories(udsproxyd PRIVATE include/ /usr/include/glib-2.0 /usr
|
||||
target_link_libraries(udsproxyd PRIVATE pthread glib-2.0)
|
||||
|
||||
# Build engine
|
||||
-add_executable(engine ipc/uds_main.c ipc/uds_event.c qtfs_common/user_engine.c)
|
||||
-target_include_directories(engine PRIVATE include/ ./ ipc/ /usr/include/glib-2.0 /usr/lib64/glib-2.0/include)
|
||||
+add_executable(engine ipc/uds_main.c ipc/uds_event.c qtfs_common/user_engine.c qtfs_server/server_fifo.c qtfs_common/libsocket.c)
|
||||
+target_include_directories(engine PRIVATE include/ ./ ipc/ qtfs_common/ /usr/include/glib-2.0 /usr/lib64/glib-2.0/include)
|
||||
target_link_libraries(engine PRIVATE glib-2.0 pthread)
|
||||
target_compile_options(engine PRIVATE "-DQTFS_SERVER")
|
||||
|
||||
--
|
||||
2.37.1 (Apple Git-137.1)
|
||||
|
||||
534
0006-code-style-problem-fix.patch
Normal file
534
0006-code-style-problem-fix.patch
Normal file
@ -0,0 +1,534 @@
|
||||
From ba079528b3c1c0fd911ee98353685c4116c8e6f8 Mon Sep 17 00:00:00 2001
|
||||
From: Deng Guangxing <dengguangxing@huawei.com>
|
||||
Date: Mon, 11 Dec 2023 14:20:51 +0800
|
||||
Subject: [PATCH 06/12] code-style problem fix
|
||||
|
||||
Signed-off-by: Deng Guangxing <dengguangxing@huawei.com>
|
||||
---
|
||||
qtfs/ipc/uds_event.c | 6 +-
|
||||
qtfs/qtfs/fifo.c | 39 ++++++-------
|
||||
qtfs/qtfs/proc.c | 10 ++--
|
||||
qtfs/qtfs/qtfs-mod.c | 6 +-
|
||||
qtfs/qtfs/sb.c | 7 +--
|
||||
qtfs/qtfs_common/qtfs_check.c | 103 ++++++++++++----------------------
|
||||
qtfs/rexec/rexec.c | 11 ++--
|
||||
7 files changed, 77 insertions(+), 105 deletions(-)
|
||||
|
||||
diff --git a/qtfs/ipc/uds_event.c b/qtfs/ipc/uds_event.c
|
||||
index 4253deb..78a2a97 100644
|
||||
--- a/qtfs/ipc/uds_event.c
|
||||
+++ b/qtfs/ipc/uds_event.c
|
||||
@@ -524,7 +524,7 @@ static int uds_msg_scm_regular_file(int scmfd, int tcpfd, struct uds_event_globa
|
||||
uds_err("failed to calloc memory");
|
||||
return EVENT_ERR;
|
||||
}
|
||||
- sprintf(fdproc, "/proc/self/fd/%d", scmfd);
|
||||
+ snprintf(fdproc, UDS_PATH_MAX, "/proc/self/fd/%d", scmfd);
|
||||
ret = readlink(fdproc, p_scmr->path, UDS_PATH_MAX);
|
||||
if (ret < 0) {
|
||||
uds_err("readlink:%s error, ret:%d, errno:%d", fdproc, ret, errno);
|
||||
@@ -562,7 +562,7 @@ static int uds_msg_scm_fifo_file(int scmfd, int tcpfd, struct uds_event_global_v
|
||||
p_get->msgtype = MSG_SCM_PIPE;
|
||||
p_get->msglen = sizeof(struct uds_stru_scm_pipe);
|
||||
|
||||
- sprintf(path, "/proc/self/fd/%d", scmfd);
|
||||
+ snprintf(path, FDPATH_LEN, "/proc/self/fd/%d", scmfd);
|
||||
lstat(path, &st);
|
||||
if (st.st_mode & S_IRUSR) {
|
||||
p_pipe->dir = SCM_PIPE_READ;
|
||||
@@ -1085,7 +1085,7 @@ int uds_event_debug_level(void *arg, int epfd, struct uds_event_global_var *p_ev
|
||||
|
||||
uds_log("debug level accept a new connection, current level:%s change to:%s", UDS_LOG_STR(cur), UDS_LOG_STR(p_uds_var->loglevel));
|
||||
|
||||
- len = sprintf(p_event_var->iov_base, "+---------------UDS LOG LEVEL UPDATE--------------+\n"
|
||||
+ len = snprintf(p_event_var->iov_base, p_event_var->iov_len, "+---------------UDS LOG LEVEL UPDATE--------------+\n"
|
||||
"+ Log level is:%s before, now change to :%s.\n"
|
||||
"+-------------------------------------------------+\n", UDS_LOG_STR(cur), UDS_LOG_STR(p_uds_var->loglevel));
|
||||
|
||||
diff --git a/qtfs/qtfs/fifo.c b/qtfs/qtfs/fifo.c
|
||||
index 829ce66..f072706 100644
|
||||
--- a/qtfs/qtfs/fifo.c
|
||||
+++ b/qtfs/qtfs/fifo.c
|
||||
@@ -26,9 +26,9 @@
|
||||
|
||||
static void qtfs_fifo_put_file(struct file *file)
|
||||
{
|
||||
- struct private_data *priv = file->private_data;
|
||||
- struct qtfs_conn_var_s *pvar = (struct qtfs_conn_var_s *)priv->priv;
|
||||
- if (pvar == NULL) {
|
||||
+ struct private_data *priv;
|
||||
+ struct qtfs_conn_var_s *pvar;
|
||||
+ if (file == NULL || (priv = file->private_data) == NULL || (pvar = (struct qtfs_conn_var_s *)priv->priv) == NULL) {
|
||||
qtfs_err("fifo private data invalid to put");
|
||||
return;
|
||||
}
|
||||
@@ -110,8 +110,8 @@ int qtfs_fifo_open(struct inode *inode, struct file *file)
|
||||
|
||||
ssize_t qtfs_fifo_readiter(struct kiocb *kio, struct iov_iter *iov)
|
||||
{
|
||||
- struct private_data *priv = kio->ki_filp->private_data;
|
||||
- struct qtfs_conn_var_s *pvar = (struct qtfs_conn_var_s *)priv->priv;
|
||||
+ struct private_data *priv;
|
||||
+ struct qtfs_conn_var_s *pvar;
|
||||
struct qtreq_fifo_read *req;
|
||||
struct qtrsp_fifo_read *rsp;
|
||||
int total = 0;
|
||||
@@ -121,7 +121,7 @@ ssize_t qtfs_fifo_readiter(struct kiocb *kio, struct iov_iter *iov)
|
||||
qtfs_err("signal SIGURG return eintr");
|
||||
return -EINTR;
|
||||
}
|
||||
- if (pvar == NULL || !virt_addr_valid(pvar)) {
|
||||
+ if (!kio || !kio->ki_filp || (priv = kio->ki_filp->private_data) == NULL || (pvar = (struct qtfs_conn_var_s *)priv->priv) == NULL || !virt_addr_valid(pvar)) {
|
||||
qtfs_err("invalid fifo read req, private data is invalid");
|
||||
return -EFAULT;
|
||||
}
|
||||
@@ -154,8 +154,8 @@ ssize_t qtfs_fifo_readiter(struct kiocb *kio, struct iov_iter *iov)
|
||||
|
||||
ssize_t qtfs_fifo_writeiter(struct kiocb *kio, struct iov_iter *iov)
|
||||
{
|
||||
- struct private_data *priv = kio->ki_filp->private_data;
|
||||
- struct qtfs_conn_var_s *pvar = (struct qtfs_conn_var_s *)priv->priv;
|
||||
+ struct private_data *priv;
|
||||
+ struct qtfs_conn_var_s *pvar;
|
||||
struct qtreq_fifo_write *req;
|
||||
struct qtrsp_fifo_write *rsp;
|
||||
|
||||
@@ -163,7 +163,7 @@ ssize_t qtfs_fifo_writeiter(struct kiocb *kio, struct iov_iter *iov)
|
||||
qtfs_err("signal SIGURG return eintr");
|
||||
return -EINTR;
|
||||
}
|
||||
- if (pvar == NULL || !virt_addr_valid(pvar)) {
|
||||
+ if (!kio || !kio->ki_filp || (priv = kio->ki_filp->private_data) == NULL || (pvar = (struct qtfs_conn_var_s *)priv->priv) == NULL || !virt_addr_valid(pvar)) {
|
||||
qtfs_err("invalid fifo write req, private data is invalid");
|
||||
return -EFAULT;
|
||||
}
|
||||
@@ -182,10 +182,11 @@ ssize_t qtfs_fifo_writeiter(struct kiocb *kio, struct iov_iter *iov)
|
||||
|
||||
int qtfs_fifo_release(struct inode *inode, struct file *file)
|
||||
{
|
||||
- struct private_data *priv = file->private_data;
|
||||
- struct qtfs_conn_var_s *pvar = (struct qtfs_conn_var_s *)priv->priv;
|
||||
+ struct private_data *priv;
|
||||
+ struct qtfs_conn_var_s *pvar;
|
||||
struct qtrsp_fifo_close *rsp = NULL;
|
||||
- if (pvar == NULL) {
|
||||
+
|
||||
+ if (file == NULL || (priv = file->private_data) == NULL || (pvar = (struct qtfs_conn_var_s *)priv->priv) == NULL) {
|
||||
qtfs_err("invalid fifo write req, private data is invalid");
|
||||
return -EFAULT;
|
||||
}
|
||||
@@ -202,22 +203,22 @@ int qtfs_fifo_release(struct inode *inode, struct file *file)
|
||||
__poll_t
|
||||
qtfs_poll(struct file *filp, poll_table *wait)
|
||||
{
|
||||
- struct qtfs_inode_priv *priv = filp->f_inode->i_private;
|
||||
+ struct qtfs_inode_priv *priv;
|
||||
__poll_t mask = 0;
|
||||
struct list_head *p;
|
||||
struct qtfs_conn_var_s *pvar;
|
||||
struct qtreq_poll *req;
|
||||
struct qtrsp_poll *rsp;
|
||||
- struct private_data *fpriv = (struct private_data *)filp->private_data;
|
||||
-
|
||||
- poll_wait(filp, &priv->readq, wait);
|
||||
-
|
||||
- p = &priv->readq.head;
|
||||
+ struct private_data *fpriv;
|
||||
|
||||
- if (fpriv->fd < 0) {
|
||||
+ if (!filp || !filp->f_inode || !(priv = filp->f_inode->i_private) || !(fpriv = (struct private_data *)filp->private_data) || fpriv->fd < 0) {
|
||||
qtfs_err("fifo poll priv file invalid.");
|
||||
return 0;
|
||||
}
|
||||
+
|
||||
+ poll_wait(filp, &priv->readq, wait);
|
||||
+ p = &priv->readq.head;
|
||||
+
|
||||
pvar = qtfs_conn_get_param();
|
||||
if (pvar == NULL) {
|
||||
qtfs_err("qtfs fifo poll get param failed.");
|
||||
diff --git a/qtfs/qtfs/proc.c b/qtfs/qtfs/proc.c
|
||||
index 70238ea..deea1c8 100644
|
||||
--- a/qtfs/qtfs/proc.c
|
||||
+++ b/qtfs/qtfs/proc.c
|
||||
@@ -147,7 +147,7 @@ struct dentry *qtfs_proc_lookup(struct inode *parent_inode, struct dentry *child
|
||||
if (pid > 0) {
|
||||
sscanf(cpath, "/proc/%s", tmp);
|
||||
memset(cpath, 0, MAX_PATH_LEN);
|
||||
- sprintf(cpath, "/local_proc/%s", tmp);
|
||||
+ snprintf(cpath, MAX_PATH_LEN, "/local_proc/%s", tmp);
|
||||
qtfs_debug("[%s]: get path from local: %s\n", __func__, cpath);
|
||||
ret = kern_path(cpath, 0, &spath);
|
||||
if(ret) {
|
||||
@@ -208,13 +208,13 @@ const char *qtfs_proc_getlink(struct dentry *dentry,
|
||||
}
|
||||
|
||||
if (!strncmp(path, "/proc/self", 11)) {
|
||||
- sprintf(link, "/local_proc/%d", (int)current->pid);
|
||||
+ snprintf(link, MAX_PATH_LEN, "/local_proc/%d", (int)current->pid);
|
||||
qtfs_info("[%s] success: %s getlink: %s", __func__, path, link);
|
||||
goto link_local;
|
||||
}
|
||||
|
||||
if (!strcmp(path, "/proc/mounts")) {
|
||||
- sprintf(link, "/proc/1/mounts");
|
||||
+ snprintf(link, MAX_PATH_LEN, "/proc/1/mounts");
|
||||
qtfs_info("[%s] success: %s getlink /proc/1/mounts", __func__, path);
|
||||
goto link_local;
|
||||
}
|
||||
@@ -222,7 +222,7 @@ const char *qtfs_proc_getlink(struct dentry *dentry,
|
||||
pid = is_local_process(path);
|
||||
if (pid > 0) {
|
||||
sscanf(path, "/proc/%s", tmp);
|
||||
- sprintf(link, "/local_proc/%s", tmp);
|
||||
+ snprintf(link, MAX_PATH_LEN, "/local_proc/%s", tmp);
|
||||
qtfs_info("[%s] success: %s getlink: %s", __func__, path, link);
|
||||
goto link_local;
|
||||
}
|
||||
@@ -274,7 +274,7 @@ int qtfs_proc_getattr(const struct path *path, struct kstat *stat, u32 req_mask,
|
||||
pid = is_local_process(cpath);
|
||||
if (pid > 0) {
|
||||
sscanf(cpath, "/proc/%s", tmp);
|
||||
- sprintf(local_path, "/local_proc/%s", tmp);
|
||||
+ snprintf(local_path, MAX_PATH_LEN, "/local_proc/%s", tmp);
|
||||
ret = kern_path(local_path, 0, &spath);
|
||||
if (ret) {
|
||||
qtfs_err("[%s]: kern_path(%s) failed: %d", __func__, local_path, ret);
|
||||
diff --git a/qtfs/qtfs/qtfs-mod.c b/qtfs/qtfs/qtfs-mod.c
|
||||
index 0b6cd65..d49e9a2 100644
|
||||
--- a/qtfs/qtfs/qtfs-mod.c
|
||||
+++ b/qtfs/qtfs/qtfs-mod.c
|
||||
@@ -23,6 +23,8 @@
|
||||
#include "syscall.h"
|
||||
#include "symbol_wrapper.h"
|
||||
|
||||
+#define MAX_RETRY 5
|
||||
+
|
||||
static struct file_system_type qtfs_fs_type = {
|
||||
.owner = THIS_MODULE,
|
||||
.name = QTFS_FSTYPE_NAME,
|
||||
@@ -86,7 +88,7 @@ retry:
|
||||
pvar->miss_proc = 0;
|
||||
}
|
||||
// miss message retry would result in block
|
||||
- if (retrytimes >= 5) {
|
||||
+ if (retrytimes >= MAX_RETRY) {
|
||||
qtfs_err("qtfs conn recv get mismatch seq_num too many times, stop retrying, signal:0x%lx", (unsigned long)current->pending.signal.sig[0]);
|
||||
return NULL;
|
||||
}
|
||||
@@ -98,7 +100,7 @@ retry:
|
||||
qtinfo_cntinc(QTINF_RESTART_SYS);
|
||||
qtinfo_recverrinc(req->type);
|
||||
}
|
||||
- if (retrytimes >= 5 && ret == -EINTR) {
|
||||
+ if (retrytimes >= MAX_RETRY && ret == -EINTR) {
|
||||
qtfs_err("qtfs conn recv get retry signal(%d) too many times, stop retrying, signal:0x%lx", ret, (unsigned long)current->pending.signal.sig[0]);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
diff --git a/qtfs/qtfs/sb.c b/qtfs/qtfs/sb.c
|
||||
index fb60261..a5bcc8e 100644
|
||||
--- a/qtfs/qtfs/sb.c
|
||||
+++ b/qtfs/qtfs/sb.c
|
||||
@@ -155,8 +155,8 @@ int qtfs_readdir(struct file *filp, struct dir_context *ctx)
|
||||
int count = 0;
|
||||
struct getdents_callback64 *buf = container_of(ctx, struct getdents_callback64, ctx);
|
||||
|
||||
- if (!pvar) {
|
||||
- qtfs_err("Failed to get qtfs sock var");
|
||||
+ if (!pvar || !buf) {
|
||||
+ qtfs_err("Failed to get qtfs sock var(%p) or gentdents(%p)", pvar, buf);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -168,7 +168,6 @@ int qtfs_readdir(struct file *filp, struct dir_context *ctx)
|
||||
req = pvar->conn_ops->get_conn_msg_buf(pvar, QTFS_SEND);
|
||||
rsp = pvar->conn_ops->get_conn_msg_buf(pvar, QTFS_RECV);
|
||||
QTFS_FULLNAME(req->path, filp->f_path.dentry, sizeof(req->path));
|
||||
- // req->count = sizeof(rsp->dirent);
|
||||
count = sizeof(rsp->dirent);
|
||||
if (buf && buf->count > 0 && buf->count < sizeof(rsp->dirent)) {
|
||||
qtfs_info("readdir use input buf size(%d), prev_reclen(%d)", buf->count, buf->prev_reclen);
|
||||
@@ -198,7 +197,6 @@ int qtfs_readdir(struct file *filp, struct dir_context *ctx)
|
||||
}
|
||||
dirent = (struct qtfs_dirent64 *)&rsp->dirent[idx];
|
||||
namelen = strlen(dirent->d_name);
|
||||
- // ret = dir_emit(ctx, dirent->d_name, namelen, dirent->d_ino, dirent->d_type);
|
||||
ret = ctx->actor(ctx, dirent->d_name, namelen, ctx->pos, dirent->d_ino, dirent->d_type);
|
||||
if (ret == -EINTR) {
|
||||
err = ret;
|
||||
@@ -210,7 +208,6 @@ int qtfs_readdir(struct file *filp, struct dir_context *ctx)
|
||||
(void *)dirent - (void *)rsp->dirent, dirent->d_name, ret, dirent->d_reclen, namelen, dirent->d_ino, dirent->d_type);
|
||||
}
|
||||
|
||||
- // ctx->pos = (rsp->d.over) ? -1 : rsp->d.pos;
|
||||
ctx->pos = rsp->d.pos;
|
||||
qtfs_info("qtfs readdir<%s> success ret:%d vldcnt:%d dircnt:%d over:%d pos:%lld.",
|
||||
req->path, rsp->d.ret, rsp->d.vldcnt, dircnt, rsp->d.over, ctx->pos);
|
||||
diff --git a/qtfs/qtfs_common/qtfs_check.c b/qtfs/qtfs_common/qtfs_check.c
|
||||
index 8daad39..e2a7ec1 100644
|
||||
--- a/qtfs/qtfs_common/qtfs_check.c
|
||||
+++ b/qtfs/qtfs_common/qtfs_check.c
|
||||
@@ -15,6 +15,26 @@
|
||||
#include "req.h"
|
||||
#include "qtfs_check.h"
|
||||
|
||||
+#define do_path_check(ops) \
|
||||
+( \
|
||||
+ { \
|
||||
+ struct qtreq_##ops *req = TOREQ; \
|
||||
+ if (check_string(req->path, sizeof(req->path))) \
|
||||
+ return QTFS_CHECK_ERR; \
|
||||
+ return QTFS_CHECK_OK; \
|
||||
+ } \
|
||||
+)
|
||||
+
|
||||
+#define do_fd_check(ops) \
|
||||
+( \
|
||||
+ { \
|
||||
+ struct qtreq_##ops *req = TOREQ; \
|
||||
+ if (check_fd(req->fd)) \
|
||||
+ return QTFS_CHECK_ERR; \
|
||||
+ return QTFS_CHECK_OK; \
|
||||
+ } \
|
||||
+)
|
||||
+
|
||||
/*
|
||||
检查原则:
|
||||
1. 基本数据类型,据实严格判断合法范围,有数组、指针操作的注意数组越界或指针飞踩;
|
||||
@@ -26,7 +46,7 @@
|
||||
// string类型基本防护,在max范围内最后一个字符必须是结束符,防止越界访问
|
||||
static inline bool check_string(char *str, size_t max)
|
||||
{
|
||||
- if (max == 0)
|
||||
+ if (str == NULL || max == 0)
|
||||
return false;
|
||||
if (str[max - 1] != '\0')
|
||||
return true;
|
||||
@@ -50,37 +70,24 @@ int req_check_none(void *in)
|
||||
|
||||
int req_check_mount(void *in)
|
||||
{
|
||||
- struct qtreq_mount *req = TOREQ;
|
||||
-
|
||||
- if (check_string(req->path, sizeof(req->path)))
|
||||
- return QTFS_CHECK_ERR;
|
||||
- return QTFS_CHECK_OK;
|
||||
+ do_path_check(mount);
|
||||
}
|
||||
|
||||
int req_check_open(void *in)
|
||||
{
|
||||
- struct qtreq_open *req = TOREQ;
|
||||
|
||||
// flags 和 mode如果错误syscall会报错,不会有安全风险
|
||||
- if (check_string(req->path, sizeof(req->path)))
|
||||
- return QTFS_CHECK_ERR;
|
||||
- return QTFS_CHECK_OK;
|
||||
+ do_path_check(open);
|
||||
}
|
||||
|
||||
int req_check_close(void *in)
|
||||
{
|
||||
- struct qtreq_close *req = TOREQ;
|
||||
- if (check_fd(req->fd))
|
||||
- return QTFS_CHECK_ERR;
|
||||
- return QTFS_CHECK_OK;
|
||||
+ do_fd_check(close);
|
||||
}
|
||||
|
||||
int req_check_readiter(void *in)
|
||||
{
|
||||
- struct qtreq_readiter *req = TOREQ;
|
||||
- if (check_fd(req->fd))
|
||||
- return QTFS_CHECK_ERR;
|
||||
- return QTFS_CHECK_OK;
|
||||
+ do_fd_check(readiter);
|
||||
}
|
||||
|
||||
int req_check_write(void *in)
|
||||
@@ -111,26 +118,17 @@ int req_check_readdir(void *in)
|
||||
|
||||
int req_check_mkdir(void *in)
|
||||
{
|
||||
- struct qtreq_mkdir *req = TOREQ;
|
||||
- if (check_string(req->path, sizeof(req->path)))
|
||||
- return QTFS_CHECK_ERR;
|
||||
- return QTFS_CHECK_OK;
|
||||
+ do_path_check(mkdir);
|
||||
}
|
||||
|
||||
int req_check_rmdir(void *in)
|
||||
{
|
||||
- struct qtreq_rmdir *req = TOREQ;
|
||||
- if (check_string(req->path, sizeof(req->path)))
|
||||
- return QTFS_CHECK_ERR;
|
||||
- return QTFS_CHECK_OK;
|
||||
+ do_path_check(rmdir);
|
||||
}
|
||||
|
||||
int req_check_getattr(void *in)
|
||||
{
|
||||
- struct qtreq_getattr *req = TOREQ;
|
||||
- if (check_string(req->path, sizeof(req->path)))
|
||||
- return QTFS_CHECK_ERR;
|
||||
- return QTFS_CHECK_OK;
|
||||
+ do_path_check(getattr);
|
||||
}
|
||||
|
||||
int req_check_setattr(void *in)
|
||||
@@ -143,26 +141,17 @@ int req_check_setattr(void *in)
|
||||
|
||||
int req_check_icreate(void *in)
|
||||
{
|
||||
- struct qtreq_icreate *req = TOREQ;
|
||||
- if (check_string(req->path, sizeof(req->path)))
|
||||
- return QTFS_CHECK_ERR;
|
||||
- return QTFS_CHECK_OK;
|
||||
+ do_path_check(icreate);
|
||||
}
|
||||
|
||||
int req_check_mknod(void *in)
|
||||
{
|
||||
- struct qtreq_mknod *req = TOREQ;
|
||||
- if (check_string(req->path, sizeof(req->path)))
|
||||
- return QTFS_CHECK_ERR;
|
||||
- return QTFS_CHECK_OK;
|
||||
+ do_path_check(mknod);
|
||||
}
|
||||
|
||||
int req_check_unlink(void *in)
|
||||
{
|
||||
- struct qtreq_unlink *req = TOREQ;
|
||||
- if (check_string(req->path, sizeof(req->path)))
|
||||
- return QTFS_CHECK_ERR;
|
||||
- return QTFS_CHECK_OK;
|
||||
+ do_path_check(unlink);
|
||||
}
|
||||
|
||||
int req_check_symlink(void *in)
|
||||
@@ -195,10 +184,7 @@ int req_check_link(void *in)
|
||||
|
||||
int req_check_getlink(void *in)
|
||||
{
|
||||
- struct qtreq_getlink *req = TOREQ;
|
||||
- if (check_string(req->path, sizeof(req->path)))
|
||||
- return QTFS_CHECK_ERR;
|
||||
- return QTFS_CHECK_OK;
|
||||
+ do_path_check(getlink);
|
||||
}
|
||||
|
||||
int req_check_rename(void *in)
|
||||
@@ -216,10 +202,7 @@ int req_check_rename(void *in)
|
||||
}
|
||||
int req_check_xattrlist(void *in)
|
||||
{
|
||||
- struct qtreq_xattrlist *req = TOREQ;
|
||||
- if (check_string(req->path, sizeof(req->path)))
|
||||
- return QTFS_CHECK_ERR;
|
||||
- return QTFS_CHECK_OK;
|
||||
+ do_path_check(xattrlist);
|
||||
}
|
||||
|
||||
int req_check_xattrget(void *in)
|
||||
@@ -277,18 +260,12 @@ int req_check_sysumount(void *in)
|
||||
|
||||
int req_check_fifopoll(void *in)
|
||||
{
|
||||
- struct qtreq_poll *req = TOREQ;
|
||||
- if (check_fd(req->fd))
|
||||
- return QTFS_CHECK_ERR;
|
||||
- return QTFS_CHECK_OK;
|
||||
+ do_fd_check(poll);
|
||||
}
|
||||
|
||||
int req_check_statfs(void *in)
|
||||
{
|
||||
- struct qtreq_statfs *req = TOREQ;
|
||||
- if (check_string(req->path, sizeof(req->path)))
|
||||
- return QTFS_CHECK_ERR;
|
||||
- return QTFS_CHECK_OK;
|
||||
+ do_path_check(statfs);
|
||||
}
|
||||
|
||||
int req_check_ioctl(void *in)
|
||||
@@ -303,18 +280,12 @@ int req_check_ioctl(void *in)
|
||||
|
||||
int req_check_epoll_ctl(void *in)
|
||||
{
|
||||
- struct qtreq_epollctl *req = TOREQ;
|
||||
- if (check_fd(req->fd))
|
||||
- return QTFS_CHECK_ERR;
|
||||
- return QTFS_CHECK_OK;
|
||||
+ do_fd_check(epollctl);
|
||||
}
|
||||
|
||||
int req_check_llseek(void *in)
|
||||
{
|
||||
- struct qtreq_llseek *req = TOREQ;
|
||||
- if (check_fd(req->fd))
|
||||
- return QTFS_CHECK_ERR;
|
||||
- return QTFS_CHECK_OK;
|
||||
+ do_fd_check(llseek);
|
||||
}
|
||||
|
||||
int req_check_sc_kill(void *in)
|
||||
diff --git a/qtfs/rexec/rexec.c b/qtfs/rexec/rexec.c
|
||||
index e24c0ad..f905cfa 100644
|
||||
--- a/qtfs/rexec/rexec.c
|
||||
+++ b/qtfs/rexec/rexec.c
|
||||
@@ -150,7 +150,7 @@ static int rexec_conn_msg(struct rexec_client_event *evt)
|
||||
rexec_err("Rexec pidmap msg > 1 error.");
|
||||
return REXEC_EVENT_OK;
|
||||
}
|
||||
- sprintf(path, "%s/%d", REXEC_PIDMAP_PATH, mypid);
|
||||
+ snprintf(path, REXEC_PIDMAP_PATH_LEN, "%s/%d", REXEC_PIDMAP_PATH, mypid);
|
||||
fd = open(path, O_CREAT|O_WRONLY, 0600);
|
||||
if (fd < 0) {
|
||||
rexec_err("Rexec create pidmap:%d-%d failed, path:%s open failed:%d",
|
||||
@@ -170,7 +170,7 @@ static int rexec_conn_msg(struct rexec_client_event *evt)
|
||||
rexec_err("Rexec pidmap file:%s lseek 0 failed errno:%d rexec exit", path, err);
|
||||
return REXEC_EVENT_EXIT;
|
||||
}
|
||||
- sprintf(buf, "%d", peerpid);
|
||||
+ snprintf(buf, REXEC_PID_LEN, "%d", peerpid);
|
||||
if ((err = write(fd, buf, strlen(buf))) <= 0) {
|
||||
rexec_err("Rexec pidmap file:%s write pid:%d failed errno:%d rexec exit.", path, peerpid, err);
|
||||
return REXEC_EVENT_EXIT;
|
||||
@@ -316,7 +316,7 @@ static int rexec_run(int efd, int connfd, char *argv[])
|
||||
// clear pidmap file
|
||||
if (pidfd > 0) {
|
||||
char path[32] = {0};
|
||||
- sprintf(path, "%s/%d", REXEC_PIDMAP_PATH, getpid());
|
||||
+ snprintf(path, 32, "%s/%d", REXEC_PIDMAP_PATH, getpid());
|
||||
close(pidfd);
|
||||
remove(path);
|
||||
}
|
||||
@@ -357,7 +357,7 @@ void rexec_clear_pids()
|
||||
continue;
|
||||
|
||||
memset(path, 0, sizeof(path));
|
||||
- sprintf(path, "%s/%s", REXEC_PIDMAP_PATH, entry->d_name);
|
||||
+ snprintf(path, REXEC_PIDMAP_PATH_LEN, "%s/%s", REXEC_PIDMAP_PATH, entry->d_name);
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd <= 0) {
|
||||
rexec_err("open pid file:%s failed", path);
|
||||
@@ -401,7 +401,7 @@ static int rexec_get_fdinfo(struct dirent *fdentry, struct rexec_fdinfo *fdinfo)
|
||||
return -1;
|
||||
if (!rexec_is_reg_file(fd))
|
||||
return -1;
|
||||
- sprintf(path, "/proc/self/fd/%s", fdentry->d_name);
|
||||
+ snprintf(path, 32, "/proc/self/fd/%s", fdentry->d_name);
|
||||
ret = readlink(path, fdinfo->path, REXEC_PATH_MAX);
|
||||
if (ret < 0) {
|
||||
rexec_err("Get fd:%d link failed.", fd);
|
||||
@@ -624,6 +624,7 @@ static int rexec_send_binary_msg(int efd, int argc, char *argv[], int arglen, ch
|
||||
pmsg->argc = argc - 1; // for remote binary's argc is argc-1
|
||||
// pmsg->msg is like: "binary"\0"argv[1]"\0"argv[2]"\0"..."
|
||||
pmsg->msglen = rexec_msg_fill_argv(pmsg->argc, &argv[1], bufmsg);
|
||||
+ // bufmsg len has been calculated to make sure it will not overflow.
|
||||
strcpy(&bufmsg[pmsg->msglen], fds_json);
|
||||
pmsg->msglen += strlen(fds_json);
|
||||
free(fds_json);
|
||||
--
|
||||
2.37.1 (Apple Git-137.1)
|
||||
|
||||
27
0007-do-not-output-addr-in-kernel.patch
Normal file
27
0007-do-not-output-addr-in-kernel.patch
Normal file
@ -0,0 +1,27 @@
|
||||
From 8b34c899b08ee078e988c900b90d9b925f5535aa Mon Sep 17 00:00:00 2001
|
||||
From: liqiang <liqiang64@huawei.com>
|
||||
Date: Mon, 11 Dec 2023 19:48:50 +0800
|
||||
Subject: [PATCH 07/12] do not output addr in kernel
|
||||
|
||||
Signed-off-by: liqiang <liqiang64@huawei.com>
|
||||
---
|
||||
qtfs/qtfs/sb.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/qtfs/qtfs/sb.c b/qtfs/qtfs/sb.c
|
||||
index a5bcc8e..0babad1 100644
|
||||
--- a/qtfs/qtfs/sb.c
|
||||
+++ b/qtfs/qtfs/sb.c
|
||||
@@ -156,7 +156,8 @@ int qtfs_readdir(struct file *filp, struct dir_context *ctx)
|
||||
struct getdents_callback64 *buf = container_of(ctx, struct getdents_callback64, ctx);
|
||||
|
||||
if (!pvar || !buf) {
|
||||
- qtfs_err("Failed to get qtfs sock var(%p) or gentdents(%p)", pvar, buf);
|
||||
+ qtfs_err("Failed to get qtfs sock var(%s) or gentdents(%s)",
|
||||
+ (!pvar) ? "INVALID" : "VALID", (!buf) ? "INVALID" : "VALID");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
--
|
||||
2.37.1 (Apple Git-137.1)
|
||||
|
||||
37
0008-fix-coredump-run-binary-after-copy-in-client.patch
Normal file
37
0008-fix-coredump-run-binary-after-copy-in-client.patch
Normal file
@ -0,0 +1,37 @@
|
||||
From d5de8eaa514e2a29cd85f0bb4eae7850bfe59c88 Mon Sep 17 00:00:00 2001
|
||||
From: liqiang <liqiang64@huawei.com>
|
||||
Date: Mon, 11 Dec 2023 21:46:43 +0800
|
||||
Subject: [PATCH 08/12] fix coredump run binary after copy in client
|
||||
|
||||
Signed-off-by: liqiang <liqiang64@huawei.com>
|
||||
---
|
||||
qtfs/qtfs/sb.c | 6 ++++++
|
||||
1 file changed, 6 insertions(+)
|
||||
|
||||
diff --git a/qtfs/qtfs/sb.c b/qtfs/qtfs/sb.c
|
||||
index fb60261..68ad696 100644
|
||||
--- a/qtfs/qtfs/sb.c
|
||||
+++ b/qtfs/qtfs/sb.c
|
||||
@@ -482,6 +482,11 @@ ssize_t qtfs_writeiter(struct kiocb *kio, struct iov_iter *iov)
|
||||
wake_up_interruptible_poll(&priv->readq, EPOLLIN);
|
||||
qtfs_err("writeiter file:%s len:%lu wakup poll.", filp->f_path.dentry->d_iname, len - leftlen);
|
||||
}
|
||||
+ if (inode->i_size < kio->ki_pos) {
|
||||
+ qtfs_info("file:%s write pos reached:%lld and inode size is:%lld just update.",
|
||||
+ filp->f_path.dentry->d_iname, kio->ki_pos, inode->i_size);
|
||||
+ inode->i_size = kio->ki_pos;
|
||||
+ }
|
||||
} while (0);
|
||||
qtfs_info("qtfs write %s over, leftlen:%lu.", filp->f_path.dentry->d_iname, leftlen);
|
||||
qtfs_conn_put_param(pvar);
|
||||
@@ -1331,6 +1336,7 @@ int qtfs_getattr(const struct path *path, struct kstat *stat, u32 req_mask, unsi
|
||||
qtfs_conn_put_param(pvar);
|
||||
return ret;
|
||||
}
|
||||
+ inode->i_size = rsp->stat.size;
|
||||
*stat = rsp->stat;
|
||||
if (path->dentry && path->dentry->d_inode && S_ISDIR(path->dentry->d_inode->i_mode))
|
||||
path->dentry->d_time = jiffies;
|
||||
--
|
||||
2.37.1 (Apple Git-137.1)
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
From 4352197e314767a644c46b43a08fc02b67d9dd63 Mon Sep 17 00:00:00 2001
|
||||
From: liqiang <liqiang64@huawei.com>
|
||||
Date: Tue, 12 Dec 2023 11:53:18 +0800
|
||||
Subject: [PATCH 09/12] get mount pointer error when remote mount path is same
|
||||
as local path
|
||||
|
||||
Signed-off-by: liqiang <liqiang64@huawei.com>
|
||||
---
|
||||
qtfs/qtfs/sb.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/qtfs/qtfs/sb.c b/qtfs/qtfs/sb.c
|
||||
index fb60261..68ed8d8 100644
|
||||
--- a/qtfs/qtfs/sb.c
|
||||
+++ b/qtfs/qtfs/sb.c
|
||||
@@ -107,7 +107,7 @@ static inline char *qtfs_mountpoint_path_init(struct dentry *dentry, struct path
|
||||
if (IS_ERR_OR_NULL(ret)) {
|
||||
qtfs_err("d_absolute_path failed:%ld", QTFS_PTR_ERR(ret));
|
||||
} else {
|
||||
- if (strcmp(mnt_file, "/")) {
|
||||
+ if (strcmp(ret, mnt_file) != 0 && strcmp(mnt_file, "/")) {
|
||||
mnt_point = strstr(ret, mnt_file);
|
||||
qtfs_info("mnt point:%s", mnt_point);
|
||||
if (mnt_point) {
|
||||
--
|
||||
2.37.1 (Apple Git-137.1)
|
||||
|
||||
114
0010-bugfix-unix-socket-connection-refuse-after-chmod-mod.patch
Normal file
114
0010-bugfix-unix-socket-connection-refuse-after-chmod-mod.patch
Normal file
@ -0,0 +1,114 @@
|
||||
From 0626a247f1b30b71f74f0eb7cd0890c4c469e6a6 Mon Sep 17 00:00:00 2001
|
||||
From: liqiang <liqiang64@huawei.com>
|
||||
Date: Wed, 13 Dec 2023 14:48:11 +0800
|
||||
Subject: [PATCH 10/12] bugfix: unix socket connection refuse after chmod
|
||||
modify socket file
|
||||
|
||||
Signed-off-by: liqiang <liqiang64@huawei.com>
|
||||
---
|
||||
qtfs/qtfs/sb.c | 38 ++++++++++++++++++++++++++++++++------
|
||||
1 file changed, 32 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/qtfs/qtfs/sb.c b/qtfs/qtfs/sb.c
|
||||
index fefb6c1..4ecbf50 100644
|
||||
--- a/qtfs/qtfs/sb.c
|
||||
+++ b/qtfs/qtfs/sb.c
|
||||
@@ -35,6 +35,17 @@ static struct inode_operations qtfs_inode_ops;
|
||||
static struct inode_operations qtfs_symlink_inode_ops;
|
||||
struct inode *qtfs_iget(struct super_block *sb, struct inode_info *ii);
|
||||
extern ssize_t qtfs_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size);
|
||||
+static void qtfs_copy_kstat_inode(struct inode *inode, struct kstat *stat)
|
||||
+{
|
||||
+ inode->i_mode = stat->mode;
|
||||
+ inode->i_size = stat->size;
|
||||
+ inode->i_uid = stat->uid;
|
||||
+ inode->i_gid = stat->gid;
|
||||
+ inode->i_atime = stat->atime;
|
||||
+ inode->i_mtime = stat->mtime;
|
||||
+ inode->i_ctime = stat->ctime;
|
||||
+}
|
||||
+
|
||||
int qtfs_statfs(struct dentry *dentry, struct kstatfs *buf)
|
||||
{
|
||||
struct qtfs_conn_var_s *pvar = qtfs_conn_get_param();
|
||||
@@ -1340,16 +1351,28 @@ int qtfs_getattr(const struct path *path, struct kstat *stat, u32 req_mask, unsi
|
||||
path->dentry->d_time = jiffies;
|
||||
qtfs_debug("qtfs getattr success:<%s> blksiz:%u size:%lld mode:%o ino:%llu pathino:%lu. %s\n", req->path, rsp->stat.blksize,
|
||||
rsp->stat.size, rsp->stat.mode, rsp->stat.ino, inode->i_ino, rsp->stat.ino != inode->i_ino ? "delete current inode" : "");
|
||||
- if (inode->i_ino != rsp->stat.ino || inode->i_mode != rsp->stat.mode) {
|
||||
+ if (inode->i_ino != rsp->stat.ino) {
|
||||
if (inode->i_nlink > 0){
|
||||
drop_nlink(inode);
|
||||
}
|
||||
d_invalidate(path->dentry);
|
||||
}
|
||||
+ qtfs_copy_kstat_inode(inode, &rsp->stat);
|
||||
qtfs_conn_put_param(pvar);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static void qtfs_copy_iattr_inode(struct inode *inode, struct iattr *attr)
|
||||
+{
|
||||
+ inode->i_mode = attr->ia_mode;
|
||||
+ inode->i_uid = attr->ia_uid;
|
||||
+ inode->i_gid = attr->ia_gid;
|
||||
+ inode->i_size = attr->ia_size;
|
||||
+ inode->i_atime = attr->ia_atime;
|
||||
+ inode->i_mtime = attr->ia_mtime;
|
||||
+ inode->i_ctime = attr->ia_ctime;
|
||||
+}
|
||||
+
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0))
|
||||
int qtfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry, struct iattr *attr)
|
||||
#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0))
|
||||
@@ -1385,6 +1408,8 @@ int qtfs_setattr(struct dentry *dentry, struct iattr *attr)
|
||||
qtfs_conn_put_param(pvar);
|
||||
return ret;
|
||||
}
|
||||
+ // 成功后更新local的inode信息
|
||||
+ qtfs_copy_iattr_inode(dentry->d_inode, &req->attr);
|
||||
qtfs_info("qtfs setattr <%s> success.\n", req->path);
|
||||
qtfs_conn_put_param(pvar);
|
||||
return 0;
|
||||
@@ -1558,7 +1583,7 @@ int qtfs_dentry_revalidate(struct dentry *dentry, unsigned int flags)
|
||||
pvar = qtfs_conn_get_param();
|
||||
if (!pvar) {
|
||||
qtfs_err("Failed to get qtfs sock var\n");
|
||||
- return 0;
|
||||
+ return 1;
|
||||
}
|
||||
|
||||
req = pvar->conn_ops->get_conn_msg_buf(pvar, QTFS_SEND);
|
||||
@@ -1569,24 +1594,25 @@ int qtfs_dentry_revalidate(struct dentry *dentry, unsigned int flags)
|
||||
rsp = qtfs_remote_run(pvar, QTFS_REQ_GETATTR, QTFS_SEND_SIZE(struct qtreq_getattr, req->path));
|
||||
if (IS_ERR_OR_NULL(rsp)) {
|
||||
qtfs_conn_put_param(pvar);
|
||||
- return 0;
|
||||
+ return 1;
|
||||
}
|
||||
if (rsp->ret) {
|
||||
qtfs_conn_put_param(pvar);
|
||||
- return 0;
|
||||
+ return 1;
|
||||
}
|
||||
|
||||
inode = dentry->d_inode;
|
||||
if (inode == NULL) {
|
||||
qtfs_conn_put_param(pvar);
|
||||
- return 0;
|
||||
+ return 1;
|
||||
}
|
||||
- if (inode->i_ino != rsp->stat.ino || inode->i_mode != rsp->stat.mode) {
|
||||
+ if (inode->i_ino != rsp->stat.ino) {
|
||||
if (inode->i_nlink > 0)
|
||||
drop_nlink(inode);
|
||||
qtfs_conn_put_param(pvar);
|
||||
return 0;
|
||||
}
|
||||
+ qtfs_copy_kstat_inode(inode, &rsp->stat);
|
||||
qtfs_conn_put_param(pvar);
|
||||
dentry->d_time = jiffies;
|
||||
}
|
||||
--
|
||||
2.37.1 (Apple Git-137.1)
|
||||
|
||||
36
0011-filter-af-unix-before-whitelist-check.patch
Normal file
36
0011-filter-af-unix-before-whitelist-check.patch
Normal file
@ -0,0 +1,36 @@
|
||||
From 039a2c19c0b854cebfc63666b55c9f83f6cd9510 Mon Sep 17 00:00:00 2001
|
||||
From: liqiang <liqiang64@huawei.com>
|
||||
Date: Wed, 13 Dec 2023 15:23:35 +0800
|
||||
Subject: [PATCH 11/12] filter af unix before whitelist check
|
||||
|
||||
Signed-off-by: liqiang <liqiang64@huawei.com>
|
||||
---
|
||||
qtfs/qtfs_common/conn.c | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/qtfs/qtfs_common/conn.c b/qtfs/qtfs_common/conn.c
|
||||
index 4f2f048..1974c06 100644
|
||||
--- a/qtfs/qtfs_common/conn.c
|
||||
+++ b/qtfs/qtfs_common/conn.c
|
||||
@@ -165,15 +165,15 @@ int qtfs_uds_remote_connect_user(int fd, struct sockaddr __user *addr, int len)
|
||||
return sysret;
|
||||
try_conn_remote:
|
||||
// len is passed from syscall input args directly. it's trustworthy
|
||||
- if (copy_from_user(&addr_un, addr, len)) {
|
||||
+ if (len > sizeof(struct sockaddr_un) || copy_from_user(&addr_un, addr, len)) {
|
||||
qtfs_err("copy sockaddr failed.");
|
||||
return sysret;
|
||||
}
|
||||
+ if (addr_un.sun_family != AF_UNIX)
|
||||
+ return sysret;
|
||||
// don't try remote uds connect if sunpath not in whitelist
|
||||
if (qtfs_uds_remote_whitelist(addr_un.sun_path) != 0)
|
||||
return sysret;
|
||||
- if (addr_un.sun_family != AF_UNIX)
|
||||
- return sysret;
|
||||
un_headlen = sizeof(struct sockaddr_un) - sizeof(addr_un.sun_path);
|
||||
if (len < un_headlen || strlen(addr_un.sun_path) >= (sizeof(addr_un.sun_path) - strlen(QTFS_UDS_PROXY_SUFFIX))) {
|
||||
qtfs_err("failed to try connect remote uds server, sun path:%s too long to add suffix:%s",
|
||||
--
|
||||
2.37.1 (Apple Git-137.1)
|
||||
|
||||
49
0012-not-updata-iattr-invalid-data-to-inode.patch
Normal file
49
0012-not-updata-iattr-invalid-data-to-inode.patch
Normal file
@ -0,0 +1,49 @@
|
||||
From 091ae21631ba7c93ba4673cdd69d199687851864 Mon Sep 17 00:00:00 2001
|
||||
From: liqiang <liqiang64@huawei.com>
|
||||
Date: Wed, 13 Dec 2023 16:58:22 +0800
|
||||
Subject: [PATCH 12/12] not updata iattr invalid data to inode
|
||||
|
||||
Signed-off-by: liqiang <liqiang64@huawei.com>
|
||||
---
|
||||
qtfs/CMakeLists.txt | 2 +-
|
||||
qtfs/qtfs/sb.c | 11 ++++-------
|
||||
2 files changed, 5 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/qtfs/CMakeLists.txt b/qtfs/CMakeLists.txt
|
||||
index 4d0e9e3..5f97eef 100644
|
||||
--- a/qtfs/CMakeLists.txt
|
||||
+++ b/qtfs/CMakeLists.txt
|
||||
@@ -24,7 +24,7 @@ target_link_libraries(engine PRIVATE glib-2.0 pthread)
|
||||
target_compile_options(engine PRIVATE "-DQTFS_SERVER")
|
||||
|
||||
if (DEFINED UDS_TEST_MODE OR DEFINED QTFS_TEST_MODE)
|
||||
- target_compile_options(engine PRIVATE "-DUDS_TEST_MODE")
|
||||
+ target_compile_options(engine PRIVATE "-DUDS_TEST_MODE" "-DQTFS_TEST_MODE")
|
||||
target_compile_options(udsproxyd PRIVATE "-DUDS_TEST_MODE")
|
||||
message(WARNING "Important risk warning: the test mode is turned on, and qtfs will expose the network port, \
|
||||
which will bring security risks and is only for testing! If you do not understand the risks,\
|
||||
diff --git a/qtfs/qtfs/sb.c b/qtfs/qtfs/sb.c
|
||||
index 4ecbf50..71aba49 100644
|
||||
--- a/qtfs/qtfs/sb.c
|
||||
+++ b/qtfs/qtfs/sb.c
|
||||
@@ -1364,13 +1364,10 @@ int qtfs_getattr(const struct path *path, struct kstat *stat, u32 req_mask, unsi
|
||||
|
||||
static void qtfs_copy_iattr_inode(struct inode *inode, struct iattr *attr)
|
||||
{
|
||||
- inode->i_mode = attr->ia_mode;
|
||||
- inode->i_uid = attr->ia_uid;
|
||||
- inode->i_gid = attr->ia_gid;
|
||||
- inode->i_size = attr->ia_size;
|
||||
- inode->i_atime = attr->ia_atime;
|
||||
- inode->i_mtime = attr->ia_mtime;
|
||||
- inode->i_ctime = attr->ia_ctime;
|
||||
+ inode->i_mode = (attr->ia_valid & ATTR_MODE) ? attr->ia_mode : inode->i_mode;
|
||||
+ inode->i_uid = (attr->ia_valid & ATTR_UID) ? attr->ia_uid : inode->i_uid;
|
||||
+ inode->i_gid = (attr->ia_valid & ATTR_GID) ? attr->ia_gid : inode->i_gid;
|
||||
+ inode->i_size = (attr->ia_valid & ATTR_SIZE) ? attr->ia_size : inode->i_size;
|
||||
}
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0))
|
||||
--
|
||||
2.37.1 (Apple Git-137.1)
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
Name: dpu-utilities
|
||||
Summary: openEuler dpu utilities
|
||||
Version: 1.6
|
||||
Release: 2
|
||||
Release: 3
|
||||
License: GPL-2.0
|
||||
Source: https://gitee.com/openeuler/dpu-utilities/repository/archive/v%{version}.tar.gz
|
||||
ExclusiveOS: linux
|
||||
@ -16,6 +16,15 @@ BuildRequires: kernel-devel >= 5.10, gcc, make, json-c-devel, glib2-devel
|
||||
Patch1: 0001-fix-suspend-in-fifo-the-reason-is-SIGURG-recieved-in.patch
|
||||
Patch2: 0002-fix-virsh-console-problem.patch
|
||||
Patch3: 0003-delete-write-path-buf-to-log-info.patch
|
||||
Patch4: 0004-fix-rexec-exit-code-bug-and-fix-some-warning.patch
|
||||
Patch5: 0005-add-cmake-to-adapt-server-fifo.patch
|
||||
Patch6: 0006-code-style-problem-fix.patch
|
||||
Patch7: 0007-do-not-output-addr-in-kernel.patch
|
||||
Patch8: 0008-fix-coredump-run-binary-after-copy-in-client.patch
|
||||
Patch9: 0009-get-mount-pointer-error-when-remote-mount-path-is-sa.patch
|
||||
Patch10: 0010-bugfix-unix-socket-connection-refuse-after-chmod-mod.patch
|
||||
Patch11: 0011-filter-af-unix-before-whitelist-check.patch
|
||||
Patch12: 0012-not-updata-iattr-invalid-data-to-inode.patch
|
||||
|
||||
%description
|
||||
This package contains the software utilities on dpu.
|
||||
@ -143,6 +152,9 @@ sed -i '/# product cut_conf/a\dpuos kiwi/minios/cfg_dpuos yes' /opt/imageT
|
||||
sed -i '/<repository_rule>/a\dpuos 1 rpm-dir euler_base' /opt/imageTailor/repos/RepositoryRule.conf
|
||||
|
||||
%changelog
|
||||
* Wed Dec 13 2023 liqiang <liqiang64@huawei.com> 1.6-3
|
||||
- Update some bugfix
|
||||
|
||||
* Sat Dec 9 2023 liqiang <liqiang64@huawei.com> 1.6-2
|
||||
- fix some problem of fifo, resolve problem in libvirt
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user