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 EDD07C021B8 for ; Tue, 4 Mar 2025 20:27:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 393736B0082; Tue, 4 Mar 2025 15:27:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3444A6B0083; Tue, 4 Mar 2025 15:27:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1E5956B0085; Tue, 4 Mar 2025 15:27:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 003926B0082 for ; Tue, 4 Mar 2025 15:27:35 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 843E6B1F28 for ; Tue, 4 Mar 2025 20:27:35 +0000 (UTC) X-FDA: 83185004070.21.D6B34EE Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) by imf25.hostedemail.com (Postfix) with ESMTP id 602D2A0011 for ; Tue, 4 Mar 2025 20:27:33 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=cGo4+k3U; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf25.hostedemail.com: domain of amir73il@gmail.com designates 209.85.218.41 as permitted sender) smtp.mailfrom=amir73il@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1741120053; 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=gn9ky4z5dMSLl5RskSlFZc3RtSEkfN0OwnmLO2V6eds=; b=X0CgTMBfyLJ/nIwAlfnz9nW7Umej3urh3sK5eghu5rcWEI/bGtDDvDNT5hE5yEbifvWev3 sfxTr3qotTyEtNZYcn3OHBbnRrz9XgSMtVd+Yr8Dl3z3+G2PQbF4SrgA5qRZq3F37PuEPn wXVGpxx3fFBJdct/M37jmZ79gi9sBuA= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=cGo4+k3U; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf25.hostedemail.com: domain of amir73il@gmail.com designates 209.85.218.41 as permitted sender) smtp.mailfrom=amir73il@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1741120053; a=rsa-sha256; cv=none; b=wT9ww9EfmFxOh1Iv6HO9fBu4X7p2msK7/eP3Jbh/6BKKqIoHf32MFELt1R+US+alHAHe5i +EAMyJdugiRCggRBNGG8J+zo/mRRMelnCEy5Jx/qro4UQiBiPxSTlXUchj/kC9P/593Ylt Y2DjYm4lQoG5OHsOq0uTRBi9A0XBnMQ= Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-abf518748cbso646976366b.2 for ; Tue, 04 Mar 2025 12:27:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741120052; x=1741724852; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=gn9ky4z5dMSLl5RskSlFZc3RtSEkfN0OwnmLO2V6eds=; b=cGo4+k3U5Cb8gF7dufJR9eYb1QRUoaZD3ZlTOkUUWf5kF6unVXH01n8VYrtMsLOyNj qeRxi8PyGSVmWyxkp5Ly98cGbOsQACV73dy2qlpOOYFoWW/ifGareyop2ycTVzxG/GAc pk98UvdQiSyGt5jAFN/MT6CXgwLCpyeIUcId5z6aaxAQoI1QsHySP5o1GyIzY0UZd1hg 2yhdcIN3kQKQ2L0PrlrlQjEI04Wp+FuwUmJPLk8MYzt50OWzWT93qB/wusUUVLVsMKFl U9iv0kcHJEFq1QPxMbnagZLSdQiyFrzgj2YPuV5x4eUwz1J3NN+63K5urLP8rRc+SY6P LxIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741120052; x=1741724852; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gn9ky4z5dMSLl5RskSlFZc3RtSEkfN0OwnmLO2V6eds=; b=P3pARAe5dn3v53+/gAw2t7ZGOCrBFxP3p6pRl4VHUYHk7kqv+BkJ3luFWp+DdN5gFI ZvBblLXLfsKnFTH1UJGDgz4OzqF+CU2gEAQrTxb23XhVlQQnd5qjqwZxnrxOBE5Zz2Cl n2FAo3AIFLoSS1TsPZV1lQB7p7UkWY3DrFM1958yZn1tF84YNaiivEqSBkobSv/IE58i TLf63Oa7V/owy6HprIVPDaQlhfP+Zvw6KHIA5Ih281W0PhWz+25+fk63vpYFwA7KZA9a vCBxS0oAd0raE8jAWhnEPntx9eKygJjh5ebP8g3g/L2YUTsObTexz/2AgxsxmvWUEVcV 4n9Q== X-Forwarded-Encrypted: i=1; AJvYcCWOxTMPsgdOpsv4ZUYUTB6eQbvtPM5jDZKH2b3g7DPK34bsez0JieLzgi+gRY18XYQ7zE1C1fPD7Q==@kvack.org X-Gm-Message-State: AOJu0Ywu6ePA5V/voXQVuNh7READJYCZXIw11WIaX3Xzq4i5VO0VueLu UngiwULPXoLxG4rqNK97k9zCJNlX2v8CeuaDOilDXIZI9Bq628QXNTt2G/u4NzcvnL/SS3HITIP x+WVxtMLALAcHu6W2e2Vj3MVJbao= X-Gm-Gg: ASbGncttWB2hpjvCMOK7IbxnTMazFiknQnF6u+umlHdiXEi4xsxxuoSQpWzI0b296WD aMZ8dsZA7TLGKrB6lvFf28ZIAxYkQvHDyH16tvMk9tBDtgb3EjWdNpOLr9a/bDYCObtMGlo8Xzm yHAPqOL1sopOengYsUUSO1E9chVQ== X-Google-Smtp-Source: AGHT+IHAIoJ0E+pxrzOSe5eeebBWS9Dt9S9yaMu+lz0dKVZefv8M1z2h5EJXZXlzDsPBXuOKAWHb5+UGNnCVo3QTjv8= X-Received: by 2002:a17:906:4fc7:b0:ac2:551:4a38 with SMTP id a640c23a62f3a-ac20d925104mr50035866b.26.1741120051525; Tue, 04 Mar 2025 12:27:31 -0800 (PST) MIME-Version: 1.0 References: <67a487f7.050a0220.19061f.05fc.GAE@google.com> <67c4881e.050a0220.1dee4d.0054.GAE@google.com> <7ehxrhbvehlrjwvrduoxsao5k3x4aw275patsb3krkwuq573yv@o2hskrfawbnc> <20250304161509.GA4047943@perftesting> In-Reply-To: <20250304161509.GA4047943@perftesting> From: Amir Goldstein Date: Tue, 4 Mar 2025 21:27:20 +0100 X-Gm-Features: AQ5f1Jo62ERWo7QAFZgtTJaHo7SsHhqhpis6fOJNRGSu3Cz1rXE-1Ym7ZbVDGEM Message-ID: Subject: Re: [syzbot] [xfs?] WARNING in fsnotify_file_area_perm To: Josef Bacik 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 602D2A0011 X-Rspam-User: X-Stat-Signature: fgec8nkoax3hm8cfs6oqagzqyj14xo9y X-HE-Tag: 1741120053-674232 X-HE-Meta: U2FsdGVkX1+EhNaqb3bQFZNq1A4K4VZbhigOJzfpXzT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mw0FYWdokQsL6p+AYdM9aifTHktt3ZN7d2fooavGoZSSajJRMVgPTLKQEWxcBi8ED1+YW6Xdryl9jHgiLxwlBiDQS1YX8ii3Fk55TMReachFGsiq9NH06zM4YH/4eGWLYGWOsZybAEMjju+72HF0o1CPdk1cBBiDHQGVt0pmd5qNgwP2gbfk0Yoc4wTnQKauhb7hX6Ym+LGwvIDhys2IMFNAS4Bc5H1fMlxokXQKPMMr6MErF7YlcK4qPo54Pn+XdSOAt1Uvw8LVUD/Jk6/ul0gmnyoJddLBb5g+WzguLvbW4dHgzr44GTJZJ0HU29UMdlmn2Sn+moJwS0vfVm9Paex3ko6QAPgLdfxIQyk1SCeaOFRzzalOVrHYelcbyMwsO9VhpkuycgdZc38EQIYj34vzfN9cuPLCdWEzPpnZCA1dHFNT7fDxK0QU67Fs+9Zvet57jDZ4BtI8 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 4, 2025 at 5:15=E2=80=AFPM Josef Bacik w= rote: > > On Tue, Mar 04, 2025 at 04:09:16PM +0100, Amir Goldstein wrote: > > On Tue, Mar 4, 2025 at 12:06=E2=80=AFPM 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 fsnotif= y_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-rc= 4-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=3D--) > > > > pc : fsnotify_file_area_perm+0x20c/0x25c include/linux/fsnotify.h:1= 45 > > > > lr : fsnotify_file_area_perm+0x20c/0x25c include/linux/fsnotify.h:1= 45 > > > > 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:51= 0 > > > > 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 pre= faulting > > > of the buffer happens already (quite deep) under the filesystem freez= e > > > protection (obtained in vfs_write()) which breaks assumptions of HSM = code > > > and introduces potential deadlock of HSM handler in userspace with fi= lesystem > > > 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 con= tent > > in this corner case - we just need to let HSM fail the access if conten= t 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 handl= ing. > > > > 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-wri= te". > > 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? > > Is there a way to tell if we're currently in a path that is under fsfreez= e > 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. Thanks, Amir.