From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 908FD378D94 for ; Mon, 22 Jun 2026 08:58:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782118702; cv=none; b=pbfSHlODX6Tv8/zeEVxR203B2ThberqySfousIg89v3bgJvA8Ew1Zi1jgD0WStcjhBS6KzIPS1sMVuvDNMalFkrsHEd280ouu9OKkHj0VSqNRYY1HfJe4WA74d+SBU/L5PCG+UbSbLdy1TzpdG07EBYtc8QQv5q9xIJvAbIz53E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782118702; c=relaxed/simple; bh=Ta78qESbrbY3yH7hK8XMSr03RR+qPZPr7paE4TUgrZs=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=l7/Ngsx7nUSRfNs2ClIPvJ/d0WiYIiZIXYJgVHCrGiKhdXtNkOH/i9cHQiW+zOtLTts3A9ORD5YRGKPLKx2H5EMhrkZlbvhenXWPPFmPH4jGE9Dwk+FlQ4FMygalTaez0zUUa6GcIEj2cwdk7+xvKII0CZc8BDngB4DJ9L11iUo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=egC9/deh; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="egC9/deh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE76B1F00A3A; Mon, 22 Jun 2026 08:58:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1782118701; bh=/wtV9YnqAxaPQ02RMCVy8daZvfOy7gyYEd/eGTMOPVo=; h=Subject:To:Cc:From:Date; b=egC9/dehD3ElknwTTFeTAoXEkbtFVPem0kpgpHywNNHGyJjvO+gOa/h3/PrEcIvcy hFSQZITBesm93qb4qW7gaWHV8k1J1jX5Shw1/yAo/uLHrp1iOBKrB1ZGl0tzCUTALS f6dssuj37WWN/XsK4/9O2KUcc8TMsnhudo+IWstw= Subject: FAILED: patch "[PATCH] fuse: re-lock request before replacing page cache folio" failed to apply to 6.1-stable tree To: joannelkoong@gmail.com,llfamsec@gmail.com,mszeredi@redhat.com Cc: From: Date: Mon, 22 Jun 2026 10:58:31 +0200 Message-ID: <2026062231-sterilize-crisped-5ef7@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.1-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y git checkout FETCH_HEAD git cherry-pick -x a078484921052d0badd827fcc2770b5cfc1d4120 # git commit -s git send-email --to '' --in-reply-to '2026062231-sterilize-crisped-5ef7@gregkh' --subject-prefix 'PATCH 6.1.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From a078484921052d0badd827fcc2770b5cfc1d4120 Mon Sep 17 00:00:00 2001 From: Joanne Koong Date: Mon, 18 May 2026 22:28:06 -0700 Subject: [PATCH] fuse: re-lock request before replacing page cache folio fuse_try_move_folio() unlocks the request on entry but does not re-lock it on the success path. This means fuse_chan_abort() can end the request and free the fuse_io_args (eg fuse_readpages_end()) while the subsequent copy chain logic after fuse_try_move_folio() accesses the fuse_io_args, leading to use-after-free issues. Fix this by calling lock_request() before replace_page_cache_folio(). This ensures the request is locked on the success path which will prevent the fuse_io_args from being freed while the later copying logic runs, and also ensures that the ap->folios[i]->mapping is never null since ap->folios[i] will always point to the newfolio after replace_page_cache_folio(). Fixes: ce534fb05292 ("fuse: allow splice to move pages") Cc: stable@vger.kernel.org Reported-by: Lei Lu Signed-off-by: Joanne Koong Signed-off-by: Miklos Szeredi diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 05b6d15afe61..86b62a1d3746 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -1037,6 +1037,10 @@ static int fuse_try_move_folio(struct fuse_copy_state *cs, struct folio **foliop if (WARN_ON(folio_test_mlocked(oldfolio))) goto out_fallback_unlock; + err = lock_request(cs->req); + if (err) + goto out_fallback_unlock; + replace_page_cache_folio(oldfolio, newfolio); folio_get(newfolio); @@ -1050,20 +1054,7 @@ static int fuse_try_move_folio(struct fuse_copy_state *cs, struct folio **foliop */ pipe_buf_release(cs->pipe, buf); - err = 0; - spin_lock(&cs->req->waitq.lock); - if (test_bit(FR_ABORTED, &cs->req->flags)) - err = -ENOENT; - else - *foliop = newfolio; - spin_unlock(&cs->req->waitq.lock); - - if (err) { - folio_unlock(newfolio); - folio_put(newfolio); - goto out_put_old; - } - + *foliop = newfolio; folio_unlock(oldfolio); /* Drop ref for ap->pages[] array */ folio_put(oldfolio);