From nobody Thu Nov 13 20:43:59 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1582782722; cv=none; d=zohomail.com; s=zohoarc; b=inI81zzsndwxmC6DJAN5nLbrSVWAwvWPAHO+2npR2GlfzKa7J0A0vay6Mu0WMQmA2eYRk9HuhoAgHABzmJ/NbzvIflviSvu5qitJWniN8lQhugTfZflYdjVEKcBvTrlHY78rIXyOlaKZj0Wc3xV0il8BEX9FLXANyUwbid8b0/0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582782722; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+F8xEGMLBDqWq3s3IXEYPAB3R5DbOgyKAXHtxeDZREM=; b=Z/jwNGsQQls1OKBsyync/2ADB7EQNAEnLm/dA+ba6pdWzcy48eoxyzRB6m/4ZhyINr6gK/NIMAW6WLKaWpE90id2FXwa+C6TKrevCCBNqPIY6nWW0Z1LOMyQX39fL8C2T+4SU4VzOIxTbgzV79lcPoHEb33eURyjO5NUFIhBEts= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1582782722532386.9353442690815; Wed, 26 Feb 2020 21:52:02 -0800 (PST) Received: from localhost ([::1]:54154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7C5Z-0000G4-9P for importer@patchew.org; Thu, 27 Feb 2020 00:52:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40527) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7C4K-0007Sc-SN for qemu-devel@nongnu.org; Thu, 27 Feb 2020 00:50:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7C4J-0000uL-PL for qemu-devel@nongnu.org; Thu, 27 Feb 2020 00:50:44 -0500 Received: from mgwkm03.jp.fujitsu.com ([202.219.69.170]:32725) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j7C4J-0000nu-32 for qemu-devel@nongnu.org; Thu, 27 Feb 2020 00:50:43 -0500 Received: from kw-mxoi1.gw.nic.fujitsu.com (unknown [192.168.231.131]) by mgwkm03.jp.fujitsu.com with smtp id 6d59_3f25_b7d26c65_e4e8_44c3_946d_499c04aabeb1; Thu, 27 Feb 2020 14:50:32 +0900 Received: from g01jpfmpwyt01.exch.g01.fujitsu.local (g01jpfmpwyt01.exch.g01.fujitsu.local [10.128.193.38]) by kw-mxoi1.gw.nic.fujitsu.com (Postfix) with ESMTP id C98D3AC009A for ; Thu, 27 Feb 2020 14:50:31 +0900 (JST) Received: from g01jpexchyt35.g01.fujitsu.local (unknown [10.128.193.4]) by g01jpfmpwyt01.exch.g01.fujitsu.local (Postfix) with ESMTP id CC59E6D6375; Thu, 27 Feb 2020 14:50:30 +0900 (JST) Received: from luna3.soft.fujitsu.com (10.124.196.199) by g01jpexchyt35.g01.fujitsu.local (10.128.193.50) with Microsoft SMTP Server id 14.3.439.0; Thu, 27 Feb 2020 14:50:31 +0900 From: Misono Tomohiro To: Subject: [PATCH v4 1/2] virtiofsd: passthrough_ll: cleanup getxattr/listxattr Date: Thu, 27 Feb 2020 14:59:26 +0900 Message-ID: <20200227055927.24566-2-misono.tomohiro@jp.fujitsu.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200227055927.24566-1-misono.tomohiro@jp.fujitsu.com> References: <20200227055927.24566-1-misono.tomohiro@jp.fujitsu.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SecurityPolicyCheck-GC: OK by FENCE-Mail X-TM-AS-GCONF: 00 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 202.219.69.170 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, vgoyal@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" This is a cleanup patch to simplify the following xattr fix and there is no functional changes. - Move memory allocation to head of the function - Unify fgetxattr/flistxattr call for both size =3D=3D 0 and size !=3D 0 case - Remove redundant lo_inode_put call in error path (Note: second call is ignored now since @inode is already NULL) Signed-off-by: Misono Tomohiro Acked-by: Vivek Goyal Reviewed-by: Dr. David Alan Gilbert --- tools/virtiofsd/passthrough_ll.c | 54 +++++++++++++------------------- 1 file changed, 22 insertions(+), 32 deletions(-) diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough= _ll.c index 9772823066..7b94300ae0 100644 --- a/tools/virtiofsd/passthrough_ll.c +++ b/tools/virtiofsd/passthrough_ll.c @@ -2384,34 +2384,30 @@ static void lo_getxattr(fuse_req_t req, fuse_ino_t = ino, const char *name, goto out; } =20 + if (size) { + value =3D malloc(size); + if (!value) { + goto out_err; + } + } + sprintf(procname, "%i", inode->fd); fd =3D openat(lo->proc_self_fd, procname, O_RDONLY); if (fd < 0) { goto out_err; } =20 + ret =3D fgetxattr(fd, name, value, size); + if (ret =3D=3D -1) { + goto out_err; + } if (size) { - value =3D malloc(size); - if (!value) { - goto out_err; - } - - ret =3D fgetxattr(fd, name, value, size); - if (ret =3D=3D -1) { - goto out_err; - } saverr =3D 0; if (ret =3D=3D 0) { goto out; } - fuse_reply_buf(req, value, ret); } else { - ret =3D fgetxattr(fd, name, NULL, 0); - if (ret =3D=3D -1) { - goto out_err; - } - fuse_reply_xattr(req, ret); } out_free: @@ -2427,7 +2423,6 @@ out_free: out_err: saverr =3D errno; out: - lo_inode_put(lo, &inode); fuse_reply_err(req, saverr); goto out_free; } @@ -2462,34 +2457,30 @@ static void lo_listxattr(fuse_req_t req, fuse_ino_t= ino, size_t size) goto out; } =20 + if (size) { + value =3D malloc(size); + if (!value) { + goto out_err; + } + } + sprintf(procname, "%i", inode->fd); fd =3D openat(lo->proc_self_fd, procname, O_RDONLY); if (fd < 0) { goto out_err; } =20 + ret =3D flistxattr(fd, value, size); + if (ret =3D=3D -1) { + goto out_err; + } if (size) { - value =3D malloc(size); - if (!value) { - goto out_err; - } - - ret =3D flistxattr(fd, value, size); - if (ret =3D=3D -1) { - goto out_err; - } saverr =3D 0; if (ret =3D=3D 0) { goto out; } - fuse_reply_buf(req, value, ret); } else { - ret =3D flistxattr(fd, NULL, 0); - if (ret =3D=3D -1) { - goto out_err; - } - fuse_reply_xattr(req, ret); } out_free: @@ -2505,7 +2496,6 @@ out_free: out_err: saverr =3D errno; out: - lo_inode_put(lo, &inode); fuse_reply_err(req, saverr); goto out_free; } --=20 2.21.1 From nobody Thu Nov 13 20:43:59 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1582782724; cv=none; d=zohomail.com; s=zohoarc; b=bVu1xp7UzaCNUk6rxVJH54r5dG09HglFhLXwO7MVCiLc8CTY5cxVg+ON8uRtoGRjiRqijLmv3TKEAyJj8nOsQK8Rb9U08hStsBo5EeXn0qXPFSaWZV+/9viF1MkJLlbunOyGemN63YgCKpcA+raLyokAOd3nByWk6wSxzRj92bA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582782724; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rcs1oMmuSt+d76AUmnsWBbpZSyH5Qr5jlHzcrXVyWMA=; b=D7QvMkoN7fmAXSXid3aT5/pAMPjBMVGelY5uIv/ymsng7iRXzEZqW7tw//oKzPk3ZCBbVkkB0unMpzYAcrW03Q2s0poJVdCS7FM0IfzyuoD2ZcWnH1GI9JJqzpEjOhJLATUXYPjmHs79qsxshEL730J5FS8PlEsytPcTV1okYxE= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1582782724767404.27652680664585; Wed, 26 Feb 2020 21:52:04 -0800 (PST) Received: from localhost ([::1]:54156 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7C5b-0000Gt-9j for importer@patchew.org; Thu, 27 Feb 2020 00:52:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40528) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7C4K-0007Sd-SP for qemu-devel@nongnu.org; Thu, 27 Feb 2020 00:50:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7C4J-0000ts-1g for qemu-devel@nongnu.org; Thu, 27 Feb 2020 00:50:44 -0500 Received: from mgwkm04.jp.fujitsu.com ([202.219.69.171]:34544) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j7C4I-0000pU-BH for qemu-devel@nongnu.org; Thu, 27 Feb 2020 00:50:42 -0500 Received: from kw-mxauth.gw.nic.fujitsu.com (unknown [192.168.231.132]) by mgwkm04.jp.fujitsu.com with smtp id 0687_5148_ad2c6a87_73a2_42f2_828c_5ed06e1c8d12; Thu, 27 Feb 2020 14:50:33 +0900 Received: from g01jpfmpwyt02.exch.g01.fujitsu.local (g01jpfmpwyt02.exch.g01.fujitsu.local [10.128.193.56]) by kw-mxauth.gw.nic.fujitsu.com (Postfix) with ESMTP id 20091AC004F for ; Thu, 27 Feb 2020 14:50:32 +0900 (JST) Received: from g01jpexchyt35.g01.fujitsu.local (unknown [10.128.193.4]) by g01jpfmpwyt02.exch.g01.fujitsu.local (Postfix) with ESMTP id 234DF5842E0; Thu, 27 Feb 2020 14:50:31 +0900 (JST) Received: from luna3.soft.fujitsu.com (10.124.196.199) by g01jpexchyt35.g01.fujitsu.local (10.128.193.50) with Microsoft SMTP Server id 14.3.439.0; Thu, 27 Feb 2020 14:50:31 +0900 From: Misono Tomohiro To: Subject: [PATCH v4 2/2] virtiofsd: Fix xattr operations Date: Thu, 27 Feb 2020 14:59:27 +0900 Message-ID: <20200227055927.24566-3-misono.tomohiro@jp.fujitsu.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200227055927.24566-1-misono.tomohiro@jp.fujitsu.com> References: <20200227055927.24566-1-misono.tomohiro@jp.fujitsu.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SecurityPolicyCheck-GC: OK by FENCE-Mail X-TM-AS-GCONF: 00 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 202.219.69.171 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, vgoyal@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Current virtiofsd has problems about xattr operations and they does not work properly for directory/symlink/special file. The fundamental cause is that virtiofsd uses openat() + f...xattr() systemcalls for xattr operation but we should not open symlink/special file in the daemon. Therefore the function is restricted. Fix this problem by: 1. during setup of each thread, call unshare(CLONE_FS) 2. in xattr operations (i.e. lo_getxattr), if inode is not a regular file or directory, use fchdir(proc_loot_fd) + ...xattr() + fchdir(root.fd) instead of openat() + f...xattr() (Note: for a regular file/directory openat() + f...xattr() is still used for performance reason) With this patch, xfstests generic/062 passes on virtiofs. This fix is suggested by Miklos Szeredi and Stefan Hajnoczi. The original discussion can be found here: https://www.redhat.com/archives/virtio-fs/2019-October/msg00046.html Signed-off-by: Misono Tomohiro Acked-by: Vivek Goyal Reviewed-by: Dr. David Alan Gilbert --- tools/virtiofsd/fuse_virtio.c | 13 ++++ tools/virtiofsd/passthrough_ll.c | 105 +++++++++++++++++-------------- tools/virtiofsd/seccomp.c | 6 ++ 3 files changed, 77 insertions(+), 47 deletions(-) diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c index 655b9a1413..21c5d76d58 100644 --- a/tools/virtiofsd/fuse_virtio.c +++ b/tools/virtiofsd/fuse_virtio.c @@ -463,6 +463,8 @@ err: return ret; } =20 +static __thread bool clone_fs_called; + /* Process one FVRequest in a thread pool */ static void fv_queue_worker(gpointer data, gpointer user_data) { @@ -478,6 +480,17 @@ static void fv_queue_worker(gpointer data, gpointer us= er_data) =20 assert(se->bufsize > sizeof(struct fuse_in_header)); =20 + if (!clone_fs_called) { + int ret; + + /* unshare FS for xattr operation */ + ret =3D unshare(CLONE_FS); + /* should not fail */ + assert(ret =3D=3D 0); + + clone_fs_called =3D true; + } + /* * An element contains one request and the space to send our response * They're spread over multiple descriptors in a scatter/gather set diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough= _ll.c index 7b94300ae0..9d325be8a5 100644 --- a/tools/virtiofsd/passthrough_ll.c +++ b/tools/virtiofsd/passthrough_ll.c @@ -130,7 +130,7 @@ struct lo_inode { pthread_mutex_t plock_mutex; GHashTable *posix_locks; /* protected by lo_inode->plock_mutex */ =20 - bool is_symlink; + mode_t filetype; }; =20 struct lo_cred { @@ -734,7 +734,7 @@ static int utimensat_empty(struct lo_data *lo, struct l= o_inode *inode, struct lo_inode *parent; char path[PATH_MAX]; =20 - if (inode->is_symlink) { + if (S_ISLNK(inode->filetype)) { res =3D utimensat(inode->fd, "", tv, AT_EMPTY_PATH); if (res =3D=3D -1 && errno =3D=3D EINVAL) { /* Sorry, no race free way to set times on symlink. */ @@ -1037,7 +1037,8 @@ static int lo_do_lookup(fuse_req_t req, fuse_ino_t pa= rent, const char *name, goto out_err; } =20 - inode->is_symlink =3D S_ISLNK(e->attr.st_mode); + /* cache only filetype */ + inode->filetype =3D (e->attr.st_mode & S_IFMT); =20 /* * One for the caller and one for nlookup (released in @@ -1264,7 +1265,7 @@ static int linkat_empty_nofollow(struct lo_data *lo, = struct lo_inode *inode, struct lo_inode *parent; char path[PATH_MAX]; =20 - if (inode->is_symlink) { + if (S_ISLNK(inode->filetype)) { res =3D linkat(inode->fd, "", dfd, name, AT_EMPTY_PATH); if (res =3D=3D -1 && (errno =3D=3D ENOENT || errno =3D=3D EINVAL))= { /* Sorry, no race free way to hard-link a symlink. */ @@ -2378,12 +2379,6 @@ static void lo_getxattr(fuse_req_t req, fuse_ino_t i= no, const char *name, fuse_log(FUSE_LOG_DEBUG, "lo_getxattr(ino=3D%" PRIu64 ", name=3D%s siz= e=3D%zd)\n", ino, name, size); =20 - if (inode->is_symlink) { - /* Sorry, no race free way to getxattr on symlink. */ - saverr =3D EPERM; - goto out; - } - if (size) { value =3D malloc(size); if (!value) { @@ -2392,12 +2387,25 @@ static void lo_getxattr(fuse_req_t req, fuse_ino_t = ino, const char *name, } =20 sprintf(procname, "%i", inode->fd); - fd =3D openat(lo->proc_self_fd, procname, O_RDONLY); - if (fd < 0) { - goto out_err; + /* + * It is not safe to open() non-regular/non-dir files in file server + * unless O_PATH is used, so use that method for regular files/dir + * only (as it seems giving less performance overhead). + * Otherwise, call fchdir() to avoid open(). + */ + if (S_ISREG(inode->filetype) || S_ISDIR(inode->filetype)) { + fd =3D openat(lo->proc_self_fd, procname, O_RDONLY); + if (fd < 0) { + goto out_err; + } + ret =3D fgetxattr(fd, name, value, size); + } else { + /* fchdir should not fail here */ + assert(fchdir(lo->proc_self_fd) =3D=3D 0); + ret =3D getxattr(procname, name, value, size); + assert(fchdir(lo->root.fd) =3D=3D 0); } =20 - ret =3D fgetxattr(fd, name, value, size); if (ret =3D=3D -1) { goto out_err; } @@ -2451,12 +2459,6 @@ static void lo_listxattr(fuse_req_t req, fuse_ino_t = ino, size_t size) fuse_log(FUSE_LOG_DEBUG, "lo_listxattr(ino=3D%" PRIu64 ", size=3D%zd)\= n", ino, size); =20 - if (inode->is_symlink) { - /* Sorry, no race free way to listxattr on symlink. */ - saverr =3D EPERM; - goto out; - } - if (size) { value =3D malloc(size); if (!value) { @@ -2465,12 +2467,19 @@ static void lo_listxattr(fuse_req_t req, fuse_ino_t= ino, size_t size) } =20 sprintf(procname, "%i", inode->fd); - fd =3D openat(lo->proc_self_fd, procname, O_RDONLY); - if (fd < 0) { - goto out_err; + if (S_ISREG(inode->filetype) || S_ISDIR(inode->filetype)) { + fd =3D openat(lo->proc_self_fd, procname, O_RDONLY); + if (fd < 0) { + goto out_err; + } + ret =3D flistxattr(fd, value, size); + } else { + /* fchdir should not fail here */ + assert(fchdir(lo->proc_self_fd) =3D=3D 0); + ret =3D listxattr(procname, value, size); + assert(fchdir(lo->root.fd) =3D=3D 0); } =20 - ret =3D flistxattr(fd, value, size); if (ret =3D=3D -1) { goto out_err; } @@ -2524,20 +2533,21 @@ static void lo_setxattr(fuse_req_t req, fuse_ino_t = ino, const char *name, fuse_log(FUSE_LOG_DEBUG, "lo_setxattr(ino=3D%" PRIu64 ", name=3D%s value=3D%s size=3D%zd)\n", ino, name, value, siz= e); =20 - if (inode->is_symlink) { - /* Sorry, no race free way to setxattr on symlink. */ - saverr =3D EPERM; - goto out; - } - sprintf(procname, "%i", inode->fd); - fd =3D openat(lo->proc_self_fd, procname, O_RDWR); - if (fd < 0) { - saverr =3D errno; - goto out; + if (S_ISREG(inode->filetype) || S_ISDIR(inode->filetype)) { + fd =3D openat(lo->proc_self_fd, procname, O_RDONLY); + if (fd < 0) { + saverr =3D errno; + goto out; + } + ret =3D fsetxattr(fd, name, value, size, flags); + } else { + /* fchdir should not fail here */ + assert(fchdir(lo->proc_self_fd) =3D=3D 0); + ret =3D setxattr(procname, name, value, size, flags); + assert(fchdir(lo->root.fd) =3D=3D 0); } =20 - ret =3D fsetxattr(fd, name, value, size, flags); saverr =3D ret =3D=3D -1 ? errno : 0; =20 if (!saverr) { @@ -2575,20 +2585,21 @@ static void lo_removexattr(fuse_req_t req, fuse_ino= _t ino, const char *name) fuse_log(FUSE_LOG_DEBUG, "lo_removexattr(ino=3D%" PRIu64 ", name=3D%s)= \n", ino, name); =20 - if (inode->is_symlink) { - /* Sorry, no race free way to setxattr on symlink. */ - saverr =3D EPERM; - goto out; - } - sprintf(procname, "%i", inode->fd); - fd =3D openat(lo->proc_self_fd, procname, O_RDWR); - if (fd < 0) { - saverr =3D errno; - goto out; + if (S_ISREG(inode->filetype) || S_ISDIR(inode->filetype)) { + fd =3D openat(lo->proc_self_fd, procname, O_RDONLY); + if (fd < 0) { + saverr =3D errno; + goto out; + } + ret =3D fremovexattr(fd, name); + } else { + /* fchdir should not fail here */ + assert(fchdir(lo->proc_self_fd) =3D=3D 0); + ret =3D removexattr(procname, name); + assert(fchdir(lo->root.fd) =3D=3D 0); } =20 - ret =3D fremovexattr(fd, name); saverr =3D ret =3D=3D -1 ? errno : 0; =20 if (!saverr) { @@ -3185,7 +3196,7 @@ static void setup_root(struct lo_data *lo, struct lo_= inode *root) exit(1); } =20 - root->is_symlink =3D false; + root->filetype =3D S_IFDIR; root->fd =3D fd; root->key.ino =3D stat.st_ino; root->key.dev =3D stat.st_dev; diff --git a/tools/virtiofsd/seccomp.c b/tools/virtiofsd/seccomp.c index 2d9d4a7ec0..bd9e7b083c 100644 --- a/tools/virtiofsd/seccomp.c +++ b/tools/virtiofsd/seccomp.c @@ -41,6 +41,7 @@ static const int syscall_whitelist[] =3D { SCMP_SYS(exit), SCMP_SYS(exit_group), SCMP_SYS(fallocate), + SCMP_SYS(fchdir), SCMP_SYS(fchmodat), SCMP_SYS(fchownat), SCMP_SYS(fcntl), @@ -62,7 +63,9 @@ static const int syscall_whitelist[] =3D { SCMP_SYS(getpid), SCMP_SYS(gettid), SCMP_SYS(gettimeofday), + SCMP_SYS(getxattr), SCMP_SYS(linkat), + SCMP_SYS(listxattr), SCMP_SYS(lseek), SCMP_SYS(madvise), SCMP_SYS(mkdirat), @@ -85,6 +88,7 @@ static const int syscall_whitelist[] =3D { SCMP_SYS(recvmsg), SCMP_SYS(renameat), SCMP_SYS(renameat2), + SCMP_SYS(removexattr), SCMP_SYS(rt_sigaction), SCMP_SYS(rt_sigprocmask), SCMP_SYS(rt_sigreturn), @@ -98,10 +102,12 @@ static const int syscall_whitelist[] =3D { SCMP_SYS(setresuid32), #endif SCMP_SYS(set_robust_list), + SCMP_SYS(setxattr), SCMP_SYS(symlinkat), SCMP_SYS(time), /* Rarely needed, except on static builds */ SCMP_SYS(tgkill), SCMP_SYS(unlinkat), + SCMP_SYS(unshare), SCMP_SYS(utimensat), SCMP_SYS(write), SCMP_SYS(writev), --=20 2.21.1