Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2757348ybh; Mon, 5 Aug 2019 06:22:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqwDgPCMuGY1QXdMI14hVFlIR8m5L/fYz/k1i8pmWqkpxY+GWgiG6bVXhZcDUT18z5rnRiGX X-Received: by 2002:a17:90a:ac11:: with SMTP id o17mr18314758pjq.134.1565011347931; Mon, 05 Aug 2019 06:22:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565011347; cv=none; d=google.com; s=arc-20160816; b=E5NR8BLsOAZPEcanpSVaZvuoImghoxMmiwCxGY4KGG+AqddO0bNcryDB2FFMHQmwj6 Y5kkVZYlq60cBKo7bgMg9XkVBYMEFiAkrMJ3Pd5yMY4stGszfiBrbHk1468g2wdPouZ7 pIkoxpXvBzNXqspuARGqylH12oZn1q1eOtBd6TI9ZUWQOt1uUhmLNOnqafWJafCrc598 eSPa5+BrD672Iu4h7fQtHh3aue6RNIlhMUjTQNCJL3NawGod+9Qie5JQVQQ7kiZvuXCV KwHFcgHp/BzuKlQp7iBDHNM5VJnOQeHO3AfCDdpQ/Y+cBnqPViQ4N6ZzCxti1QElhvBM 7ouA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Awxg9Ih8j8FnrozUW82aZWd1LSx+i18tkYRHS3p+olY=; b=uPpyxRT0p9/gFpHdXq4clx9hVsUjT6gid9mZPyOo+0mOvlDzC7q0c/9E9TgduQPfXo S6KmtdFp46eknFV4nOJIzPb/ccxYYseIEe1i9qP+u53Dic2MnKNaxM6WfhsOrOiOy/SB J7rb8j033hdqm7e2OZuk2S1erBtTLSBzZEd9b5YlJR+lItuyMT7lB4vLds6JcGRKEm3I fPFIK1zNxEaLlxk9OoCu5x1HqwkOblwowwhmWHP3X9SFdehV5Vk2Eu6DqUIabEWunC9P kMbwIBQ8bdKLIzRYWL1Gdy3hvuTpuhbpTs5DOsqX1RDRv2vPzgLLkaS1NfWTq1irRc86 t7mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MyrVRK4o; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j12si12643751pgp.261.2019.08.05.06.22.12; Mon, 05 Aug 2019 06:22:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MyrVRK4o; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730515AbfHENVZ (ORCPT + 99 others); Mon, 5 Aug 2019 09:21:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:57464 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730479AbfHENVR (ORCPT ); Mon, 5 Aug 2019 09:21:17 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ABD3B20880; Mon, 5 Aug 2019 13:21:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565011277; bh=6/aconRxdHSsHCvo34orQxhuarnf6NEQYSFYDAIaev8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MyrVRK4oBkjBNdLeE6E9grHFJR5t0WyVnRxKstSdnjalgI//2BxBP015mjAxFDrDM WUHTyvVF0TYl9kU6fQwoq93zQcvVJZ4jUxpVKA871nzlrnxmkrQNPCs1vIrNKqNbyA PI5i4y5O+S1hmGjgGp+KH93rn1qWzA/9c0CDM6YY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ronnie Sahlberg , Pavel Shilovsky , Steve French , Sasha Levin Subject: [PATCH 5.2 031/131] cifs: Fix a race condition with cifs_echo_request Date: Mon, 5 Aug 2019 15:01:58 +0200 Message-Id: <20190805124953.516186475@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190805124951.453337465@linuxfoundation.org> References: <20190805124951.453337465@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit f2caf901c1b7ce65f9e6aef4217e3241039db768 ] There is a race condition with how we send (or supress and don't send) smb echos that will cause the client to incorrectly think the server is unresponsive and thus needs to be reconnected. Summary of the race condition: 1) Daisy chaining scheduling creates a gap. 2) If traffic comes unfortunate shortly after the last echo, the planned echo is suppressed. 3) Due to the gap, the next echo transmission is delayed until after the timeout, which is set hard to twice the echo interval. This is fixed by changing the timeouts from 2 to three times the echo interval. Detailed description of the bug: https://lutz.donnerhacke.de/eng/Blog/Groundhog-Day-with-SMB-remount Signed-off-by: Ronnie Sahlberg Reviewed-by: Pavel Shilovsky Signed-off-by: Steve French Signed-off-by: Sasha Levin --- fs/cifs/connect.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 59380dd546a1e..6ad43ac129d2f 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -706,10 +706,10 @@ static bool server_unresponsive(struct TCP_Server_Info *server) { /* - * We need to wait 2 echo intervals to make sure we handle such + * We need to wait 3 echo intervals to make sure we handle such * situations right: * 1s client sends a normal SMB request - * 2s client gets a response + * 3s client gets a response * 30s echo workqueue job pops, and decides we got a response recently * and don't need to send another * ... @@ -718,9 +718,9 @@ server_unresponsive(struct TCP_Server_Info *server) */ if ((server->tcpStatus == CifsGood || server->tcpStatus == CifsNeedNegotiate) && - time_after(jiffies, server->lstrp + 2 * server->echo_interval)) { + time_after(jiffies, server->lstrp + 3 * server->echo_interval)) { cifs_dbg(VFS, "Server %s has not responded in %lu seconds. Reconnecting...\n", - server->hostname, (2 * server->echo_interval) / HZ); + server->hostname, (3 * server->echo_interval) / HZ); cifs_reconnect(server); wake_up(&server->response_q); return true; -- 2.20.1