From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 BEAB43DEFE1 for ; Thu, 23 Apr 2026 08:57:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776934643; cv=none; b=gHHBxvbm9o3OQPKrNKf2GY10R+xoUNZ5zBAFpkdadgeqvN8Qyw22BXd787JD9EfJcSSIUgkAoqU798Mh5UqdTUNsNTWwkadOVFTNwax0tisC1vkYCFr76HvlShntOgj60BNzm1DWclTKIgYhL9TU4iXaPjad4PxNMxGafPesNKc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776934643; c=relaxed/simple; bh=s/mVlPzEebqAesHz/sLkbRMTIWafF4uV9ydlEIHsbbU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=d5x/md4DshriPc4oKyC1G4Uzl2UgYSovuGliU0w0TQaOuWvbcB3npj5Fwsn2OKullqjn4tAmRp5Xd14uovhR6VscVPbJKYz1/Rcs8MQqpuuWUHtknfByxmY7hnR6vIrJm0SwH91GQH8HGbFoCOnQtiGbcA87/AcXu7LjykxBZJA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Sf8CpHoa; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Sf8CpHoa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C43CC2BCB2; Thu, 23 Apr 2026 08:57:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1776934643; bh=s/mVlPzEebqAesHz/sLkbRMTIWafF4uV9ydlEIHsbbU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Sf8CpHoaL+a5k2dVuN2jmMb04nqrchsuw4gl2y9GI9Prs+cYCZ5u/yS5uyQpSegPN wq80DQQ+wLnarznDUipCT/44ZhZ9ZTGIDFQAqTrb38vshI8JW2KZjBPxq7wBhSgg3i yvqaBJruKbq9kM9IHMsFtJFVW5X0sVrYN+lHPQTM= Date: Thu, 23 Apr 2026 10:57:21 +0200 From: Greg KH To: "Matthew Wilcox (Oracle)" Cc: stable@vger.kernel.org, Google Big Sleep , Jens Axboe , Jan Kara , Andrew Morton Subject: Re: [PATCH 6.18.y] mm: call ->free_folio() directly in folio_unmap_invalidate() Message-ID: <2026042345-t-shirt-december-6836@gregkh> References: <2026042002-idealness-evade-7213@gregkh> <20260420145343.2046992-1-willy@infradead.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260420145343.2046992-1-willy@infradead.org> On Mon, Apr 20, 2026 at 03:53:43PM +0100, Matthew Wilcox (Oracle) wrote: > We can only call filemap_free_folio() if we have a reference to (or hold a > lock on) the mapping. Otherwise, we've already removed the folio from the > mapping so it no longer pins the mapping and the mapping can be removed, > causing a use-after-free when accessing mapping->a_ops. > > Follow the same pattern as __remove_mapping() and load the free_folio > function pointer before dropping the lock on the mapping. That lets us > make filemap_free_folio() static as this was the only caller outside > filemap.c. > > Link: https://lore.kernel.org/20260413184314.3419945-1-willy@infradead.org > Fixes: fb7d3bc41493 ("mm/filemap: drop streaming/uncached pages when writeback completes") > Signed-off-by: Matthew Wilcox (Oracle) > Reported-by: Google Big Sleep > Cc: Jens Axboe > Cc: Jan Kara > Cc: > Signed-off-by: Andrew Morton > (cherry picked from commit 615d9bb2ccad42f9e21d837431e401db2e471195) > Signed-off-by: Matthew Wilcox (Oracle) > --- > mm/filemap.c | 3 ++- > mm/internal.h | 1 - > mm/truncate.c | 6 +++++- > 3 files changed, 7 insertions(+), 3 deletions(-) This is odd, it's applying with a ton of fuzz, which puts things in the wrong functions and breaks the build. Let me go fix it up by hand... thanks, greg k-h