From 7f0db330a3fd275ef2f3b367e3fece7fee3ca83c Mon Sep 17 00:00:00 2001 From: Deng Guangxing Date: Tue, 18 Oct 2022 20:58:25 +0800 Subject: [PATCH] fix qtfs chmod potentially error Signed-off-by: Deng Guangxing --- qtfs/qtfs_server/fsops.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/qtfs/qtfs_server/fsops.c b/qtfs/qtfs_server/fsops.c index a06df78..1e48777 100644 --- a/qtfs/qtfs_server/fsops.c +++ b/qtfs/qtfs_server/fsops.c @@ -521,6 +521,25 @@ static int handle_setattr(struct qtserver_arg *arg) return sizeof(struct qtrsp_setattr); } inode = path.dentry->d_inode; + if (req->attr.ia_valid & (ATTR_KILL_SUID | ATTR_KILL_SGID)) { + req->attr.ia_valid &= ~(ATTR_KILL_SUID | ATTR_KILL_SGID | + ATTR_MODE); + req->attr.ia_mode = inode->i_mode; + if (inode->i_mode & S_ISUID) { + req->attr.ia_valid |= ATTR_MODE; + req->attr.ia_mode &= ~S_ISUID; + } + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) { + req->attr.ia_valid |= ATTR_MODE; + req->attr.ia_mode &= ~S_ISGID; + } + } + if (!req->attr.ia_valid) { + rsp->ret = QTFS_OK; + path_put(&path); + return sizeof(struct qtrsp_setattr); + } + inode_lock(inode); rsp->errno = notify_change(path.dentry, &req->attr, NULL); if (rsp->errno < 0) { -- Gitee