Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1876842pxb; Mon, 13 Sep 2021 07:22:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKiK5eitNC80RRtCWpIthMdfTKMHMZB3+fZUwVFHh/NFPLAJGXNUuMXRQ+d1c4ukvLTS1K X-Received: by 2002:a02:7117:: with SMTP id n23mr5529651jac.143.1631542877159; Mon, 13 Sep 2021 07:21:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631542877; cv=none; d=google.com; s=arc-20160816; b=gK5eJC9VPGb02yjKwNPncLqs2kEF4KxraJWEQNryn4z8JFpY27/PR4RkTC/n5Ay3LW 1UFGZp6QtEa7WS/WNqFHW5AQ8Xl8FatyupWITxorz0WAStA45IMDTLaiVCPvR6eDDSha 3HGCrn4pGNTkUNrEC3/PqRiB0fZxKRjozwBVatUs8bq4soxtUXMSsrfd/5pEaoWCbIIk RzllaDrJHz6xH6rCB6cClCXYG+sLU6xSOwFaoDyNd4BeNofwV82iZ6sPJ1SkxuFlnDtt RZ4uwMiwkKEzPH2ZofD6rtzmRvTNTYwQHqCmS0WrSb5O9FEvmOhDWV1dfVdWMFg112P+ Yq+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+KcGypgo3wHPfpxpQ0mUiskP2vmtMNSF3eB65opv4dM=; b=GFKW/3PLBoMhKl9Ac4oXcDLgFILDHxxgi4uxbz/92aUM3NzuXTxYBrRI6+gK4pk90x p/lhxBcu/strQvFoHzChYzOu505Bv7atSUw0irU7xEzQF6rM7j0PyXXdOnVxxxW5EVSf Jaly1ym2W0dp/EAdkjIG8LsuwLHm3HzcGLhDix7M3H++gSPtAae/2tc8dHNjgYVLpt+1 11OV83yq9p8CJ+viYd0+6yjtFILQzQMouajppPrrzguGDxloh4KWZPoTg01+MAonuUkj +7jFt1akJy5mk4fx5cldSaypOpCTLbSdNe28gpS2ro1ifqKLWhhHijVDmIeP3Mb/Lx6c EV7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=okTVUmS1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a2si6245740ilf.15.2021.09.13.07.21.03; Mon, 13 Sep 2021 07:21:17 -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=@linuxfoundation.org header.s=korg header.b=okTVUmS1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345379AbhIMOTi (ORCPT + 99 others); Mon, 13 Sep 2021 10:19:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:37396 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345030AbhIMOOt (ORCPT ); Mon, 13 Sep 2021 10:14:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 605FE61414; Mon, 13 Sep 2021 13:43:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631540634; bh=zmLb3zZasJWMktiL2sQcWc9wmYJF4uFDv5WFh/069H4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=okTVUmS1nmjbN2o7sYgQVSR1n0MUrHaTd3UTFa3F18Dg6YaCQRCAcLyApvcYPrVmW oFKAeUsBka4wNNAdF8NqDmHTwKCiTMFHGlA6eS1qs9tK/32fIh46p4ymmK9UzKAA9Z Rof5Zcoz4VbO5jPVh9Ji8jyY7YhUAzBeTDlpabAo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiaoli Feng , Ronnie Sahlberg , Steve French Subject: [PATCH 5.13 274/300] cifs: Do not leak EDEADLK to dgetents64 for STATUS_USER_SESSION_DELETED Date: Mon, 13 Sep 2021 15:15:35 +0200 Message-Id: <20210913131118.590524008@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131109.253835823@linuxfoundation.org> References: <20210913131109.253835823@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ronnie Sahlberg commit 3998f0b8bc49ec784990971dc1f16bf367b19078 upstream. RHBZ: 1994393 If we hit a STATUS_USER_SESSION_DELETED for the Create part in the Create/QueryDirectory compound that starts a directory scan we will leak EDEADLK back to userspace and surprise glibc and the application. Pick this up initiate_cifs_search() and retry a small number of tries before we return an error to userspace. Cc: stable@vger.kernel.org Reported-by: Xiaoli Feng Signed-off-by: Ronnie Sahlberg Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman --- fs/cifs/readdir.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) --- a/fs/cifs/readdir.c +++ b/fs/cifs/readdir.c @@ -381,7 +381,7 @@ int get_symlink_reparse_path(char *full_ */ static int -initiate_cifs_search(const unsigned int xid, struct file *file, +_initiate_cifs_search(const unsigned int xid, struct file *file, const char *full_path) { __u16 search_flags; @@ -463,6 +463,27 @@ error_exit: return rc; } +static int +initiate_cifs_search(const unsigned int xid, struct file *file, + const char *full_path) +{ + int rc, retry_count = 0; + + do { + rc = _initiate_cifs_search(xid, file, full_path); + /* + * If we don't have enough credits to start reading the + * directory just try again after short wait. + */ + if (rc != -EDEADLK) + break; + + usleep_range(512, 2048); + } while (retry_count++ < 5); + + return rc; +} + /* return length of unicode string in bytes */ static int cifs_unicode_bytelen(const char *str) {