Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2936867ybk; Mon, 18 May 2020 11:32:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzNiGOyqGovPV2vSm14oqVoUK6UPHgka4FWx6SFR+47Hui18FzxZZgs+QV1AKLFB0VHKiR X-Received: by 2002:aa7:d1ce:: with SMTP id g14mr3463568edp.146.1589826732211; Mon, 18 May 2020 11:32:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589826732; cv=none; d=google.com; s=arc-20160816; b=QgGdJRVCP0A/mBu/VTZyCOYraM+bvGU8rS6vaVhZ+er13mhB2AR6rcaqtKmPtiB20D tylPNnPJ1ZTjjM8OcwlwpISsO6rsD+etn/GLvyXbrkeNznRq5Ki/MB7CbXWqFynAq69T NqPKKkYVCdtOqfPMtvDencm3NrZKtc+unehlXGlj8OPucXuMHmdKjB/vdk84aHHwnav2 Rn///mGSrpnJxsiysRHXbW9YfuYQV/xyNIgR+Um2l+DVGNGi2ffAX+zrWAAyMtKlShGC L7nQrLBNtLYfeHplON8/jebwpjodvNybFZrf9p6tyo1r9J4lbsdn5AkpyBt4L1IHJz2M wNwQ== 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=+bpi0JOoTNMVzMsKrwV7nzh2JT870OCQg0ANYoEK9xE=; b=IvDR3yoI3viHKKOcq4exNnUIr2q3mnqQ/OGUxGcopR7IzuBhpNwJdZnOSKTGMngUfc CbX9S3rE/Sd0QEIBngSQuQ44gAT6i5ona6tOBiNpaVZ6Vz9DdyPGCpCwwtN1/ydj6UNB KqqYcsKD34wAwV63961KM6LTpuz4ciIa+rCLk5SEgVLNBNjn/xzLjNQWmGRTMgMeBPC9 yGVeLRnwbwDrJ4APfdIgGqVTQ8l42/ZFOpnas3PVEgnvErWpSJXOgOYYxoc2G+I3D2/8 8hPiaQgBzL9FsSNoL8SDT+9Lkekaiq2cWQroZ8sKrA8b1+fH8mE0ZVZyVjcGdXN24Egc +MTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=M89gzHfe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ca26si6807296ejb.248.2020.05.18.11.31.49; Mon, 18 May 2020 11:32:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=M89gzHfe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387949AbgERS1v (ORCPT + 99 others); Mon, 18 May 2020 14:27:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:41402 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729610AbgERRnj (ORCPT ); Mon, 18 May 2020 13:43:39 -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 EA61F20873; Mon, 18 May 2020 17:43:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589823818; bh=pLKK1rWfKBUkBR8Z+9c0T7j+u/CPpMhUJDWsMDYB5aY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M89gzHfeQl9Rm3aG91iZT9R0f9iFPNE+qhl+itWAdXIIX7kyso2H9NxNWUAUZTpdL xGD7aPOgGmt2YXcZ0FITKf5mLVXQudVCYwtVWqjm23j3M9XAcuYRxoEtsom+W50++3 AxUnmp8zYhwGQ/4XhWDbKr9SNA5vZ0Tix1NGUREs= 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 4.9 48/90] cifs: Fix a race condition with cifs_echo_request Date: Mon, 18 May 2020 19:36:26 +0200 Message-Id: <20200518173500.990164419@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200518173450.930655662@linuxfoundation.org> References: <20200518173450.930655662@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 From: Ronnie Sahlberg [ 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 37c8cac86431f..3545b237187a8 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -551,10 +551,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 * ... @@ -563,9 +563,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