From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796049459; b=k3IdYjPxXLXNLAquScLI87gl96/4DG0uZXKZi8AJjQ8sgDapTGG+IdgAHfBwQ442+7o0 xZOvmdv86ImXZUYvLuHU9B4+fdrqkMKmnePwDAdZUMV33IQ6YXQBYAMU2QMBuQTIVUZur qHh3rtjWzEb3tDY4kQ1AbvY4Iqafz0e6Y5kUAwg8fG+Ae0SgXnD9XJO1qZkHG2GPI5Y2g HEfOAhzeJEHFZPEz//QoTfX+flV8/MHZLAfTooB/q/t2462oMSo51fFsHRcNIrOLb3T1L IYbAfJnhDzyPtsIUcuvnoxcRrI6qsbcL6q1sRyCiUDEvEW9weWarU6s3fOTMh6QnmJg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796049459; h=DMARC-Filter:DKIM-Signature:X-MC-Rep:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received: X-Received:Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:X-Mimecast-Spam-Score: X-Mimecast-MFC-PROC-ID:X-Mimecast-Originator: Content-Transfer-Encoding:content-type; bh=YMtn23cPSjwohaR+qdTwIVB0MrBuoBWTZnklOfs8KQw=; b=Rfvz0LDnJfRqmvh9+g/hgLEhAb6Dt3MjAjLq1WbaLsZtVvu4I8qhSgCFO55HS0RMTIHA hiC/5skhky8istIOPfAb0vzS/uB2lCWeq6S+uRvIAEOagncE758tQlp8WvU58xhT9tLqK UReej2dSuKAqNIR7pFsjuY0AMqszxa1IMsbNWjU+KpWWDLAkdwlHGSCFwx1rKKUY5ufqS cDDJlYK+NzbMNAe030TUgRu5g1r7GfDLKTB/IkZtMUnA87M0//7VmSywenBgEDsmvcGJm YBA8swnvI3Os62xT/BQKMpS+nh2gnb9em4WBlnpspm0i4MO1dJKVIIJ7iuYcBD2BODQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=d75sSlzt; arc=none smtp.remote-ip=170.10.129.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 285F5606A68F for ; Mon, 30 Nov 2026 14:37:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 285F5606A68F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=d75sSlzt DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796049458; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YMtn23cPSjwohaR+qdTwIVB0MrBuoBWTZnklOfs8KQw=; b=d75sSlztHyif6uDPUT9/ElTMsdqxfMLEFA/ZwsltjiZM14kRwc0VdpTO80GYfoVlAiz7fs uwtbPXzzw4UJf3mxTXipY3fe5wkdEeEtiDL2pTnuoz7hCPWJRSdT5aPN47dVmnhToRDJKL fq0c/G/ZXtyvxdinRtE8isIO8vd8WDg= X-MC-Rep: binary re single Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-85-4HHDNU6fOMGaqVrRNY2WRQ-1; Mon, 30 Nov 2026 14:37:35 +0000 X-MC-Unique: 4HHDNU6fOMGaqVrRNY2WRQ-1 X-Mimecast-MFC-AGG-ID: 4HHDNU6fOMGaqVrRNY2WRQ_1796049454 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-49d70f45b22so6718766f8f.2 for ; Mon, 30 Nov 2026 06:37:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796049454; x=1796654254; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=YMtn23cPSjwohaR+qdTwIVB0MrBuoBWTZnklOfs8KQw=; b=jGBGtTTwbfVuI7S2ie8C0D2KSeiMoh+tzekAo1cs5JFpHfLTTKOQQYEpTDtV23Oo2F feF1mDX29xGwTulUVehIs2AR0bP4QNtzU8CySE7yGGKvk5+w3kS2kIrXfZ0ImxoitkJ6 bJ3o2ZNVoBcitqJidnNUQDVeMM6bgG8NjDBof4dLJQi6gilaDL5c/bvKLQBvzKBbElsk BkzISlUDviCS8ozL7wfn1t6kTrtB5uZOClHpqkTwBvr/HuogVs9Q2sNmJh2ap6f/lsC1 wUj5azy7D/f+ejTo8E6Fmg5IsasvFQljxO6D4d8Gkv1sUYKq5Em3q6/xu/OmWWJN9C7q qCMg== X-Forwarded-Encrypted: i=1; AL+hErE1DE4Q32Kcr0wEZRYn6PlDw+kcpD2SSZnJt+52r6QV7k1iUZe4rwCuBxHRvxZfxY1dIpWpn5OYg5HoMzVfvg==@lists.linux.dev X-Gm-Message-State: APuU4Z8GknU0X/SBwaI8eX3pTeG83Ib4rS3jGrNXaB0e51oQRSARoEUd yE/+sA8Wy+tNfGkXWVqD61U87xD95Poz/k4NsmJ7OPt1EOkgnFdaaYAo6NNeIoMP7C3OrLCIHcN 6Q4XyIL1pqsdbv7T+FHDDSC9gvHF3NwGIjNyrBxo7eFAEL9ph24GYyWlBnYAc98re62/u X-Gm-Gg: AZFdTZd/4qAHolSFJ/Wkaudm8POOsalou73EsgAFTq6yNQmw1FYSSrI+udsqwCgt4BL wo+dn9Lg9TYIPwoNl2C8fyehSKU/eOg06zvOLYp9CJwghiPq2ipX9cyMtMzfIhtD0aL+mAzl0lX HjKqkqR6ZPZRxSA3v4pCgAydb/ZS7T7TvxZi1Xlbz6LTvK710/k6bTIRrwCaxV4k7O6OWklZeIH WFZqhE4vhpcUNJAYN40vi64c2Bm0Mw5CLNMN/f++itftvNbsbCazR0ldjjqoBHvZT4NxOQg1Le5 dpRuo0QZDo5S7DdosLsiAzyUMFkhf+zjeTBbW2vjtzs4uikTALkl8H9Duf3eobyxF8V2OzTyHup 8Q8v7EboTvcNUM3PnNU34HsDoZxpsvDOjab3ur9gUsPukkDALC5TjEvX9GMhdLRaXVWW6TvOpOz wp7ZYINulHRvQUX1uHol310JlUX21/eG8guAo2ttdd X-Received: by 2002:a05:6000:2dc7:b0:4a5:bb9f:9c3c with SMTP id ffacd0b85a97d-4abb4c7ac0dmr75304745f8f.53.1796049453841; Mon, 30 Nov 2026 06:37:33 -0800 (PST) X-Received: by 2002:a05:6000:2dc7:b0:4a5:bb9f:9c3c with SMTP id ffacd0b85a97d-4abb4c7ac0dmr75304713f8f.53.1796049453471; Mon, 30 Nov 2026 06:37:33 -0800 (PST) Received: from mszeredi-thinkpadt14gen6.redhat.corp (193-226-214-34.pool.digikabel.hu. [193.226.214.34]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6b110c3csm62452044f8f.36.2026.11.30.06.37.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 06:37:32 -0800 (PST) From: Miklos Szeredi To: fuse-devel@lists.linux.dev, virtualization@lists.linux.dev Cc: Li Wang , German Maglione , Stefan Hajnoczi Subject: [PATCH v2 4/4] virtiofs: fix forget leak on submount unmount Date: Mon, 30 Nov 2026 15:37:20 +0100 Message-ID: <20261130143728.326871-4-mszeredi@redhat.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261130143728.326871-1-mszeredi@redhat.com> References: <20261130143728.326871-1-mszeredi@redhat.com> X-Mailing-List: virtualization@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: qnypbPbzAP9TXWiHteT0igcTNV7wqUDnM18NeHthzXM_1796049454 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true generic_shutdown_super() clears SB_ACTIVE before calling evict_inodes(), so fuse_evict_inode() skipped both the FUSE_FORGET for fi->nlookup and fuse_cleanup_submount_lookup() for every remaining inode. For a full unmount that is mostly fine: FUSE_DESTROY has already told the server to drop everything. But a submount unmount takes the same path with the connection still alive: fuse_mount_remove() returns false, so fuse_conn_destroy() is not called and no FUSE_DESTROY is sent. The server then keeps the lookup count of every inode of the submount for the lifetime of the connection, which can be arbitrarily long if the parent mount stays around and submounts come and go. fuse_submount_lookup is worse, because it is freed nowhere else: the object and its embedded forget are leaked on any unmount, including a full one, for every inode that has one. Queue both regardless of SB_ACTIVE. This is safe on the paths where the connection is already gone: both fuse_dev_queue_forget() and virtio_fs_send_forget() just free the link when the queue is disconnected, and fc->chan stays valid until fuse_free_conn(), well after evict_inodes(). Fixes: c4d361f66ac9 ("fuse: share lookup state between submount and its parent") Cc: Signed-off-by: Miklos Szeredi --- fs/fuse/inode.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 344fcb55a64b..81ee6c96203c 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -141,6 +141,7 @@ static void fuse_cleanup_submount_lookup(struct fuse_conn *fc, static void fuse_evict_inode(struct inode *inode) { struct fuse_inode *fi = get_fuse_inode(inode); + struct fuse_conn *fc = get_fuse_conn(inode); /* Will write inode on close/munmap and in all other dirtiers */ WARN_ON(inode_state_read_once(inode) & I_DIRTY_INODE); @@ -157,19 +158,27 @@ static void fuse_evict_inode(struct inode *inode) */ if (FUSE_IS_VDAX(inode)) fuse_vdax_inode_cleanup(inode); - if (inode->i_sb->s_flags & SB_ACTIVE) { - struct fuse_conn *fc = get_fuse_conn(inode); + /* + * Must be done unconditionally as well: on a submount unmount the + * connection stays alive and no FUSE_DESTROY is sent, so without + * this the server keeps the lookup counts of every inode in the + * submount for the lifetime of the connection. The + * fuse_submount_lookup object is freed nowhere else, so skipping it + * leaks that too. If the connection is already gone (full unmount, + * failed mount) fuse_chan_queue_forget() just frees the forget. + */ + if (fi->nlookup) { + fuse_chan_queue_forget(fc->chan, fi->forget, fi->nodeid, + fi->nlookup); + fi->forget = NULL; + } - if (fi->nlookup) { - fuse_chan_queue_forget(fc->chan, fi->forget, fi->nodeid, - fi->nlookup); - fi->forget = NULL; - } + if (fi->submount_lookup) { + fuse_cleanup_submount_lookup(fc, fi->submount_lookup); + fi->submount_lookup = NULL; + } - if (fi->submount_lookup) { - fuse_cleanup_submount_lookup(fc, fi->submount_lookup); - fi->submount_lookup = NULL; - } + if (inode->i_sb->s_flags & SB_ACTIVE) { /* * Evict of non-deleted inode may race with outstanding * LOOKUP/READDIRPLUS requests and result in inconsistency when -- 2.56.1