Received: by 2002:a17:90a:bc8d:0:0:0:0 with SMTP id x13csp1573734pjr; Mon, 18 May 2020 16:47:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfzvkEoB3WCgM9UhfmAEE25bmWHhGxXCXsyuLNL8C8087CgvfhA0Sif+dvebP5jNsIegli X-Received: by 2002:a50:da06:: with SMTP id z6mr14704630edj.372.1589845620495; Mon, 18 May 2020 16:47:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589845620; cv=none; d=google.com; s=arc-20160816; b=K9reC11AG8Jca+uKD18O5PjklEzOVv4SO0D0p36eDalkmjR8uumOgnOQYVdpL20ogK G5gZtSItwUoyo5cYbrxcLAQOvPwAkH7nERwoWolGnJZZspFO+b0SNvHF4APQqSGNt5cy DpoFoGXgeRnplBfFyb9c6ZUyGdl7nh0IZ/933ZqlUpsX/G/BSls5SV1l10DBsSyKsdY2 ppfTae0al4ZcJN8MH7hwLNsvbkiJPHzZxBO2xyJhKiSy93ijiObvpImSH8XlaD/qBd1d vKRSRXo1tuW9MtAG45yCnDHG+tAnkCSB1mOssjA2W8xwGE46DHIFYothuoROOzqrt0+c Dl1Q== 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=RPbwfNgdwaJW2Yp+ybIS8JL7u1AFVa1Ym4ge8wgdhG8=; b=VTdfm+ORdNRQAmokSl1NnxkLjQkk2WidIMWh3z4uF8zqRX6fzd8l60dpVN0BF917BJ nLS6IyodV8QM9OPa+BvGy7axmbUCu1rxOjUuoA39RdTpbuNIdk/trS9m4RD6iesHRSLi YBJzZfOOkS6v+E63Cxu8a4X1tC7EGlHfup1DdM/tdac63M/j1l4K/DOcMHXCj02R/rkR LPKng1Ad35ccpFG/5VjWnvpMCwLcZUbjKax6jdq8BbSCWp8mNkh9TnCWHI3oL5k9Ou/I 6MJRsi75HFUNuE0aCmTkY5dxkNLP1x34XfALVqbQPqJHIjo9P23Bcj5HM7OW2lwDH0rq cLaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uxXbeUom; 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 j2si7170153edd.36.2020.05.18.16.46.38; Mon, 18 May 2020 16:47:00 -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=uxXbeUom; 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 S1733261AbgERSUc (ORCPT + 99 others); Mon, 18 May 2020 14:20:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:56280 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729761AbgERRwq (ORCPT ); Mon, 18 May 2020 13:52:46 -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 E00A9207F5; Mon, 18 May 2020 17:52:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589824366; bh=yrAxux62RVSsRCz4EE8zavy7cKRxl0L7f3iPoXjbJqQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uxXbeUomTWkCYGWy2feLzLDNlzNoa/tI9vtPX194MTGXFV1GbOt6Or791kJ36GdVs CI0D2HSAJTlNxiT5T/H58OzVsFtkJIrv9Xvyvo9x411RszR77hjVXaApFz77xydrk1 +8J0gR6Zy1CYYl/BHRg/smwdUe/cTFWEkSFoeAv4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adam McCoy , Steve French , Pavel Shilovsky Subject: [PATCH 4.19 62/80] cifs: fix leaked reference on requeued write Date: Mon, 18 May 2020 19:37:20 +0200 Message-Id: <20200518173502.930083151@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200518173450.097837707@linuxfoundation.org> References: <20200518173450.097837707@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: Adam McCoy commit a48137996063d22ffba77e077425f49873856ca5 upstream. Failed async writes that are requeued may not clean up a refcount on the file, which can result in a leaked open. This scenario arises very reliably when using persistent handles and a reconnect occurs while writing. cifs_writev_requeue only releases the reference if the write fails (rc != 0). The server->ops->async_writev operation will take its own reference, so the initial reference can always be released. Signed-off-by: Adam McCoy Signed-off-by: Steve French CC: Stable Reviewed-by: Pavel Shilovsky Signed-off-by: Greg Kroah-Hartman --- fs/cifs/cifssmb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -2051,8 +2051,8 @@ cifs_writev_requeue(struct cifs_writedat } } + kref_put(&wdata2->refcount, cifs_writedata_release); if (rc) { - kref_put(&wdata2->refcount, cifs_writedata_release); if (is_retryable_error(rc)) continue; i += nr_pages;