Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1906833pxb; Mon, 13 Sep 2021 07:56:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/XQ8d/AAXyYr2IE+J46h3f+DcSk9EcM+hQe1CzLuVZSwld3/F2dLh9OpSXutHu8IhXVeI X-Received: by 2002:aa7:dc19:: with SMTP id b25mr13859403edu.23.1631545013688; Mon, 13 Sep 2021 07:56:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631545013; cv=none; d=google.com; s=arc-20160816; b=v22FrKcHLOoY8dR+v7MRhfh+dFYg910yTSA04YMHXRS6zIqiidDqMcQY06TfoeUP/X ZKTYMhyOARFvGh5WuAPJ1bzCLbOZtc2j4PgwttcOpsxbt/wOBV2Y0qwKHNCUbJBXStLZ MWAs0lCbGkIh5ZMgNZkHYv1iGpGX0SMq/giojJRXS+X3w3xJvE3rt5zUm0sj6zdcmp87 pVgrmRDDe6aKS52j78qYgroON2jABJQqGHPFjKV8yb4k3iiK9emgSU7w4dI7py6rOZj9 yFob4jfBYceoNURH/ZpIpDRhAk632e0Xcl3Vs3FBFoS3jWCZWqQWyaPRW29PxLI0s2WM hJ7g== 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=W2+NH7taG7OXY+xXOITHaHF+M08367kSqkMtl/Rszho=; b=LhMaRxBn2tD0BxcaVa2N3tj07nA+0m9nw5CW292wIrOrPDbPG84eLF8QpjdnWpTuim HsP6L4msNAiV05TmMtssoCRsFm+fApDf34CqtoD6csi9b+zA9xW75DNZwvYkAL0b7rnf 0I2sBXfq6djfSznTue0fI1po5PADf/u4fGvCnyUP7IcVRwC31XucQJVSsKJygkFQ68Wt NbXLvhfcn7FrAha/biwks1MqRBMM7ME5IMlx6xYcH9EeEVBafxX848VKLzkpR6LDZjEv giFolBkRXaDY/ft1fNV72kCaj9TQ30xcl5OwfOrdkjIXfylPqXzXiknofag3Zp1nbj6I Gefw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yAxLZreh; 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 w10si7437082ejf.364.2021.09.13.07.56.29; Mon, 13 Sep 2021 07:56:53 -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=yAxLZreh; 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 S1346586AbhIMOxd (ORCPT + 99 others); Mon, 13 Sep 2021 10:53:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:39254 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346099AbhIMOrU (ORCPT ); Mon, 13 Sep 2021 10:47:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 535EE6323E; Mon, 13 Sep 2021 13:59:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631541554; bh=JGtyvFusl+H8klQABYldTExrZ9rGErbrO7in6R3WAmI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yAxLZrehvsygXfFi9ilrm81q7glF/44/gl6ju2IUO0JNcOHjeDHK8FB0kP7XvNvgB CJJi4CMdnRntJdy517zg6wiJsQ4ppviVjvD+hcb1llNIlXIkyFk3UuAGFE6fy0RBe0 FJ9/eyIuFvhy7FXT9m/79FQWt5qPqtmW+vK76PrY= 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.14 306/334] cifs: Do not leak EDEADLK to dgetents64 for STATUS_USER_SESSION_DELETED Date: Mon, 13 Sep 2021 15:16:00 +0200 Message-Id: <20210913131123.762721637@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131113.390368911@linuxfoundation.org> References: <20210913131113.390368911@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 @@ -369,7 +369,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; @@ -451,6 +451,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) {