Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4304560pxu; Tue, 1 Dec 2020 01:23:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJzKbpm1UciiOa1H5lh0ihrauQz14mQkAdoEbe+N/EcjRhvr+2lM5q5z7yW5NYnxR7TJUjgq X-Received: by 2002:a50:ed8d:: with SMTP id h13mr2030302edr.180.1606814606339; Tue, 01 Dec 2020 01:23:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606814606; cv=none; d=google.com; s=arc-20160816; b=tOpydPo4/L9TbXkLxq+Us1iY9v3N5DE/2q+ZGu6irfGjfBam53dcywMTwaM59N/Yxu cmZ97yeVm/1slo1kaJFljzlvuK6YfF6M3IYa0bcxlldAtf3sczkI8GkNbcqZEyKgJrWX OA6bcBewOBTVDk6SEIaNx+gH9vz9cVqGmaAaAAJvSskBY4VniUebdSa9E+PWt/7lEg1v kKXorDGAJ3hEdy/pVSOIb/vbK4nVH6SKclIgzeXu8+6kwmbtKnsrbzHDpCOLCpjFWeM+ X36PfBmJPPZDgC5KNMKmoPnUu8iA54cI2+WF98rZPGVxy3GmBdI7qpBOXXKv5RbNwILx Z0xg== 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=Sxa4ujDJ9r757uWM+rjSmA9AEEx85TSJoDLT8hn3MVQ=; b=hDs/8nrciQ7a2v/ZXGide3ncTaq4V0F1fHXE9DbuZzHqBOcJDC99wuqmdKhyL5SPDW iqHxSxNHewtZBWTAfCbfzMWm2sk+ftB2PY15IMKO8SZjfMwJTcRDP45+2DLh1PxH9WLv LzaYsmvbG+SNHLaiV06GM3HS4Sd8N6vQ/ZFaFTu5hE+xFfMi02J1oVQi7Zj0xNESwUlC Gmf7FDDq/dsTVsrpbXXpEb5kvjiysgvzBCxMVE5ptkJIn0gv7C561jZ3RG7vmT/oivoT 0apNJQZQRzuLEq5ajqLVI/onUqw4NyA9JAXtheRcHh6bO5V25X7+DgrnzD6gpERDMHvH /AqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DlPLFZbj; 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 gz14si589691ejb.630.2020.12.01.01.23.03; Tue, 01 Dec 2020 01:23:26 -0800 (PST) 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=DlPLFZbj; 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 S2390770AbgLAJTn (ORCPT + 99 others); Tue, 1 Dec 2020 04:19:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:47564 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389607AbgLAJJ5 (ORCPT ); Tue, 1 Dec 2020 04:09:57 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 ABC3C221FD; Tue, 1 Dec 2020 09:09:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606813757; bh=cRe5mJBKoQHBJb+J5qMIuqEBsxPrftHbP3xrSHAiY0E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DlPLFZbjNOGYjVVdFs97zewP85+Vqs04uKZmeg37074KGZwp+85VMic3sjo79Kakj rE0heoSF5EqDX/ovQ8kzKFB0T2AlgiSe1rXOeNXVNJiCIVWOGmN1h82PWRPUwF69gh wGkhNEwbcgRP7I3tfnp+qJZhr/76s/WCAwXrE57c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rohith Surabattula , Pavel Shilovsky , Steve French Subject: [PATCH 5.9 018/152] smb3: Handle error case during offload read path Date: Tue, 1 Dec 2020 09:52:13 +0100 Message-Id: <20201201084714.265683626@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201084711.707195422@linuxfoundation.org> References: <20201201084711.707195422@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: Rohith Surabattula commit 1254100030b3377e8302f9c75090ab191d73ee7c upstream. Mid callback needs to be called only when valid data is read into pages. These patches address a problem found during decryption offload: CIFS: VFS: trying to dequeue a deleted mid that could cause a refcount use after free: Workqueue: smb3decryptd smb2_decrypt_offload [cifs] Signed-off-by: Rohith Surabattula Reviewed-by: Pavel Shilovsky CC: Stable #5.4+ Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman --- fs/cifs/smb2ops.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -4415,7 +4415,25 @@ static void smb2_decrypt_offload(struct dw->server->vals->read_rsp_size, dw->ppages, dw->npages, dw->len, true); - mid->callback(mid); + if (rc >= 0) { +#ifdef CONFIG_CIFS_STATS2 + mid->when_received = jiffies; +#endif + mid->callback(mid); + } else { + spin_lock(&GlobalMid_Lock); + if (dw->server->tcpStatus == CifsNeedReconnect) { + mid->mid_state = MID_RETRY_NEEDED; + spin_unlock(&GlobalMid_Lock); + mid->callback(mid); + } else { + mid->mid_state = MID_REQUEST_SUBMITTED; + mid->mid_flags &= ~(MID_DELETED); + list_add_tail(&mid->qhead, + &dw->server->pending_mid_q); + spin_unlock(&GlobalMid_Lock); + } + } cifs_mid_q_entry_release(mid); }