Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB9003E3169 for ; Mon, 18 May 2026 09:06:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779095214; cv=none; b=Umik24mzg/qA+cj2O2emqiXyMmt2Sc58bRWoI6HA/53u3MzlHLOMgIv1/4c1rjZIwba9fIoBzV+c1d5jlBmwcSst/bpLcyHUr+H47+7kJ7Q5MjRV72TGjTWrWQmCAuVpOyKQbubCMIWvRKw1POlvJ8jIN48AOf8c+ggcvR56i70= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779095214; c=relaxed/simple; bh=+sv4jnUTyOdjjZciCJyC+lf1CirV23BI+BT8te+prnE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=YqrQ2Hcen/TOSV51r9FgdTKXZTv+js7ijxEXekjfn1JfMDQ/CTRPKuJd8+ow4khKINHvE9LDE0xtmv7Jc7wOp29Mj0aFLLVIWbsFcsKhU3Bm61xNYyZ88+FstMgUjTKZ1fPZEKkFzE8tncQDkUBaKKDOo1P9IgPoYwu2lVBfY6c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=I5OQOZvJ; arc=none smtp.client-ip=209.85.218.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="I5OQOZvJ" Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-bd394f4a931so447212266b.2 for ; Mon, 18 May 2026 02:06:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779095211; x=1779700011; darn=lists.linux.dev; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=zSl2K2WdTrcT8MX7//EVVA3HDXITKieSgfsnYmfI0m8=; b=I5OQOZvJsXrI9c0mMGJVL9MVijrBHJt7J//5AKylTxvN/1DmbfS1ofvbaPanAK2s6F Yo/tpujIYuZwekdSM/YKAXjeoD1RhT3hJUORKY8J6ShY6UCSCB7AYislKTrCOnJnfJaL C8mAavqTXE9V6YD9jFxFhVqkwzTINCaM0GPDRP1DUfJ/LNseMBA1t5wy+c50/koVGOtJ wWnJGVKZ9fD/39BtrjKfgPVj3hXzIA+13tTRcwLfWkQvoYO6h4sN9Rk5A2pKyXh0lldE kHGPRhhqfCRkIiScG999wmPpvfsSwFfv7aKglvRS1fXEDyFa08t259VJy3jVJ8gp8aSf selg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779095211; x=1779700011; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zSl2K2WdTrcT8MX7//EVVA3HDXITKieSgfsnYmfI0m8=; b=p7o2Sj98fCJNGcVI9wzAmfLKa0Vp2Wen93v5toG6d+s1Y0eae12rK/paduaNaS+gPQ osyR08Qvprn6p0GBVDX8PzkxuKhY2b5RCM/QVy+65eDCqV9TwLqIIvlhQskNO0aX3Uh0 l3T+PV1C7AnsRPSvlB25SvKgiRcl4tB1AjlvPR2SNWG9M9iAhDu6m1d/PPoaMO7b3tsF nUkZK+GeuLzXkuRCCzuG5m5FcnV4lCc5yGldYuu+v+h0sR+1AX9LIHam0rilvlVS67jx ApbEt8Pc3xVMIs262ZOBiOOEbxN/AZmcTC+1xjTIFc8fK34BMlQ6oRCVcxiihQ7MHChE bp+A== X-Forwarded-Encrypted: i=1; AFNElJ8MVdIwZLPog4Z10hEKbvhabqbG6N5umsNZ1K2WvJtJHwqMfYc+rAVT7X6jk/I6jzrgrNgvJWY7kulY@lists.linux.dev X-Gm-Message-State: AOJu0YyUM5/inWzEt/+/oZiWhlzxvPn4b1iPYXTQhRBdIUEKIpu1NukM FY7Unvu5TbWt8TbSzY6Ny5lUxp5W/eF4ZzwMGc0E+vRn/9pqgjmqTKHC X-Gm-Gg: Acq92OGSKDIAE4Sfbvem63/HR6W+oUhJlyjcGh4UT1xVGhM53Z1Cl5B2B23Yda8g/m4 36JW481DcbADmjrtJlOPkd4x0tkh+v7iSH16m5chjL2OSovPVae08MOaltGWljJ6ZgGpmgX9aZ2 6PmuDRX3euY3svvKiIKok9DSbfDFiaC4yotsyiZoLwDhX3CAgH0CsNeiLTgWMYiDuSfJTCn1/Pb G/LjIZlTyHtBQBj3g1Dgy1ji75XabOo8RW63TVBGEXI7PaM2iijcjcMDxL8ax1Vu8KB2XvnXnVO hOz+qORgCaw4VVzsn7hssV2zvf96nCW+0sX8KzOSy52MlWu9R+RIbdVXp9Wtgmi9WP96k8j1lx1 yKolPW3ocEYq0UB3vsOmeXYI1RVzgDXh4xcNCyBx5/TWFuif3cspi6eCb7pJi2SOn04bp0x1uEk 6yza4nRxlEHPj9Rc7avEvLi9/KqGPSZCBlB8K6uZD0CncKDfqcdOMz37UHt33LB6tdJdW4hORJD lKOSrPmRmHE/gVFG3Am1MTxcMYG0M3rdesQ7hmpMVFX9YTcD9oRKMrWgeQ= X-Received: by 2002:a17:906:6185:b0:bc4:b9f5:fe27 with SMTP id a640c23a62f3a-bd51780c8acmr759171166b.10.1779095211030; Mon, 18 May 2026 02:06:51 -0700 (PDT) Received: from ?IPV6:2620:10d:c096:325:77fd:1068:74c8:af87? ([2620:10d:c092:600::1:6e9b]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-bd4f4e57cb8sm535358566b.50.2026.05.18.02.06.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 May 2026 02:06:50 -0700 (PDT) Message-ID: <9f3f3dc7-1c52-49b6-91d5-046f1fc7b2a8@gmail.com> Date: Mon, 18 May 2026 10:06:48 +0100 Precedence: bulk X-Mailing-List: fuse-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2] fuse: wait for aborted connection before releasing last fuse_dev To: Bernd Schubert , Berkant Koc , Greg KH , Miklos Szeredi Cc: "security@kernel.org" , Joanne Koong , "linux-fuse@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "io-uring@vger.kernel.org" , Jens Axboe , fuse-devel References: <20260517095846.fuse-iouring-uaf.dc5f5dbb71dc@berkoc.com> <2026051703-equinox-multitude-91e2@gregkh> <20260517-fuse-uaf-cover@berkoc.com> <20260517-fuse-uaf-patch2@berkoc.com> <08d3f6e0-7745-4084-995a-95ddb77f7f11@ddn.com> Content-Language: en-US From: Pavel Begunkov In-Reply-To: <08d3f6e0-7745-4084-995a-95ddb77f7f11@ddn.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 5/17/26 16:00, Bernd Schubert wrote: > On 5/17/26 14:59, Berkant Koc wrote: >> [You don't often get email from me@berkoc.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ] >> >> From: Berkant Koc >> >> fuse_dev_release() on the last fuse_dev of a connection calls >> fuse_abort_conn(fc) and then immediately fuse_conn_put(fc). For io-uring >> backed connections fuse_abort_conn() reaches fuse_uring_abort(), which >> runs fuse_uring_teardown_all_queues() synchronously once and then >> schedules ring->async_teardown_work to run after >> FUSE_URING_TEARDOWN_INTERVAL (HZ/20). If the synchronous pass left >> queue_refs > 0 the work owns further accesses to ring->queues[*]-> >> ent_avail_queue and ent_in_userspace entries. >> >> Meanwhile fuse_conn_put() can drop the last reference and arm >> delayed_release() via call_rcu(). After the RCU grace period >> delayed_release() calls fuse_uring_destruct(), which kfree()s the ring >> entries on each queue->ent_released list. The previously scheduled >> async_teardown_work then runs and walks per-queue lists that contain >> freed entries, producing a slab-use-after-free reported by KASAN at >> fuse_uring_teardown_all_queues+0xee reading ent->list.next from a >> freed kmalloc-192 region. >> >> fuse_wait_aborted() already exists for this purpose: it waits on >> fc->blocked_waitq for num_waiting to drain and then calls >> fuse_uring_wait_stopped_queues(), which waits for ring->queue_refs to >> reach zero. Call it between fuse_abort_conn() and fuse_conn_put() on >> the last-device path so the io-uring teardown work has fully drained >> before the connection can be torn down. >> >> Fixes: c090c8abae4b ("fuse: Add io-uring sqe commit and fetch support") >> Cc: stable@vger.kernel.org # 6.14+ >> Tested-by: Berkant Koc >> Signed-off-by: Berkant Koc >> --- >> fs/fuse/dev.c | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c >> index 5dda7080f4a9..7d9c06654a98 100644 >> --- a/fs/fuse/dev.c >> +++ b/fs/fuse/dev.c >> @@ -2566,6 +2566,7 @@ int fuse_dev_release(struct inode *inode, struct file *file) >> if (last) { >> WARN_ON(fc->iq.fasync != NULL); >> fuse_abort_conn(fc); >> + fuse_wait_aborted(fc); >> } >> fuse_conn_put(fc); >> } > > I might be wrong, but I don't think it is possible, Maybe Pavel or Jens > could help (added to CC). Basically as long as > fuse_uring_async_stop_queues() runs we do not have completed all > io-uring commands via io_uring_cmd_done() and as long as we do not have > completed these io-uring commands. If I understand the question right, yes, fuse io_uring cmd requests hold a reference to the fuse file, so until you complete them the file will not get released. -- Pavel Begunkov