Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp694404ybh; Tue, 10 Mar 2020 06:36:25 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtccHCAgMSjpoOb0ncand48BqgqU018oOmvPwfzy3kJSh+P9DkaoQYN/qKV6I5XjfAblbwl X-Received: by 2002:a54:4892:: with SMTP id r18mr1177332oic.81.1583847385580; Tue, 10 Mar 2020 06:36:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583847385; cv=none; d=google.com; s=arc-20160816; b=X7QGiKLJTFqRKqFDH7+pGerWhepD2NMJ+Kt1PzEeB7vjNH0fvIDJzstWgehRk9cO36 8+aeX1WNWxs3DgOa3mLQh1O1a1uKz8CIEqAIRvpNlZLZgCAUvUBDYmis+ZpXNq8l1VSv aZJkTs7eAqeUBibrVtFkYzugCf6ganNVIcGNqp8k/6S7nC6H0tSXJRFCHiCsfX7U4akK hBH/v4bKqSZMdi24QozCWt9rb85idka4go/oatHdSACTUjuAk161LdOiEoV7SiZCW5GL UJC7nDOfp2kSNIQiVd4cHOLnrcrXOtF1TEkv9fPsdQAGXz+cHy+ZicFpu7eWqS9jjkHu FQyw== 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=KiHsaASFQJ72ZCushGrsJNDBAbcoAVQGAbnyYWGE1nM=; b=Pq7n2oQommpq0t6efGk2hsV7XRs/FZ3xJOpLJKa9iVi1PaN2IWAmKCTpvuZvpRU5V/ CT7YE8P4fxpeCF5W+/xtvEfG6RQN1er9KQDZ6EAKfp8J9l9fGFJB5gWRImN8X4+09TZ9 b5QoeaEKdm+b/w6KBleCtq/Ws5V0ko4pVKDqDIPcIMGe/gi/J1TQ2BuH7fByJUHKBH7O R8dOVuCYIZqwsBhFWLaj07jtBhBW1NoTbyuNO5pFdN6zhhDVWDMJxxL8Y4Qr/iqUD5md h2GYKJS77gw/M5L0FBK0o4ECkci4jpGDifb9qtblbosSi4cHVIv6Xq9yTrFJzLEygZ8x 3YlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="J/xd067E"; 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 l8si8276834otk.285.2020.03.10.06.36.09; Tue, 10 Mar 2020 06:36:25 -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="J/xd067E"; 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 S1728023AbgCJMqd (ORCPT + 99 others); Tue, 10 Mar 2020 08:46:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:49808 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726847AbgCJMqc (ORCPT ); Tue, 10 Mar 2020 08:46:32 -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 20A392468D; Tue, 10 Mar 2020 12:46:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583844391; bh=ewhqRxtaE9Vq08pfP77RGCsTISd7n1fBGBXrjGoNLZc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J/xd067Eq2WGUL75t0iuWmqR5HfM0M8nUDY8rnRCBzC/NZOlneiNziTACQr8hJPq5 mJRZJoXx5/V3lLlWgh/Z0cOtrX3YI+kUV3aOR/pbpCQemob2VbLfxrW1FwEUB4hNLW b3XnjEkTI2IE/8NSUcA3RMS9GNS+lID02tHrUPQs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ronnie Sahlberg , Steve French , Pavel Shilovsky , Aurelien Aptel Subject: [PATCH 4.9 63/88] cifs: dont leak -EAGAIN for stat() during reconnect Date: Tue, 10 Mar 2020 13:39:11 +0100 Message-Id: <20200310123622.064771415@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200310123606.543939933@linuxfoundation.org> References: <20200310123606.543939933@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 commit fc513fac56e1b626ae48a74d7551d9c35c50129e upstream. If from cifs_revalidate_dentry_attr() the SMB2/QUERY_INFO call fails with an error, such as STATUS_SESSION_EXPIRED, causing the session to be reconnected it is possible we will leak -EAGAIN back to the application even for system calls such as stat() where this is not a valid error. Fix this by re-trying the operation from within cifs_revalidate_dentry_attr() if cifs_get_inode_info*() returns -EAGAIN. This fixes stat() and possibly also other system calls that uses cifs_revalidate_dentry*(). Signed-off-by: Ronnie Sahlberg Signed-off-by: Steve French Reviewed-by: Pavel Shilovsky Reviewed-by: Aurelien Aptel CC: Stable Signed-off-by: Greg Kroah-Hartman --- fs/cifs/inode.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -1990,6 +1990,7 @@ int cifs_revalidate_dentry_attr(struct d struct inode *inode = d_inode(dentry); struct super_block *sb = dentry->d_sb; char *full_path = NULL; + int count = 0; if (inode == NULL) return -ENOENT; @@ -2011,15 +2012,18 @@ int cifs_revalidate_dentry_attr(struct d full_path, inode, inode->i_count.counter, dentry, cifs_get_time(dentry), jiffies); +again: if (cifs_sb_master_tcon(CIFS_SB(sb))->unix_ext) rc = cifs_get_inode_info_unix(&inode, full_path, sb, xid); else rc = cifs_get_inode_info(&inode, full_path, NULL, sb, xid, NULL); - + if (rc == -EAGAIN && count++ < 10) + goto again; out: kfree(full_path); free_xid(xid); + return rc; }