From patchwork Thu Apr 23 12:35:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Federico Sauter X-Patchwork-Id: 6262061 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C90BA9F1BE for ; Thu, 23 Apr 2015 12:35:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C85FC20265 for ; Thu, 23 Apr 2015 12:35:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 536C7200E1 for ; Thu, 23 Apr 2015 12:35:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934296AbbDWMfE (ORCPT ); Thu, 23 Apr 2015 08:35:04 -0400 Received: from host2.bln.innominate.com ([77.245.32.75]:20884 "EHLO home.innominate.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934251AbbDWMfD (ORCPT ); Thu, 23 Apr 2015 08:35:03 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by home.innominate.com (Postfix) with ESMTP id C06FF21B6 for ; Thu, 23 Apr 2015 14:35:00 +0200 (CEST) Received: from home.innominate.com ([127.0.0.1]) by localhost (innominate.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bxT45mygjY7W for ; Thu, 23 Apr 2015 14:35:00 +0200 (CEST) Received: from [10.1.8.10] (unknown [10.1.8.10]) by home.innominate.com (Postfix) with ESMTP id A65CB21B3 for ; Thu, 23 Apr 2015 14:35:00 +0200 (CEST) Message-ID: <5538E6F4.6010105@innominate.com> Date: Thu, 23 Apr 2015 14:35:00 +0200 From: Federico Sauter User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: linux-cifs@vger.kernel.org Subject: Re: [PATCH] CIFS: Fix race condition on RFC1002_NEGATIVE_SESSION_RESPONSE References: <550860D2.5040207@innominate.com> In-Reply-To: <550860D2.5040207@innominate.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Any feedback on whether this patch makes sense or not? ;-) ---8<---------------------------------------------------------------------- >From 54e3c95a4646c8666c6f08766250fd056b06e7f5 Mon Sep 17 00:00:00 2001 From: Federico Sauter Date: Tue, 17 Mar 2015 17:45:28 +0100 Subject: [PATCH] CIFS: Fix race condition on RFC1002_NEGATIVE_SESSION_RESPONSE This patch fixes a race condition that occurs when connecting to a NT 3.51 host without specifying a NetBIOS name. In that case a RFC1002_NEGATIVE_SESSION_RESPONSE is received and the SMB negotiation is reattempted, but under some conditions it leads SendReceive() to hang forever while waiting for srv_mutex. This, in turn, sets the calling process to an uninterruptible sleep state and makes it unkillable. The solution is to unlock the srv_mutex acquired in the demux thread *before* going to sleep (after the reconnect error) and before reattempting the connection. --- fs/cifs/connect.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index d05a300..a45e7fc 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -381,6 +381,7 @@ cifs_reconnect(struct TCP_Server_Info *server) rc = generic_ip_connect(server); if (rc) { cifs_dbg(FYI, "reconnect error %d\n", rc); + mutex_unlock(&server->srv_mutex); msleep(3000); } else { atomic_inc(&tcpSesReconnectCount); @@ -388,8 +389,8 @@ cifs_reconnect(struct TCP_Server_Info *server) if (server->tcpStatus != CifsExiting) server->tcpStatus = CifsNeedNegotiate; spin_unlock(&GlobalMid_Lock); + mutex_unlock(&server->srv_mutex); } - mutex_unlock(&server->srv_mutex); } while (server->tcpStatus == CifsNeedReconnect); return rc;