From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0D37C10F27 for ; Tue, 10 Mar 2020 12:42:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 938072469D for ; Tue, 10 Mar 2020 12:42:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583844164; bh=SQ2MaxiEeeggYa8Al9n/ttmWC3FChj2NL+dGYfBYCuY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=wpE6z1VqkmcnA2H/dwK0P+/PQvtj4iVZYDs+UJXP6gcffpe/ec+rJooXt1FOLym1h jBa96jA4TRz3zKio6sVFMy6SEyMQ0N98Q4s+foGLTOXmsOJxO4iBmsuXXWC14PoS5S jgNy67eKs416/EENqowSMQJ3wrOQkIAHJTQvD1r8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727401AbgCJMmh (ORCPT ); Tue, 10 Mar 2020 08:42:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:42666 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726729AbgCJMmh (ORCPT ); Tue, 10 Mar 2020 08:42:37 -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 723E224691; Tue, 10 Mar 2020 12:42:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583844157; bh=SQ2MaxiEeeggYa8Al9n/ttmWC3FChj2NL+dGYfBYCuY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YsYjpZ6MD3mXXJwXz99lIpwxCn2blAhxl+48XbtJ+DNTKt8Djwu3S0IsZzyBeRGJe 30y2X7zN6017r4tY5ecgpikqKH3e+B6upw5/8urQP3OJ/0sW4jiAm9zpImWrwSu0XH UbTjwjUezHHdE84aDdZcRj0MXEPWB1wRYsWUn7jo= 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.4 50/72] cifs: dont leak -EAGAIN for stat() during reconnect Date: Tue, 10 Mar 2020 13:39:03 +0100 Message-Id: <20200310123613.706021327@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200310123601.053680753@linuxfoundation.org> References: <20200310123601.053680753@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 @@ -1957,6 +1957,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; @@ -1978,15 +1979,18 @@ int cifs_revalidate_dentry_attr(struct d full_path, inode, inode->i_count.counter, dentry, dentry->d_time, 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; }