Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2718809pxv; Sun, 11 Jul 2021 23:43:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEjdc/lkfmhIn8ajTFKG+zIcPb1mV+myjRfv5XhmQzkm616KLpRCZOblap0BrLaF/u/obi X-Received: by 2002:a17:907:990f:: with SMTP id ka15mr51313536ejc.132.1626072209480; Sun, 11 Jul 2021 23:43:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626072209; cv=none; d=google.com; s=arc-20160816; b=CzB7vOWAQALpgI0p5yfWe6XNucUB1J0LMwhhsLCPbN/F2/kbCg8o7mQp3MjR1m9CYV F9ZHwuH6v1th1t/yPx9cE1vN55eEl50x/JaxEbOi4mR8dEY1PJzCD8SI/m/OCGFdi6mx ABBU0HrSsM/n9sVCWbb8LP1/w+nk+440QcPyKsz3UY0NsZ1pZ4BDa9ST23uyhPuFUCvc WzZS3N+dl0rk01OQYtLmdZ//D/tSZr13bCZot1NQSjb7eVJLKhQ3HgN1hix1lDNuYLr3 VYZ2lmFcuc7XzyE7rrkz0N9ev4VAUssku1tvtAGmx1Pto7lIxdkBeiZ0JG/jDdIeQ+kt mZDA== 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=La96ZOnLCuISoToF4U4Gkzb75zCo2cRrGyXrp0CuhB8=; b=rJsxFmwD+BgJ0ilni7NvOESLuwu7jdSfTcmIE3SURdqnHw9kLqLm1KnBXZDmgJn4OO nm+OxjCw7DsfpNsPsZSMwjjO/CtiqfNv1V35kEutTV89dadQW2YMz9akXoG8kx9XVpIv g5wj/OQu0s/cE5TCv8V9Fok2df7MTU3FRtXuE5LVBmsVVHZUjtMX4lCSp3dhU+Vq2GgI B3k0+ySd7RA7dZ+n8x3IjRTal+Gxjix5LbG/9SIs5oabaTJUvhbbsyEmhoAH6nxESQoN I744sFIqbbovXgzluucvAQNBEZP3tCRiQkoJIkGquO7ntqOutkBMS3CSPhXl1AMH5HFl gNbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YLhk1RnK; 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 t23si4659442eji.705.2021.07.11.23.43.07; Sun, 11 Jul 2021 23:43:29 -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=YLhk1RnK; 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 S238720AbhGLGoM (ORCPT + 99 others); Mon, 12 Jul 2021 02:44:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:55268 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237827AbhGLGey (ORCPT ); Mon, 12 Jul 2021 02:34:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4C0B961108; Mon, 12 Jul 2021 06:31:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071503; bh=QEY4HZx0PhNedxofWfACw2Z8kdb5dujA0Zr76nphuLY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YLhk1RnKy6T8ULmHIdWOixr6dyzo8b5mo5ZGGycne0H7V68VsGXuWcilIYnuKlb9l Jmm1WITuIEI4DzSjr5xptX6S3TQXqJjTQutytajlY6UeGygmWHxd01NkPJWtxJl64B RiqGmZ0jeNPjzIMHU+Ua3JxG0H7gotK/uXAQTAt8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pradeep P V K , Miklos Szeredi Subject: [PATCH 5.10 097/593] fuse: check connected before queueing on fpq->io Date: Mon, 12 Jul 2021 08:04:17 +0200 Message-Id: <20210712060853.884372276@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060843.180606720@linuxfoundation.org> References: <20210712060843.180606720@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: Miklos Szeredi commit 80ef08670d4c28a06a3de954bd350368780bcfef upstream. A request could end up on the fpq->io list after fuse_abort_conn() has reset fpq->connected and aborted requests on that list: Thread-1 Thread-2 ======== ======== ->fuse_simple_request() ->shutdown ->__fuse_request_send() ->queue_request() ->fuse_abort_conn() ->fuse_dev_do_read() ->acquire(fpq->lock) ->wait_for(fpq->lock) ->set err to all req's in fpq->io ->release(fpq->lock) ->acquire(fpq->lock) ->add req to fpq->io After the userspace copy is done the request will be ended, but req->out.h.error will remain uninitialized. Also the copy might block despite being already aborted. Fix both issues by not allowing the request to be queued on the fpq->io list after fuse_abort_conn() has processed this list. Reported-by: Pradeep P V K Fixes: fd22d62ed0c3 ("fuse: no fc->lock for iqueue parts") Cc: # v4.2 Signed-off-by: Miklos Szeredi Signed-off-by: Greg Kroah-Hartman --- fs/fuse/dev.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -1276,6 +1276,15 @@ static ssize_t fuse_dev_do_read(struct f goto restart; } spin_lock(&fpq->lock); + /* + * Must not put request on fpq->io queue after having been shut down by + * fuse_abort_conn() + */ + if (!fpq->connected) { + req->out.h.error = err = -ECONNABORTED; + goto out_end; + + } list_add(&req->list, &fpq->io); spin_unlock(&fpq->lock); cs->req = req;