From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 CF1D31B85D6; Mon, 10 Feb 2025 08:27:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739176056; cv=none; b=d3FmQLe0zRnYGUip2iKjMC0j4jvZLFuIkPNHG+4mttbl4DcoH7qrI+9kdGyzRlYETJh+UBzpcDeaZc2ckpCfucyoz72D27hFvG2z0pgMfuAy7kGtoYG2NnKGekD2cR3zl3Vc266zZ03ODKHgYnrhqi98EYN04K3BltLsyyu7NZk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739176056; c=relaxed/simple; bh=FTdL7sctDOxRcrBb0oZ2biT5vSzSQRjnYgP28GSiWkI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=pZQ6/NrUDYVKWXoM/D4uy4UQk4UEUe6ery5MT4rF/kjKqsGOnmtXs3zT5pir9jRr8inCemTMk8733UcHd/PD53KAbAiLR7jEp7EHKtoYFu5vhGOZGo3O71GoDkc6DdfcUT96WAvbVjeE9+fgv41sq0XSvZZGiBVGnBLAfQiqHQc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=TzyQ0rT0; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=PNwgz+o5; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=CZ/6gXlp; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=KUIj5cQS; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="TzyQ0rT0"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="PNwgz+o5"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="CZ/6gXlp"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="KUIj5cQS" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id D715221109; Mon, 10 Feb 2025 08:27:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1739176053; h=from:from:reply-to: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:autocrypt:autocrypt; bh=YcF4untn6noy1BENHYGy14SUwNDSxJ/1RtuCfKAWOys=; b=TzyQ0rT0C7H76CYNALXR817sGRgtoNy2a5UfFajR0OHCpPQbntfWmhkK7znRtDhu4RMY7S Rf16CHHoPsjjdZONzWivoK2cHUtb4nMFbB1vfpM7d9hed9wNW1dXYewA4hb/LgTmIQ7kla jSItw3gsVRZ3tCpycVbw3u9HQXdADIY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1739176053; h=from:from:reply-to: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:autocrypt:autocrypt; bh=YcF4untn6noy1BENHYGy14SUwNDSxJ/1RtuCfKAWOys=; b=PNwgz+o5DXD9Rrlilyh0YvC5KsD47+yPBweDKJ0tXEa4PDO6TQ3s76TYkxaNZbbwrS8sMx o4ch4yn+lKe6eaAQ== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b="CZ/6gXlp"; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=KUIj5cQS DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1739176052; h=from:from:reply-to: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:autocrypt:autocrypt; bh=YcF4untn6noy1BENHYGy14SUwNDSxJ/1RtuCfKAWOys=; b=CZ/6gXlprzUtNko0sDUyNN4xwzCzy0ffKeQJzQhL/Jx+GgR/HDXc21DMnThgdkSh9vZTQz 84A61qcyFZEfwBshgDnFgwUWzIqgS4oghayU4n90KK+PbvizgQLY7IPtxKhbJRjvfslX0i il0/8xYr0MTy8TxwUqRx6E1BP5gwtxw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1739176052; h=from:from:reply-to: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:autocrypt:autocrypt; bh=YcF4untn6noy1BENHYGy14SUwNDSxJ/1RtuCfKAWOys=; b=KUIj5cQSoxB56L3SoXovFtnfKg9P/K6Ac0c76Jw5zPnj6ECbL1557jb6SqEPkwJzYNCnQt TvpuBGQddUfc+nAw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B582913707; Mon, 10 Feb 2025 08:27:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id p7/9K3S4qWfmIQAAD6G6ig (envelope-from ); Mon, 10 Feb 2025 08:27:32 +0000 Message-ID: <81298bd1-e630-4940-ae5b-7882576b6bf4@suse.cz> Date: Mon, 10 Feb 2025 09:27:32 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [REGRESSION][BISECTED] Crash with Bad page state for FUSE/Flatpak related applications since v6.13 To: Joanne Koong , Matthew Wilcox Cc: Josef Bacik , Miklos Szeredi , Christian Heusel , Miklos Szeredi , regressions@lists.linux.dev, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm , =?UTF-8?Q?Mantas_Mikul=C4=97nas?= References: <2f681f48-00f5-4e09-8431-2b3dbfaa881e@heusel.eu> <9cd88643-daa8-4379-be0a-bd31de277658@suse.cz> <20250207172917.GA2072771@perftesting> <8f7333f2-1ba9-4df4-bc54-44fd768b3d5b@suse.cz> Content-Language: en-US From: Vlastimil Babka Autocrypt: addr=vbabka@suse.cz; keydata= xsFNBFZdmxYBEADsw/SiUSjB0dM+vSh95UkgcHjzEVBlby/Fg+g42O7LAEkCYXi/vvq31JTB KxRWDHX0R2tgpFDXHnzZcQywawu8eSq0LxzxFNYMvtB7sV1pxYwej2qx9B75qW2plBs+7+YB 87tMFA+u+L4Z5xAzIimfLD5EKC56kJ1CsXlM8S/LHcmdD9Ctkn3trYDNnat0eoAcfPIP2OZ+ 9oe9IF/R28zmh0ifLXyJQQz5ofdj4bPf8ecEW0rhcqHfTD8k4yK0xxt3xW+6Exqp9n9bydiy tcSAw/TahjW6yrA+6JhSBv1v2tI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yialGkSiZJNkWgeHe+jEcfRT6pJZOJidSCdzvJpbdJmm+eED w9XOLH1IIWh7RURU7G1iOfEfmImFeC3cbbS73LQEFGe1urxvIH5K/7vX+FkNcr9ujwWuPE9b 1C2o4i/yZPLXIVy387EjA6GZMqvQUFuSTs/GeBcv0NjIQi8867H3uLjz+mQy63fAitsDwLmR EP+ylKVEKb0Q2A== In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: D715221109 X-Spam-Level: X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FREEMAIL_TO(0.00)[gmail.com,infradead.org]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FREEMAIL_CC(0.00)[toxicpanda.com,szeredi.hu,heusel.eu,redhat.com,lists.linux.dev,vger.kernel.org,kvack.org,gmail.com]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_SEVEN(0.00)[11]; DKIM_TRACE(0.00)[suse.cz:+]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:dkim,suse.cz:mid,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -4.51 X-Spam-Flag: NO On 2/8/25 16:46, Joanne Koong wrote: > On Sat, Feb 8, 2025 at 2:11 AM Matthew Wilcox wrote: >> >> On Fri, Feb 07, 2025 at 04:22:56PM -0800, Joanne Koong wrote: >> > > Thanks, Josef. I guess we can at least try to confirm we're on the right track. >> > > Can anyone affected see if this (only compile tested) patch fixes the issue? >> > > Created on top of 6.13.1. >> > >> > This fixes the crash for me on 6.14.0-rc1. I ran the repro using >> > Mantas's instructions for Obfuscate. I was able to trigger the crash >> > on a clean build and then with this patch, I'm not seeing the crash >> > anymore. >> >> Since this patch fixes the bug, we're looking for one call to folio_put() >> too many. Is it possibly in fuse_try_move_page()? In particular, this >> one: >> >> /* Drop ref for ap->pages[] array */ >> folio_put(oldfolio); >> >> I don't know fuse very well. Maybe this isn't it. > > Yeah, this looks it to me. We don't grab a folio reference for the > ap->pages[] array for readahead and it tracks with Mantas's > fuse_dev_splice_write() dmesg. this patch fixed the crash for me when > I tested it yesterday: > > diff --git a/fs/fuse/file.c b/fs/fuse/file.c > index 7d92a5479998..172cab8e2caf 100644 > --- a/fs/fuse/file.c > +++ b/fs/fuse/file.c > @@ -955,8 +955,10 @@ static void fuse_readpages_end(struct fuse_mount > *fm, struct fuse_args *args, > fuse_invalidate_atime(inode); > } > > - for (i = 0; i < ap->num_folios; i++) > + for (i = 0; i < ap->num_folios; i++) { > folio_end_read(ap->folios[i], !err); > + folio_put(ap->folios[i]); > + } > if (ia->ff) > fuse_file_put(ia->ff, false); > > @@ -1049,6 +1051,7 @@ static void fuse_readahead(struct readahead_control *rac) > > while (ap->num_folios < cur_pages) { > folio = readahead_folio(rac); > + folio_get(folio); This is almost the same as my patch, but balances the folio_put() in readahead_folio() with another folio_get(), while mine uses __readahead_folio() that does not do folio_put() in the first place. But I think neither patch proves the extraneous folio_put() comes from fuse_try_move_page(). > ap->folios[ap->num_folios] = folio; > ap->descs[ap->num_folios].length = folio_size(folio); > ap->num_folios++; > > > I reran it just now with a printk by that ref drop in > fuse_try_move_page() and I'm indeed seeing that path get hit. It might get hit, but is it hit in the readahead paths? One way to test would be to instead of yours above or mine change, to stop doing the foio_put() in fuse_try_move_page(). But maybe it's called also from other contexts that do expect it, and will leak memory otherwise. > Not sure why fstests didn't pick this up though since splice is > enabled by default in passthrough_hp, i'll look into this next week. >