From nobody Fri Mar 29 10:45:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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 1642088980408406.357773254986; Thu, 13 Jan 2022 07:49:40 -0800 (PST) Received: from localhost ([::1]:60472 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n82M6-000849-Lo for importer@patchew.org; Thu, 13 Jan 2022 10:49:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n826h-0000j6-13 for qemu-devel@nongnu.org; Thu, 13 Jan 2022 10:33:43 -0500 Received: from smtp01.stuvus.uni-stuttgart.de ([129.69.139.72]:48018) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n826d-0000wU-IC for qemu-devel@nongnu.org; Thu, 13 Jan 2022 10:33:42 -0500 Received: from [141.58.209.220] (helo=beaver.rus.uni-stuttgart.de) by smtp01.stuvus.uni-stuttgart.de with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (envelope-from ) ; Thu, 13 Jan 2022 16:33:33 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=stuvus.uni-stuttgart.de; s=20200828.smtp01; h=Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=K47Phf+baWik1OtUpOcdWSSeVU2rZCJrwMNuGUWLoqk=; b=Jz3+T9hCz85lKlAX5QIyVhCOo e1RLDcZTNMltf3EJvTcIr5OZWJq8RZIaEJMsxJRXCd1rZmIGyy2rLya7K5iHP/PwcbyFixJBbCUMA gNajrBiqw9x6Wb/mjKiPVM3io6+Ti98C4RCsNO5XwBq+HP7X6Enk/8YkKqKH/xdoZfhsuIiuaRkId fpejRtmWX5Cx+RJde4ecFAVwCh2MHj0CiTiP3DbD+Ofq2clBQphspBFpO1O3BjRrMoTke0QWJcgNd YEWyJXoCahC/czs02htGLhDV1hGnmsbs5AQN6qQP+oAlPIsPvYNsjKkUwvXmhdHB2FenPw+KwDS0A CaIElVkoQ==; X-Spam-Bar: + X-Spam-Score: 1.9 From: Sebastian Hasler To: qemu-devel@nongnu.org Subject: [PATCH v2] virtiofsd: Do not support blocking flock Date: Thu, 13 Jan 2022 16:32:49 +0100 Message-Id: <20220113153249.710216-1-sebastian.hasler@stuvus.uni-stuttgart.de> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=129.69.139.72; envelope-from=sebastian.hasler@stuvus.uni-stuttgart.de; helo=smtp01.stuvus.uni-stuttgart.de X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: virtio-fs@redhat.com, Sebastian Hasler Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1642088984214100001 Content-Type: text/plain; charset="utf-8" With the current implementation, blocking flock can lead to deadlock. Thus, it's better to return EOPNOTSUPP if a user attempts to perform a blocking flock request. Signed-off-by: Sebastian Hasler Reviewed-by: Greg Kurz Reviewed-by: Vivek Goyal --- tools/virtiofsd/passthrough_ll.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough= _ll.c index 64b5b4fbb1..faa62278c5 100644 --- a/tools/virtiofsd/passthrough_ll.c +++ b/tools/virtiofsd/passthrough_ll.c @@ -2442,6 +2442,15 @@ static void lo_flock(fuse_req_t req, fuse_ino_t ino,= struct fuse_file_info *fi, int res; (void)ino; =20 + if (!(op & LOCK_NB)) { + /* + * Blocking flock can deadlock as there is only one thread + * serving the queue. + */ + fuse_reply_err(req, EOPNOTSUPP); + return; + } + res =3D flock(lo_fi_fd(req, fi), op); =20 fuse_reply_err(req, res =3D=3D -1 ? errno : 0); --=20 2.33.1