From patchwork Sun Dec 19 09:34:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasily Averin X-Patchwork-Id: 12686647 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 688B1C433F5 for ; Sun, 19 Dec 2021 09:35:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232415AbhLSJfA (ORCPT ); Sun, 19 Dec 2021 04:35:00 -0500 Received: from mail-am6eur05on2108.outbound.protection.outlook.com ([40.107.22.108]:7712 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229585AbhLSJfA (ORCPT ); Sun, 19 Dec 2021 04:35:00 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TVZ9r37AYf3l2YE59x1Qbl9ZWfsDn0Cyw8hGLa1Js41f/rcwqaf/O0669667gwQJb36xpz6HI0k1D33zPCr4JdINdf98Fci28ioqfDwcMYbwN9sOC66U/GeVYf4I6uCGR4AIFmyNbgLKB9EkRSNsQDOgLg5NVNHP/4MSXTMCKkLvsC5+FBkUDqGQnJtRaK5LXio+i5Voj0ORZUL6dCUGxzaa/d1S4EyjzJvck2FHnP5OeTLdewQItP2/aQr+k4VrKH/L/jNNDdUAxy2vJ+dXmUP7AOk3ou66InsWRy7Wq1A69UcNpn6BvIG+Uyg9nGaQmk1hs0qYCGLSUtv6s39Qtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YqosS6LVyNHWnlOWDQWJd/jT4o74AN19ou/E9pCa7KE=; b=GV5McJrIuWcnpIqNgD0bMruHbM/hHYNmvTWRAqqChTw/iRfxZFVSIEGJBDzZ1UbZnSZald5sL5Rp1SiP0DA0Cz+VZI1AsCNxuIUfgK0mq2l4q4hIp/qTD0ZfojWSQzXH4vLjSJS5a/Ih8tX+eLlC7th8GwJ0XQkXY6VSWEjCsezm6hF5XnB3zPchzg0WzLH2Q+z98E3ec5bbujzOyWPjqdMNz3/PFeGRdHoiLKAMLfREwzejpNIyhy3qxFjlhLWF0hQ/niQfWGcZP3tLHaeFhpZI1Jvt3UV26fYNJbMr3zWLzTepRA980duQiyODKdu7m6/CB9K5sHCfCpPxLd/aBA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YqosS6LVyNHWnlOWDQWJd/jT4o74AN19ou/E9pCa7KE=; b=dAKycXxW56l00JIaYDz+F6CHM7qY4m5al/oa0671oS2JgrCBN3h9RwqeJpA9VfY9mny1ZPiWeE+BNoLBO6S9y32uVWVEDqaUSLgOnPNaze07Bke1nU9Ox+DkVRPReUjDU8i92beOYq4XC2GIXZ1ogAnfHhKFoEQhQ+ZV5FnoyF8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DB9PR08MB6619.eurprd08.prod.outlook.com (2603:10a6:10:257::21) by DB6PR0801MB2022.eurprd08.prod.outlook.com (2603:10a6:4:76::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.17; Sun, 19 Dec 2021 09:34:56 +0000 Received: from DB9PR08MB6619.eurprd08.prod.outlook.com ([fe80::347f:d385:ec53:75aa]) by DB9PR08MB6619.eurprd08.prod.outlook.com ([fe80::347f:d385:ec53:75aa%7]) with mapi id 15.20.4801.015; Sun, 19 Dec 2021 09:34:56 +0000 From: Vasily Averin Subject: [PATCH] ksmbd: use F_SETLK to force vfs_file_lock() to return asynchronously To: Namjae Jeon , Sergey Senozhatsky , Steve French , Hyunchul Lee Cc: kernel@openvz.org, linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Message-ID: Date: Sun, 19 Dec 2021 12:34:54 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 Content-Language: en-US X-ClientProxiedBy: AM6PR10CA0028.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:89::41) To DB9PR08MB6619.eurprd08.prod.outlook.com (2603:10a6:10:257::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c33f0c42-c840-49a9-53f4-08d9c2d2d14b X-MS-TrafficTypeDiagnostic: DB6PR0801MB2022:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:663; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 06o7OHdi3V38FhNLyHfyTaTICw11C90AU841EUrLH133Y1VuZPFMAvmdetRiWqCi7qAuYUXEKd8t7QcnnuFhK8eH+7CvUiSYssjXx2aVVvDgwDSStriL012pjXo5HLo7PKTDugrCF0icrkaHO5NScj2xZA0soaZpRyHuVV2WrVjFoGMgGjFQZWCMwP4bHId/4KtRAqFYMU8gcDGQxcoFm4WDlEpuvA8qlP+ocdhu88dsb4hbvPb1/cWngz4K8KihdZPBwxs+aciQTysNBR3cd+2QboJJLsc2BZQGcHj/s1GlocGM4VvZbMwuUFu/0vgUZz8Ao9TEtBBPv8goPIaovvMQsmpZjkxJzC52hfDtbOPhR7zZnCk+vHYPQonYxw/BiBmvOEAy+q3IoyEECVH3uSU6abHZ9hCNDWgIUvOVAi+hpMBQikkrYgqMjNXsTXpPNQkHWl7oIJkWZQecN3KTLQUpzLutuA4mnhk9olyielvmhu7T39dImMaNFoaiy34ZOAwfZ9xZ8TX1gYMfTrEA3QE7i/RqxiLyFF8PIHypNE3tc/irf091YMCsGWJaBtO02EDss5AyNNmtzkaHOkGsyCWrWVM2qliTTzELUHgk4SLIA3KZlzvZvyrQz4Rt60Oqijsg+b8hIlc4BcsVYEyShnV5Lf8cQJErknyVpoLNlZMCpReFAuiitlFncW4wBXBRkO/Jsd2Ic30hI3kqxFiIqrrsBMS6G1RULFXHQRXaLpcgFilqNfaIp3kc/iCtifkQLGZg4JBn93iR/dA43E/cQg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR08MB6619.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(2906002)(6486002)(316002)(110136005)(5660300002)(38350700002)(38100700002)(4744005)(31696002)(31686004)(86362001)(36756003)(66946007)(66556008)(4326008)(66476007)(508600001)(6512007)(8936002)(83380400001)(186003)(52116002)(26005)(6506007)(8676002)(2616005)(45980500001)(43740500002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?izfzwuZQatlyp5cfZ+Gm1EIbUgPp?= =?utf-8?q?hkQnca/O+SokDOHgELNOPG2cuxFOhIiBF37MnIskWAzttoscV29XMX37bVQNbLDFA?= =?utf-8?q?rhhsDuVl/SC5iAoQwbw8n2LfhtkeIvjl9GNadD5VIOK8MUJk5/YvGiZazLIUWvBWn?= =?utf-8?q?RLe/kqkrSxJ+6FbrQ4wVQUO2NtbiKpVss2K1e/KyNd1/V2YhA5fOkSAT20A0B08Ro?= =?utf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utf-8?q?T/kdYUgdc4HGj0HeJLBYS6IvO+Bs7yzjDz55+yp5YHhDOfCGvZFQtWpbmLd7OsRi/?= =?utf-8?q?mMBIewpv4GIjlDtmu0LV9f00ejWPkMPFoQa9kU3LKXlq/xWykAVIi943Nn1Gd0avG?= =?utf-8?q?qr+XbdFhB42cS1cO8YLckR0hFCDHYjBXEx+UvQsidxkbFUIe+r6sad7Dwrw6hw9V8?= =?utf-8?q?BnlUk9GmJoww5ZxlXzpllKgfeFfLWOjAKh2LZUvBO0oqBtEex5vblfkHNLwXNN2L5?= =?utf-8?q?HZVQ4tSjDeDWwCoSRlLk9mW+zCpklXHySWIrL8nPO/ieywdoEZCmjEq1YGgWU9Ehk?= =?utf-8?q?bdgD2epsaW8HDX2GsqAtzjlOzGaIXZu4E6rqTiMLIBqt7gMRBU4PT9ra78gSzDVA4?= =?utf-8?q?bFbfwv6LDh8OEAlMmFja+Q1pDwKxcTHg7Pd5opqeWfuvWfitmIXlsML4ElAZM+7aX?= =?utf-8?q?NhVlR8uewFKo8TYjwagvgvmK1WAdKgDLEBBv/TWAk3WrNSiSxHLu3BA=3D?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: c33f0c42-c840-49a9-53f4-08d9c2d2d14b X-MS-Exchange-CrossTenant-AuthSource: DB9PR08MB6619.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2021 09:34:56.2549 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7RTnH1I7198+sSx0HF03UmnWbuf3BL3wCDZsFh7gpFE0S67h5P22EQxzlChmMBA8eBX1LUUP8m0HT3mKgrQ6HQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB2022 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org To avoid possible deadlock ksmbd should process locks asynchronously. Callers expecting vfs_file_locks() to return asynchronously should only use F_SETLK, not F_SETLKW. Signed-off-by: Vasily Averin --- fs/ksmbd/smb2pdu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c index 0c020deb76bb..34f333549767 100644 --- a/fs/ksmbd/smb2pdu.c +++ b/fs/ksmbd/smb2pdu.c @@ -6646,13 +6646,13 @@ static int smb2_set_flock_flags(struct file_lock *flock, int flags) switch (flags) { case SMB2_LOCKFLAG_SHARED: ksmbd_debug(SMB, "received shared request\n"); - cmd = F_SETLKW; + cmd = F_SETLK; flock->fl_type = F_RDLCK; flock->fl_flags |= FL_SLEEP; break; case SMB2_LOCKFLAG_EXCLUSIVE: ksmbd_debug(SMB, "received exclusive request\n"); - cmd = F_SETLKW; + cmd = F_SETLK; flock->fl_type = F_WRLCK; flock->fl_flags |= FL_SLEEP; break;