Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp424700pxb; Fri, 16 Apr 2021 08:55:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxIyVFMS97jKIjKdETu3rmuNqfgkVp1uZ3WjBkNm/weGCyLFnrXJ0WexZjfNjYcET7d4Jj X-Received: by 2002:a17:902:b601:b029:eb:1207:86ec with SMTP id b1-20020a170902b601b02900eb120786ecmr10031365pls.3.1618588525402; Fri, 16 Apr 2021 08:55:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618588525; cv=none; d=google.com; s=arc-20160816; b=UfesVYPPOx1FzGAL/1DVqRMjJgCHAFSw+hCclGLAuME09BE3vKaUEgqxDY8NfpdfPr qhWpDwZoz1bmz+ALHuXtp9ovCi6sEN5HG4ST6NMp6n341Zy1QxZg8xigmO3ze7dnUFKl wtaPr8PIYAmaQDrLt21TLChWekQl7mssFm+Acy+eY8r1dB3Q5zWBL7ACB/TysoAKXdqE kIEfuWjkMwqMRzByVGr0oRZz+jE2m8Fm5VfksAid3V16Sq+h4zbiXmO8d/e2i//+oHug 7Mkinyw3uzf6k6E9mo9bKWBb4o5A5pp2ghe49CjiPH3peX2nS2mexBCvLJk/EAywW+nX oKMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=qI9nOWnWg60l7KGoCvV4KEa7aircievLbwTS8bnfRVY=; b=hX51p2ZgNtiRgug7i5orMy2uyKyd2PxSIMfbHtu931cjLwbbqKykLfFebL9VbvkUU0 a1BgBHtW1nJL5T4ZQYTf4klUodYmuTt1DWi8PG4CduKXo6TUS9ivkVG4iejxwD7vFjaF P+/1wba6t5Bl0CZF1BoR0QkIYXtHMu0Mbyg/lyRv8ptsu3OODyv8gzNwZomeUeHli2wk CNTsoNHk1ZQ63NrDIJhH8599eIPbxqISSLjmhYzgSolxZb8qMS6SW5t9z5XAQ+rN22BD A1TCmjPYWAqLtPlQn1CRA2NpnUBYuD9gXGfN9zcUPjqS1VkfXXHpbcpuu5qrzYtXIb8P 36ug== ARC-Authentication-Results: i=1; mx.google.com; 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 cp7si7284020plb.389.2021.04.16.08.55.13; Fri, 16 Apr 2021 08:55:25 -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; 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 S244556AbhDPOT6 (ORCPT + 99 others); Fri, 16 Apr 2021 10:19:58 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:39402 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235724AbhDPOT5 (ORCPT ); Fri, 16 Apr 2021 10:19:57 -0400 Received: from ironmsg-lv-alpha.qualcomm.com ([10.47.202.13]) by alexa-out.qualcomm.com with ESMTP; 16 Apr 2021 07:19:32 -0700 X-QCInternal: smtphost Received: from ironmsg02-blr.qualcomm.com ([10.86.208.131]) by ironmsg-lv-alpha.qualcomm.com with ESMTP/TLS/AES256-SHA; 16 Apr 2021 07:19:30 -0700 X-QCInternal: smtphost Received: from hydcbspbld03.qualcomm.com ([10.242.221.48]) by ironmsg02-blr.qualcomm.com with ESMTP; 16 Apr 2021 19:49:16 +0530 Received: by hydcbspbld03.qualcomm.com (Postfix, from userid 2304101) id 375F8215B8; Fri, 16 Apr 2021 19:49:14 +0530 (IST) From: Pradeep P V K To: miklos@szeredi.hu Cc: stummala@codeaurora.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Pradeep P V K Subject: [PATCH V1] fuse: Set fuse request error upon fuse abort connection Date: Fri, 16 Apr 2021 19:49:12 +0530 Message-Id: <1618582752-26178-1-git-send-email-pragalla@codeaurora.org> X-Mailer: git-send-email 2.7.4 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is a minor race in setting the fuse out request error between fuse_abort_conn() and fuse_dev_do_read() as explained below. 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 The above scenario may cause Thread-1 request to add into fpq->io list after Thread-2 sets -ECONNABORTED err to all its requests in fpq->io list. This leaves Thread-1 request with unset err and this further misleads as a completed request without an err set upon request_end(). Handle this by setting the err appropriately. Signed-off-by: Pradeep P V K --- fs/fuse/dev.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index a5ceccc..102c56f 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -1283,6 +1283,7 @@ static ssize_t fuse_dev_do_read(struct fuse_dev *fud, struct file *file, clear_bit(FR_LOCKED, &req->flags); if (!fpq->connected) { err = fc->aborted ? -ECONNABORTED : -ENODEV; + req->out.h.error = err; goto out_end; } if (err) { -- 2.7.4