From nobody Sat May 18 17:16:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1571222452; cv=none; d=zoho.com; s=zohoarc; b=Doz6N8aU7PCzwhwqUNHZ6XVBqqBjAuZh18QiP7UNiBxPKKLLjSXnupor4ZJYkiki7T04z+9Oc0YOhg/VQqsWph18X+QdEUpKEJc5V6JljqxcQZwWqJ1XYaIqFxUCXCVumekkhFTDroy6nGQzZgwQTwK1HOQEmyTfCGFy2VU8TsE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571222452; 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=ahgLQwgUDmHWO3TkVhUZZNOL5Eay9Zwe18HW8wgcbTI=; b=K4P+Yht8cFtHzVkQJmNWnjatDBKSRtc3hD1nb2BMA8FVoUvOk0ZUQOjC4GzVD6IHMCNX2YO84pX7M8tFs4NnMHg5hEl47pxGXZJuDNI7ucjqQ1KbkW6qnK+/18fuGdVIY7KVrBhiR+Uu7mH/cRWiJlEG6wecqXNBXHb3i2+SRQw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1571222452924545.8010200627815; Wed, 16 Oct 2019 03:40:52 -0700 (PDT) Received: from localhost ([::1]:40732 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKgjb-0004H8-TG for importer@patchew.org; Wed, 16 Oct 2019 06:40:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35979) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKga8-0006Rh-VM for qemu-devel@nongnu.org; Wed, 16 Oct 2019 06:31:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKga4-0006G4-3h for qemu-devel@nongnu.org; Wed, 16 Oct 2019 06:31:04 -0400 Received: from mgwkm02.jp.fujitsu.com ([202.219.69.169]:46960) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iKga2-0006FM-Aj for qemu-devel@nongnu.org; Wed, 16 Oct 2019 06:30:59 -0400 Received: from kw-mxauth.gw.nic.fujitsu.com (unknown [192.168.231.132]) by mgwkm02.jp.fujitsu.com with smtp id 3866_5ffe_eb1f6e5b_66f1_425e_b0c7_02822bc8ecff; Wed, 16 Oct 2019 19:30:50 +0900 Received: from g01jpfmpwkw01.exch.g01.fujitsu.local (g01jpfmpwkw01.exch.g01.fujitsu.local [10.0.193.38]) by kw-mxauth.gw.nic.fujitsu.com (Postfix) with ESMTP id 28D09AC00D2 for ; Wed, 16 Oct 2019 19:30:49 +0900 (JST) Received: from G01JPEXCHKW17.g01.fujitsu.local (G01JPEXCHKW17.g01.fujitsu.local [10.0.194.56]) by g01jpfmpwkw01.exch.g01.fujitsu.local (Postfix) with ESMTP id 3692E6925C7; Wed, 16 Oct 2019 19:30:48 +0900 (JST) Received: from luna3.soft.fujitsu.com (10.124.196.199) by G01JPEXCHKW17.g01.fujitsu.local (10.0.194.56) with Microsoft SMTP Server id 14.3.439.0; Wed, 16 Oct 2019 19:30:48 +0900 From: Misono Tomohiro To: Subject: [PATCH 1/2] virtiofsd: Avoid process hang when doing xattr operation to FIFO Date: Wed, 16 Oct 2019 19:37:53 +0900 Message-ID: <20191016103754.2047-2-misono.tomohiro@jp.fujitsu.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191016103754.2047-1-misono.tomohiro@jp.fujitsu.com> References: <20191016103754.2047-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.169 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, misono.tomohiro@jp.fujitsu.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" I see xfstest generic/062 causes process hang because of xattr operation to FIFO created by mknod. The problem is that virtiofsd opens any files with only O_RDWR or O_RDONLY flags for xattr operation, and therefore if a file is FIFO, open may not return. Since O_NONBLOCK flag has no effect to regular files, add it to open flags to fix the problem. Signed-off-by: Misono Tomohiro Reviewed-by: Stefan Hajnoczi --- contrib/virtiofsd/passthrough_ll.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/virtiofsd/passthrough_ll.c b/contrib/virtiofsd/passthr= ough_ll.c index 84b60d85bd..645324da58 100644 --- a/contrib/virtiofsd/passthrough_ll.c +++ b/contrib/virtiofsd/passthrough_ll.c @@ -2251,7 +2251,7 @@ static void lo_getxattr(fuse_req_t req, fuse_ino_t in= o, const char *name, } =20 sprintf(procname, "%i", inode->fd); - fd =3D openat(lo->proc_self_fd, procname, O_RDONLY); + fd =3D openat(lo->proc_self_fd, procname, O_RDONLY|O_NONBLOCK); if (fd < 0) { goto out_err; } @@ -2323,7 +2323,7 @@ static void lo_listxattr(fuse_req_t req, fuse_ino_t i= no, size_t size) } =20 sprintf(procname, "%i", inode->fd); - fd =3D openat(lo->proc_self_fd, procname, O_RDONLY); + fd =3D openat(lo->proc_self_fd, procname, O_RDONLY|O_NONBLOCK); if (fd < 0) { goto out_err; } @@ -2397,7 +2397,7 @@ static void lo_setxattr(fuse_req_t req, fuse_ino_t in= o, const char *name, } =20 sprintf(procname, "%i", inode->fd); - fd =3D openat(lo->proc_self_fd, procname, O_RDWR); + fd =3D openat(lo->proc_self_fd, procname, O_RDWR|O_NONBLOCK); if (fd < 0) { saverr =3D errno; goto out; @@ -2446,7 +2446,7 @@ static void lo_removexattr(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_RDWR); + fd =3D openat(lo->proc_self_fd, procname, O_RDWR|O_NONBLOCK); if (fd < 0) { saverr =3D errno; goto out; --=20 2.21.0 From nobody Sat May 18 17:16:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1571221999; cv=none; d=zoho.com; s=zohoarc; b=FQG4IZrmEpq4/1obQquOTv0pRXyPVoCTb3GwbGalTESLcNaZYe3Z0dZJ8Ttlb04bkxKXz0HqEAiQ9ByCkDV4ewBQQd/C5b0WdBDYWQykj3W6uH+pFH6Y5RIDOmZdimFHsgEa2taaKk1O9hm1zL1haVtq3tnqHAV9jdMvaC+m+qw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571221999; 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=o6L3HRkuF8N+gYJ0VxAkgjr4Lm2KZfOfxDR1dP1oqdQ=; b=Kn1iB3ajYqKGcK7mjsurj8+elk+320tLRTlsQB3GPeB6qCcdQ4botqSe5LUX1U4OF1BJq2kmIf1BiBvR5V9h8yRLZvumUi7Fn/9U6hoA1kHPc1XedpeKGAjC+noynmN6sgP5wPaNEnb8IlL628GCJz+RB/j9gcEnqK7HnXMhXyQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 157122199921397.17795714339411; Wed, 16 Oct 2019 03:33:19 -0700 (PDT) Received: from localhost ([::1]:40664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKgcI-0007R9-4x for importer@patchew.org; Wed, 16 Oct 2019 06:33:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35980) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKga9-0006Ri-0L for qemu-devel@nongnu.org; Wed, 16 Oct 2019 06:31:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKga4-0006GA-4S for qemu-devel@nongnu.org; Wed, 16 Oct 2019 06:31:04 -0400 Received: from mgwym04.jp.fujitsu.com ([211.128.242.43]:42843) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iKga2-0006Fa-BQ for qemu-devel@nongnu.org; Wed, 16 Oct 2019 06:31:00 -0400 Received: from yt-mxauth.gw.nic.fujitsu.com (unknown [192.168.229.68]) by mgwym04.jp.fujitsu.com with smtp id 5cc6_13a4_95c720a2_6587_411c_9454_ce4b7341e6f3; Wed, 16 Oct 2019 19:30:51 +0900 Received: from g01jpfmpwkw02.exch.g01.fujitsu.local (g01jpfmpwkw02.exch.g01.fujitsu.local [10.0.193.56]) by yt-mxauth.gw.nic.fujitsu.com (Postfix) with ESMTP id 9841AAC00C6 for ; Wed, 16 Oct 2019 19:30:50 +0900 (JST) Received: from G01JPEXCHKW17.g01.fujitsu.local (G01JPEXCHKW17.g01.fujitsu.local [10.0.194.56]) by g01jpfmpwkw02.exch.g01.fujitsu.local (Postfix) with ESMTP id 99DE93284C9; Wed, 16 Oct 2019 19:30:49 +0900 (JST) Received: from luna3.soft.fujitsu.com (10.124.196.199) by G01JPEXCHKW17.g01.fujitsu.local (10.0.194.56) with Microsoft SMTP Server id 14.3.439.0; Wed, 16 Oct 2019 19:30:49 +0900 From: Misono Tomohiro To: Subject: [PATCH 2/2] virtiofsd: Allow setxattr operation to directry Date: Wed, 16 Oct 2019 19:37:54 +0900 Message-ID: <20191016103754.2047-3-misono.tomohiro@jp.fujitsu.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191016103754.2047-1-misono.tomohiro@jp.fujitsu.com> References: <20191016103754.2047-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: 211.128.242.43 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, misono.tomohiro@jp.fujitsu.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" setxattr to directry fails because lo_setxattr (and lo_remove_xattr) tries to open any file with O_RDWR even if it is a directory. Since O_RDONLY is enough for the operation, change O_RDWR flag to O_RDONLY to fix the problem. Signed-off-by: Misono Tomohiro Reviewed-by: Stefan Hajnoczi --- contrib/virtiofsd/passthrough_ll.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/virtiofsd/passthrough_ll.c b/contrib/virtiofsd/passthr= ough_ll.c index 645324da58..1b439d58ed 100644 --- a/contrib/virtiofsd/passthrough_ll.c +++ b/contrib/virtiofsd/passthrough_ll.c @@ -2397,7 +2397,7 @@ static void lo_setxattr(fuse_req_t req, fuse_ino_t in= o, const char *name, } =20 sprintf(procname, "%i", inode->fd); - fd =3D openat(lo->proc_self_fd, procname, O_RDWR|O_NONBLOCK); + fd =3D openat(lo->proc_self_fd, procname, O_RDONLY|O_NONBLOCK); if (fd < 0) { saverr =3D errno; goto out; @@ -2446,7 +2446,7 @@ static void lo_removexattr(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_RDWR|O_NONBLOCK); + fd =3D openat(lo->proc_self_fd, procname, O_RDONLY|O_NONBLOCK); if (fd < 0) { saverr =3D errno; goto out; --=20 2.21.0