Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3547512pxj; Mon, 21 Jun 2021 00:50:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZ39/0rYAk5f8w6R6aTTp0giFXVN5ZKJspnC47fNgFtocwFsYHNQsNBKCl7cZ+8nwkI6Wy X-Received: by 2002:a05:6402:50d2:: with SMTP id h18mr18673261edb.384.1624261808536; Mon, 21 Jun 2021 00:50:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624261808; cv=none; d=google.com; s=arc-20160816; b=R3n8xIaZCAMHyaKgQEQ+kCux51/yqzL9DraJFR75zt85q7R7VNmVSYI/8KX9Y8OVtd npNtQeUVxNYbFTVecs4D6FPE4JWeHHdFlH6sAr5nPv2m0vtmGBPZS8e+p2gheei9lPSz JKSIUFtqLUmqGZZl2Xho8GFexpQslT4DeXPHVPvF3Wzh9q1afdyXmx0lphFIvY3dO22e S31aH3hDCGeVVQpAvtcGcaPouMoEALvxlQlem0GN9NwRl+0167qRV4uke5+7SvDaPs8M UMVMsblftZW+JgaYCVNNB6ctAzAOfy4qll9PX/sko3oHAx1fLQg2vIookzPFtZfWWehy xWjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=B+3nVzY+A+yS0flLb0aI3OtB+R+qY6lENuass8lUP0s=; b=fXNi1PjPM1ZZxcB70dfowkAT4NvU6074nZTP+QYcmlbUpVc+Actkzv7LVbeoXAOEPb 5KsfP/UNhpE6S8V32ScTtvHV869Z/JM8g7upbEkiwgPec5DanE/9f46M3HdDl6hLBKNP aQrsoNQVMxWSN+/nsn3HiaH/GVQ4ng/BrVhrWd4WkLAFfBJkas2ZIFmNYpD6E4qPVaQY Fte63XgVNL3xm5vHagXP/oLOxe7vNMUogLjgjhJtxxlh4KgjE1s1UiLqJ8mR7M6O0UN1 9ikkgrC78jHgW56F6rl1CL9sAhcmw5UozuAP2qdigz8gl7GyK57TTs5kBvgOzODOtEkK l7tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=pCfdWjHB; 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 f15si1269732edd.563.2021.06.21.00.49.45; Mon, 21 Jun 2021 00:50:08 -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=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=pCfdWjHB; 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 S229905AbhFUHvE (ORCPT + 99 others); Mon, 21 Jun 2021 03:51:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229621AbhFUHvD (ORCPT ); Mon, 21 Jun 2021 03:51:03 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0ACEAC061574 for ; Mon, 21 Jun 2021 00:48:50 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id y7so18380800wrh.7 for ; Mon, 21 Jun 2021 00:48:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=B+3nVzY+A+yS0flLb0aI3OtB+R+qY6lENuass8lUP0s=; b=pCfdWjHBStJoBNJ03nESo/gmOCXuo7I7UpHcNfI+jjdN+mbVNglwqjbQSVwgxiKdgp X1I213X8ek79cNJz9yoYL+R+KBUqL5TVIjSjxpxsMKFOGfmeUkucwoO87ARFDY310HED 9loNoUsZ9V+PE+LTNkqHTr0Hwd+Ksde+egOWc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=B+3nVzY+A+yS0flLb0aI3OtB+R+qY6lENuass8lUP0s=; b=QUfo0oX1QoPttNUuoqjPHlr2CtMopuMnIHQglDfjAehyqPoPaTOK0bXyjK052d6UJH BbNBtOJy+mWKee4/pz3SgWEuBobc9Y8tqvGJORaIG8TOTcRf95wD7acjEgvWMu9118zd PFR+r88OLWSpnubP9+tw1Egkb3BBwsLslvCcoY64YavLkHlgBM+mTxgEDePAiRuHZTh1 ++dCBZwPjtmFeTVmQa/bJjE+1c5xU5E/RmvTkvus2A066ld6CJx1zOeuPse7eGt4JJIL gTzRpHRNTQG9t4teDsnuxTYqqhbOtiRQinDhh7p5Iz7Zm4JU+VADEwYsGCBkz5O7C/R5 NF7g== X-Gm-Message-State: AOAM531oF7XCWNfhCv4IhDenksRkZH4e2BrgGLCfCMhYcC0fRdlVM0G6 v0jI541hfIH73Ju3QUFGUQJR7Q== X-Received: by 2002:adf:eb82:: with SMTP id t2mr26701649wrn.337.1624261728564; Mon, 21 Jun 2021 00:48:48 -0700 (PDT) Received: from miu.piliscsaba.redhat.com (catv-86-101-169-67.catv.broadband.hu. [86.101.169.67]) by smtp.gmail.com with ESMTPSA id h15sm16564269wrq.88.2021.06.21.00.48.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 00:48:48 -0700 (PDT) Date: Mon, 21 Jun 2021 09:48:45 +0200 From: Miklos Szeredi To: Pradeep P V K Cc: stummala@codeaurora.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH V1] fuse: Set fuse request error upon fuse abort connection Message-ID: References: <1618582752-26178-1-git-send-email-pragalla@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1618582752-26178-1-git-send-email-pragalla@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 16, 2021 at 07:49:12PM +0530, Pradeep P V K wrote: > 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. The fix looks good, but still allows the request to block during the copy phase after being aborted, which the FR_LOCKED/FR_ABORT bits are meant to prevent. Here's an updated fix. It does not allow the request to be queued on the fpq->io list after fuse_abort_conn() has aborted requests on that list. Can you verify that it fixes the race you reported? Thanks, Miklos --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -1272,6 +1272,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;