From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796049457; b=hL2ydS9jZSbcxbHuZOdeGwWjWSqYyV9zBpZgat/pajg6A+ZRNKHA64EHWKr/hcIFsPMA tfCS3qQ1uGQMOlNcpy1EtsvtktV95jOAxbHc0E+kCb+1rAZ37ic+PoU9R1VGw6GVpusRH YqV7W1GL/rXWpK3g30Mhjhm+TgrBiyzHyIon0Xg2+XJrv84PQ41iYNw8Vi2G6WrVJdj38 9fP/O4HPDUlhrHZafbiLm4GFTce5C3kCKMrzuSWsHBlSFLstZX+tlKv/jfIs/mE0FA4Xu cUe/PJL8GSOVm8eKTs6Xb5rGQCe6E3vYEod8WGiLZsNf2VPiHE8yHcdR3lP7mzwY3KA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796049457; h=DMARC-Filter:DKIM-Signature: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: MIME-Version:X-Mimecast-Spam-Score:X-Mimecast-MFC-PROC-ID: X-Mimecast-Originator:Content-Transfer-Encoding:content-type; bh=TDy8Tc7Iea+fEMov5PKxcIRAqUaHvg+tY+kOpYhBUi4=; b=nwTdBWHN/taDGstLkGYwTn1U9B++HCxIRRXlI5og+D2WHWI6FRf8e2DSFsLPNfLNdtyR 5aKRrqE3lQWEQ+V/BiAMoFYcPgcUdDS9nUgrCfxCgWpBJ+F4YILmQjw3fkOzVQyooIfR+ nAQK5VORMNzfuMR7BHlMy+nycSNWXOW2THGQFFrTVYNy7P7tYCaJ/iXkJcsmzxzpfWooo i/NRKMPgMKTVkLVsg9XOw5nUtRFcTmrzhZoDffrYlpGtHqfU3tJxvWcPboTBHm2OV3Nb+ NwcsrJB/4GywFKhHpGb/pBba0OgV4oQD7yCfFtX1pd31DRM2Bug+1Gtp7dwR7mDV6iA== 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=FV86+itk; arc=none smtp.remote-ip=170.10.133.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 36282606A33D for ; Mon, 30 Nov 2026 14:37:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 36282606A33D 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=FV86+itk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796049455; 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; bh=TDy8Tc7Iea+fEMov5PKxcIRAqUaHvg+tY+kOpYhBUi4=; b=FV86+itkckiGLN4u47dDsgj13gNr+qZHBibo3j60QVCZtEhH1Cttd+Ubtru8lvOTuIOrcY JjCPkOUiIWldpJxpddY078FzXzk6C+gQv2O2fPqqwCMmsqFUvinljzD5T8s41OfmmqUANq erDJLQXFNOdWL/phfl1FWZCNpgn3egs= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-628-eiWXXMONNo2KiyXxJZxdjg-1; Mon, 30 Nov 2026 14:37:32 +0000 X-MC-Unique: eiWXXMONNo2KiyXxJZxdjg-1 X-Mimecast-MFC-AGG-ID: eiWXXMONNo2KiyXxJZxdjg_1796049451 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-4925ef75fc4so6348827f8f.1 for ; Mon, 30 Nov 2026 06:37:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796049451; x=1796654251; h=content-transfer-encoding:mime-version: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=TDy8Tc7Iea+fEMov5PKxcIRAqUaHvg+tY+kOpYhBUi4=; b=ZJHYWFopR14ZGRYxEU5pot1zMLzUzvJBzxr6unyMaMksig04TL2IH8yFHlXX0oZ6Y7 PnRrN+ih078Km7y7Mc94lzxJiXqnfOFjcpx7qeP47UrKcCIYOIhpTGBaG7olp4rEdPM4 ggIjMMNJWqztmEXxXiZbp3+mLIYp1JAJEjj8pnyD3cr06wOWMHiiqqelhAdO3QSIdCzA ZBgZBJbpSieA36d1NkzdNipgcHo5yjw9qcZRGWgxD8Wf9d8OBsDFH3vV1XF+8H0DxiIz 4XDn+68cKWIJynnu1oDOd5ge6XvOgAeckyswJWy1s5TNFEWmzpkrIoYLhgmf7cvR0GxI DNew== X-Forwarded-Encrypted: i=1; AL+hErELilt2cOz7BT68RB/JZH1JjQN6UwswDVdNdlaUM5s9rlCJjx92tvC+OGrhGc7X4dk8XGgHH1ocz+mhLY9X2w==@lists.linux.dev X-Gm-Message-State: APuU4Z8+bwi26xye2HGWjjntitHFrgyeZAiAaBzcTPCW/iWvLQLMIvqk 7DpZmPHm5q8+TsW1xZ4NRfaYugSK7a4NizAqfIFCPPMKbHFXQ55xg3cxtyKF8mHA1XSNCZpqBqR dIUx86Q/+1cx7p9260OLiPOyR4sVg8rv5TKPphNIoh2rlxM2l0j2nL8OpDQPOz1RbX4QC X-Gm-Gg: AZFdTZcz8QTJt0vCOmaK+mwG+5+HIoaPoSt1zaL5uLK1ehOji0mBqH2Dz7r7+3qXlgk rqS1w+WXbKxxpv/Nr4a3cAqh96YckxUkORHyIKtrNSIKE0MbJ1EXpvBWCi68S2gOTNd3VEK1Yh5 k+Wxy7Ip8IkNpXbL/n7RzRKBgInHwq+qki8BNdk/xqvGqF9TysRnI8jlq0wQaDtdQClMytzhbbN Wv4wg/HZcE6M5NCmZYs1eEuBmaeZQZ4DtKm8mbHVTijGNxRKcbh1+Zqhm5hcoijCS/vbTCBNVFj KVo/fRMwpoKPeQkUS4/XKQcwADSwkbaEhBxmq/+HnVbGBJUz85edvUP8FPxeA1PildAqFOgugWa nMeoj2CUrnrWPqyGjeBo377jjL4IFiTqKWn6ouPK2E1EdpaA3iLWQiJWPZvJfQz2WoDPoY2jvqe bxYRre9wpnhehpBQLRqZQy4AThG/EyEd62CYM15y/J X-Received: by 2002:a5d:64c8:0:b0:493:c0a:507d with SMTP id ffacd0b85a97d-4abaab633c7mr72289191f8f.1.1796049450948; Mon, 30 Nov 2026 06:37:30 -0800 (PST) X-Received: by 2002:a5d:64c8:0:b0:493:c0a:507d with SMTP id ffacd0b85a97d-4abaab633c7mr72289148f8f.1.1796049450540; Mon, 30 Nov 2026 06:37:30 -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.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 06:37:29 -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 1/4] virtiofs: fix DAX range leak on unmount Date: Mon, 30 Nov 2026 15:37:17 +0100 Message-ID: <20261130143728.326871-1-mszeredi@redhat.com> X-Mailer: git-send-email 2.56.1 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: rl3c5RBOq0J-_Sn0u1Zk0EreHF0wxa-H9soLVHzM8kI_1796049451 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 at unmount time fuse_evict_inode() skipped fuse_vdax_inode_cleanup() for every remaining inode. The DAX ranges owned by those inodes stay on fc->vdax->busy_ranges instead of being returned to the free pool, and fuse_vdax_conn_free() only frees free_ranges before kfree()ing the connection, so the busy fuse_dax_mapping objects are leaked. Nothing warns about it: fuse_free_inode() kfree()s fi->vdax without checking that the interval tree is empty. Call fuse_vdax_inode_cleanup() regardless of SB_ACTIVE. That is what virtio_fs_conn_destroy() has always assumed ("Soon evict_inodes() will be called which will free all memory ranges belonging to all inodes"). Unlike the FORGET in the same block, which is pointless once DESTROY has been sent, the DAX cleanup is the only thing there that owns memory. On a full unmount virtio_fs_conn_destroy() has already run by the time evict_inodes() is called, so the FUSE_REMOVEMAPPING requests sent by fuse_vdax_inode_cleanup() fail with -ENOTCONN, which inode_reclaim_dmap_range() ignores. On a submount unmount the connection is still alive and those requests are both valid and needed. Fixes: c2d0ad00d948 ("virtiofs: implement dax read/write operations") Cc: Reported-by: Sashiko Closes: https://sashiko.dev/#/bug/linux-3b38f8c0-5e4a-4c21-87a6-4f96cc3cf147 Reviewed-by: Li Wang Signed-off-by: Miklos Szeredi --- fs/fuse/inode.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 20fbc99f3590..344fcb55a64b 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -150,11 +150,16 @@ static void fuse_evict_inode(struct inode *inode) truncate_inode_pages_final(&inode->i_data); clear_inode(inode); + /* + * Must be done unconditionally: the DAX ranges owned by this inode + * are freed nowhere else, so skipping this on an inactive + * superblock would leak them. + */ + 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); - if (FUSE_IS_VDAX(inode)) - fuse_vdax_inode_cleanup(inode); if (fi->nlookup) { fuse_chan_queue_forget(fc->chan, fi->forget, fi->nodeid, fi->nlookup); -- 2.56.1