From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 581FCC021B8 for ; Tue, 4 Mar 2025 20:37:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E6EB26B0083; Tue, 4 Mar 2025 15:37:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DF830280001; Tue, 4 Mar 2025 15:37:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C70D36B008C; Tue, 4 Mar 2025 15:37:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id A6A496B0083 for ; Tue, 4 Mar 2025 15:37:02 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 261D31405F7 for ; Tue, 4 Mar 2025 20:37:02 +0000 (UTC) X-FDA: 83185027884.23.5C821FC Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) by imf20.hostedemail.com (Postfix) with ESMTP id 252BF1C0004 for ; Tue, 4 Mar 2025 20:36:59 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=toxicpanda-com.20230601.gappssmtp.com header.s=20230601 header.b=przwKY5X; dmarc=none; spf=none (imf20.hostedemail.com: domain of josef@toxicpanda.com has no SPF policy when checking 209.85.222.171) smtp.mailfrom=josef@toxicpanda.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1741120620; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ajQNjB8mdedYx2LlwHnzClYRQdUqzI1pUD1k+HxZ7oQ=; b=l2Y9yGEKfLaXe9N19XOilz2/+3tGs0c9dBUX1UFglOxm4LpkCdSaKtFxV8oI6tB+NUM+32 j6TQxtzYyzMgEaak5U+j1lSTtr8M5TP3obnSaAjeuWpS5Jff4vSytOAOO+hOUBlC8MbJph lfgDj3lnjvO/nBzB6QDeNzYNNf8S6OY= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=toxicpanda-com.20230601.gappssmtp.com header.s=20230601 header.b=przwKY5X; dmarc=none; spf=none (imf20.hostedemail.com: domain of josef@toxicpanda.com has no SPF policy when checking 209.85.222.171) smtp.mailfrom=josef@toxicpanda.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1741120620; a=rsa-sha256; cv=none; b=vVScIq++eKL40hSakc8ETzPZh1pJRMwShxMb+v2ZBQ2WKwlmQOF7aEHdRX8oA+hXXVQzAW Bml96vnJzyxmXFTh2SKUsdJZaajUWB/hdHThKbtuujlFP4uIIXu2Sii1mgLvtNQCfnDzch SKK4HwQW5a13fTaXQ50Ko3M/gog7xng= Received: by mail-qk1-f171.google.com with SMTP id af79cd13be357-7c08b14baa9so519651685a.3 for ; Tue, 04 Mar 2025 12:36:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1741120619; x=1741725419; darn=kvack.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=ajQNjB8mdedYx2LlwHnzClYRQdUqzI1pUD1k+HxZ7oQ=; b=przwKY5XXBqa79eG/i8nj0Fn79mW1QvDz2YHmHXdMGIgy/coSmVAZUaknl88D4Ev59 0FucCr+3zg/liz82oYukwGYD1n+bx5Kc/RiRvWXQfqUBm7B5Wbs0pD1SBquyP2jkH1US 7cUP6G9gyGzq6OV4tl2GPv82vZV+4zxwWN8cku7fk4fvGga1Vp71z/yLwD0X2t7Lgaw7 dO4lTYawd7qL71tegX+fLQfYEbYL/fvmOjufY9Ibu1roB5ujCv0NjQxdGKO6Z8jdd0oA YdeUkQBR6LmeKinAPB8qo4Q39q/keM6TwCvN9sVwBEvQUc1gundhjZBL2LIN5sK8GMia XIfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741120619; x=1741725419; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ajQNjB8mdedYx2LlwHnzClYRQdUqzI1pUD1k+HxZ7oQ=; b=OG15DJZ2xJSxc7ALEMCC4XqguCJa34X6hRUI3Dj8M14VKrufgD3NNacMCORmKT3kaB qDP4PawZpLtEsLrR4oAE/c9Tt1P3ioQKeEcFuqaUuVLn65PlXwexzot6odeFt3IZbqJQ /2btrB8n8/dZndnfnD9bJOFeGkYoWCQw+e0z3trMn3NMdI/c79Kv6EqHaTLVa2u3hfQg bA39FtEVwVl2Cguh7cidGn349sPdmNuHQ+97aruMca0eir69/eNVTyCV+fGiCWOLpQpS plgAfUj+Xn/V+XBisRE1DAbeAzMm7MTAq9l4xkl1jqYkqmBT2pwizfrMRqrPtt8N/ibx orsQ== X-Forwarded-Encrypted: i=1; AJvYcCVNywq+xkbYLLZFbcJn1NXFz97d0GVFD2ShGQUWokG70MqSxFYFf5GB5z8VfYWdpG+dF0/Yq/PlHQ==@kvack.org X-Gm-Message-State: AOJu0YwytlxD6O2ZqV9KQEDFeRhbSIqTx/vXZYwlImmKvQ87aBnl7e0y qA+Jlzm+aBGWbhtuZ1ZmWH+m+x4cUN5zL6y3zVZAoOQWqivesUkD4/4jrkmm1fw= X-Gm-Gg: ASbGncuWcfshwRYraKZBocVkxRykCx4vb8l5AjphyCxhRdRLJ8hrJw1bg3c6+NXd/UX wkO/tQKEkubBqxaDwjAhUMiZ662nauwDtOTbDT6O60CoTxZ7a1v1jQ1ARKd/pe5qeMcR/sXuUUh PYfK7tyq/1M5HM4tNPCJWpz/TPYnhmq1J97ew7fSy91GFCuye2xbbWgfWpTTdHcgmxIp15hIYbK lHF4dSs/OfkgUAVna69oC+GWF44F4dDnx+ARhblgmtWN0So779W4C4Cl4XuGuWNCFXHULi0wMda Kd/YnFLj7ygqQy5Kg9nrOvqVBXwD0CvJytuchwKinnkF/WrY35qQuQITGcJJWkvT4/AWM4/ZCMD 6Ef6Wyw== X-Google-Smtp-Source: AGHT+IGN8GLNVXAgiOiVnkab7Lf8kpIiyiCI+E2wOU2Xu9jt2bq8RbpAyG8danZh0oP6vJsQHUFI8w== X-Received: by 2002:a05:620a:8908:b0:7c0:b103:f252 with SMTP id af79cd13be357-7c3d8e15ea4mr142233885a.8.1741120619086; Tue, 04 Mar 2025 12:36:59 -0800 (PST) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7c3cd20e6bdsm155346885a.23.2025.03.04.12.36.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Mar 2025 12:36:58 -0800 (PST) Date: Tue, 4 Mar 2025 15:36:57 -0500 From: Josef Bacik To: Amir Goldstein Cc: Jan Kara , syzbot , akpm@linux-foundation.org, axboe@kernel.dk, brauner@kernel.org, cem@kernel.org, chandan.babu@oracle.com, djwong@kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-xfs@vger.kernel.org, syzkaller-bugs@googlegroups.com Subject: Re: [syzbot] [xfs?] WARNING in fsnotify_file_area_perm Message-ID: <20250304203657.GA4063187@perftesting> References: <67a487f7.050a0220.19061f.05fc.GAE@google.com> <67c4881e.050a0220.1dee4d.0054.GAE@google.com> <7ehxrhbvehlrjwvrduoxsao5k3x4aw275patsb3krkwuq573yv@o2hskrfawbnc> <20250304161509.GA4047943@perftesting> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 252BF1C0004 X-Rspam-User: X-Stat-Signature: xh8rjuwg1wdxn5356mar8pxp4a39iimt X-HE-Tag: 1741120619-55501 X-HE-Meta: U2FsdGVkX18pAOsAEUACWNgXvJ6wTloSeRed5kU3oOK9YvULR3Qtas+2fTdYTzjNmfQJ2Hb00hgMmLjTY5LykitKibnLoue8rCLxkANhBrc4A/pFoRe3PYLZZLj3IGYzoeJI/8a+POlcBCy8KdlkudI6F5Imw9hAcBYx2FrydtWX/Bxol+7osCLQb2DEI/Ey7GlRqlryVmEgp/eMlsD1kZXs+ygCoS1e+lHc1lXQCrD9lUA+hgdlOqJpJpVG9O2zamfy0PVxAoSSM8UzVvRbmKFnQGRo7cW2pJBUwD/QQ9G+F+IQ+0LVuM7jElPdsxgYuwiMrvJyonxWN2UWCrPlceObKfFWSpOm5x1kx4RzIb/0zFZ2Q0NwTARRrJBND6d2CWg2WpccIY3IQG0G3l6qvk6Xj73xbieTBqCM64nwlUJBAgJYThGPOF9Px+D9pfZ4LHd6JMwupbkF6mIAyPzRkIN3trcnt8ofDoXucIbSPMJNroUFV/d6ypyRX3mge2Zb/LYMDuFLI6RL5kw1SfDj2Yowvtm3uJjGAeMbdliubHoEEthoyUVpdTxICmcuEOBtddIO0CBvwv9RGcpePze7/0DfoJDoAWCLgQEfxoyI+hepYjj86mWIXcKQMbtglkYaEO2javkDWhpH5SPAVZBFGJhgVC1TcFw+ezZ/sCv1ofnVA9/Z+GgpLlmKdnM0zvGZ/h/PYY0Jfppsrf2ZoCS6M3HDEo3ZOtmJta7CSfDcgqMWMIKkbCiD2xkB91jpNztlQXJxMgpFnPLygIyTLbLS28f4aAVCzeuYpZF3rixtcBnMADwDHXVWGlR0Xo85Zl7EUeevB9OSkEvD2MaAM2nux5U5f8wzBTUASi4xOJWnHf1VVYrfvA1PJaHCbcLKVKXsvmAfkQp1OVEuE2dSXFEDWK8KGoiPaqTyiTLWrri52BQ0zjV8nKlyBOP0HI9yxYAmqT3p+IaA1hFefTrEJiF rXaXXDQ9 XeLxwSq2LZmX6B1ck9y8IcNUk3ZI2PSHsJD0XWY/6L0KFbgwQ6+U/iiZVXdvWcAWsZ7ThBddT9Q459Ayp/oZ450ZJ0VhirNTHxT+IIwdYxmD0GHd9CmBMLeKmAIRjmhbnGyW5WQCU/UIuT/OW9cQt3PCxVNPHNiJZTfbTudkQSzs9CCK/M9H/R0yPEHJf+rqoPVyccQjiAGoHGJwng+4M2LaIuSsUA33rJHyf3V+yVIKwctkOGnNSQPglbjB0zix9hRyixLlHWd/BfoidiUKQAvI1WhoL0Qjq5qKkJRBhLcEsRP/iQr/VeF2rRxOwoOsveroar8lPIY3uoOSJjiHtxddQKs5fdIohjsj00bClOrpXILxMaPg0yiuOsN3koyq5hS9fVDJ33HUi5w/mhgUS9AQ2oGW/Xtx/gQX5jnHrl6gCfaD5js9Go5E2qMbTCeB7rVkS80Mjm/pPM/7NbyUgFicMgYtfnmErZpmlgw+w85gleaVKKXLaAQKqbPvRmNHkgi4hUAgo0M4IaETlzhwWSdlvNgjeQvagdJmOY0aEAyDw/VtJMa4a928kVErS7CF0FOGved8/+gBMe0cJyVwTK4wB+pF0HkBiauLLZOdPjkEqL2hVW5Tb7h3scE/VQqe4Vuk/O24oggVj4QgNkfpdiKv4Qm4HPUbPnFZmE1OtVDfRuuE= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Tue, Mar 04, 2025 at 09:27:20PM +0100, Amir Goldstein wrote: > On Tue, Mar 4, 2025 at 5:15 PM Josef Bacik wrote: > > > > On Tue, Mar 04, 2025 at 04:09:16PM +0100, Amir Goldstein wrote: > > > On Tue, Mar 4, 2025 at 12:06 PM Jan Kara wrote: > > > > > > > > Josef, Amir, > > > > > > > > this is indeed an interesting case: > > > > > > > > On Sun 02-03-25 08:32:30, syzbot wrote: > > > > > syzbot has found a reproducer for the following issue on: > > > > ... > > > > > ------------[ cut here ]------------ > > > > > WARNING: CPU: 1 PID: 6440 at ./include/linux/fsnotify.h:145 fsnotify_file_area_perm+0x20c/0x25c include/linux/fsnotify.h:145 > > > > > Modules linked in: > > > > > CPU: 1 UID: 0 PID: 6440 Comm: syz-executor370 Not tainted 6.14.0-rc4-syzkaller-ge056da87c780 #0 > > > > > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 12/27/2024 > > > > > pstate: 80400005 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) > > > > > pc : fsnotify_file_area_perm+0x20c/0x25c include/linux/fsnotify.h:145 > > > > > lr : fsnotify_file_area_perm+0x20c/0x25c include/linux/fsnotify.h:145 > > > > > sp : ffff8000a42569d0 > > > > > x29: ffff8000a42569d0 x28: ffff0000dcec1b48 x27: ffff0000d68a1708 > > > > > x26: ffff0000d68a16c0 x25: dfff800000000000 x24: 0000000000008000 > > > > > x23: 0000000000000001 x22: ffff8000a4256b00 x21: 0000000000001000 > > > > > x20: 0000000000000010 x19: ffff0000d68a16c0 x18: ffff8000a42566e0 > > > > > x17: 000000000000e388 x16: ffff800080466c24 x15: 0000000000000001 > > > > > x14: 1fffe0001b31513c x13: 0000000000000000 x12: 0000000000000000 > > > > > x11: 0000000000000001 x10: 0000000000ff0100 x9 : 0000000000000000 > > > > > x8 : ffff0000c6d98000 x7 : 0000000000000000 x6 : 0000000000000000 > > > > > x5 : 0000000000000020 x4 : 0000000000000000 x3 : 0000000000001000 > > > > > x2 : ffff8000a4256b00 x1 : 0000000000000001 x0 : 0000000000000000 > > > > > Call trace: > > > > > fsnotify_file_area_perm+0x20c/0x25c include/linux/fsnotify.h:145 (P) > > > > > filemap_fault+0x12b0/0x1518 mm/filemap.c:3509 > > > > > xfs_filemap_fault+0xc4/0x194 fs/xfs/xfs_file.c:1543 > > > > > __do_fault+0xf8/0x498 mm/memory.c:4988 > > > > > do_read_fault mm/memory.c:5403 [inline] > > > > > do_fault mm/memory.c:5537 [inline] > > > > > do_pte_missing mm/memory.c:4058 [inline] > > > > > handle_pte_fault+0x3504/0x57b0 mm/memory.c:5900 > > > > > __handle_mm_fault mm/memory.c:6043 [inline] > > > > > handle_mm_fault+0xfa8/0x188c mm/memory.c:6212 > > > > > do_page_fault+0x570/0x10a8 arch/arm64/mm/fault.c:690 > > > > > do_translation_fault+0xc4/0x114 arch/arm64/mm/fault.c:783 > > > > > do_mem_abort+0x74/0x200 arch/arm64/mm/fault.c:919 > > > > > el1_abort+0x3c/0x5c arch/arm64/kernel/entry-common.c:432 > > > > > el1h_64_sync_handler+0x60/0xcc arch/arm64/kernel/entry-common.c:510 > > > > > el1h_64_sync+0x6c/0x70 arch/arm64/kernel/entry.S:595 > > > > > __uaccess_mask_ptr arch/arm64/include/asm/uaccess.h:169 [inline] (P) > > > > > fault_in_readable+0x168/0x310 mm/gup.c:2234 (P) > > > > > fault_in_iov_iter_readable+0x1dc/0x22c lib/iov_iter.c:94 > > > > > iomap_write_iter fs/iomap/buffered-io.c:950 [inline] > > > > > iomap_file_buffered_write+0x490/0xd54 fs/iomap/buffered-io.c:1039 > > > > > xfs_file_buffered_write+0x2dc/0xac8 fs/xfs/xfs_file.c:792 > > > > > xfs_file_write_iter+0x2c4/0x6ac fs/xfs/xfs_file.c:881 > > > > > new_sync_write fs/read_write.c:586 [inline] > > > > > vfs_write+0x704/0xa9c fs/read_write.c:679 > > > > > > > > The backtrace actually explains it all. We had a buffered write whose > > > > buffer was mmapped file on a filesystem with an HSM mark. Now the prefaulting > > > > of the buffer happens already (quite deep) under the filesystem freeze > > > > protection (obtained in vfs_write()) which breaks assumptions of HSM code > > > > and introduces potential deadlock of HSM handler in userspace with filesystem > > > > freezing. So we need to think how to deal with this case... > > > > > > Ouch. It's like the splice mess all over again. > > > Except we do not really care to make this use case work with HSM > > > in the sense that we do not care to have to fill in the mmaped file content > > > in this corner case - we just need to let HSM fail the access if content is > > > not available. > > > > > > If you remember, in one of my very early version of pre-content events, > > > the pre-content event (or maybe it was FAN_ACCESS_PERM itself) > > > carried a flag (I think it was called FAN_PRE_VFS) to communicate to > > > HSM service if it was safe to write to fs in the context of event handling. > > > > > > At the moment, I cannot think of any elegant way out of this use case > > > except annotating the event from fault_in_readable() as "unsafe-for-write". > > > This will relax the debugging code assertion and notify the HSM service > > > (via an event flag) that it can ALLOW/DENY, but it cannot fill the file. > > > Maybe we can reuse the FAN_ACCESS_PERM event to communicate > > > this case to HSM service. > > > > > > WDYT? > > > > I think that mmap was a mistake. > > What do you mean? > Isn't the fault hook required for your large executables use case? I mean the mmap syscall was a mistake ;). > > > > > Is there a way to tell if we're currently in a path that is under fsfreeze > > protection? > > Not at the moment. > At the moment, file_write_not_started() is not a reliable check > (has false positives) without CONFIG_LOCKDEP. > > > Just denying this case would be a simpler short term solution while > > we come up with a long term solution. I think your solution is fine, but I'd be > > just as happy with a simpler "this isn't allowed" solution. Thanks, > > Yeh, I don't mind that, but it's a bit of an overkill considering that > file with no content may in fact be rare. Agreed, I'm fine with your solution. Thanks, Josef