)]}'
{
  "commit": "c3d355f427cea70fbe31b49e21f1915dbf37f2e6",
  "tree": "4124fa4b77cf2b7fe571d6f3c3e9ed28cf075299",
  "parents": [
    "79b496ebe382866e3a05090b7dc9ae95e85e65b2"
  ],
  "author": {
    "name": "Edvard Conrad",
    "email": "edvard@tuta.io",
    "time": "Thu Oct 29 22:18:40 2026 +0100"
  },
  "committer": {
    "name": "Christian Brauner",
    "email": "brauner@kernel.org",
    "time": "Fri Oct 30 15:57:59 2026 +0100"
  },
  "message": "fs: let backing files inherit FMODE_NONOTIFY from the user file\n\nWhen fanotify reports a permission event, copy_event_to_user() creates\nthe event fd with dentry_open_nonotify(), so that the listener\u0027s use of\nthat fd does not generate further events. If the event\u0027s path is on a\nstacked filesystem, the stacked filesystem\u0027s -\u003eopen() opens the real\nfile with backing_file_open(). Since commit ebe559609d78 (\"fs: get rid\nof __FMODE_NONOTIFY kludge\"), FMODE_NONOTIFY lives in f_mode only and\nthe backing file does not inherit it: it is allocated with the default\nfsnotify mode, and fsnotify_open_perm_and_set_mode() raises FS_OPEN_PERM\non the real path if the backing filesystem has permission event\nwatchers.\n\nBefore that commit __FMODE_NONOTIFY travelled in f_flags, and overlayfs\ncopies the user file\u0027s f_flags into the backing open\n(ovl_open_realfile()), so the backing file was exempt implicitly. Commit\nbc2473c90fca (\"ovl: enable fsnotify events on underlying real files\")\nrelied on that when it dropped FMODE_NONOTIFY from OVL_OPEN_FLAGS.\n\nThe nested event is queued to the same group, from inside the\nlistener\u0027s read(2), and can only be answered by another reader thread\nof that group. A listener holding filesystem marks on both the stacked\nand the backing filesystem therefore deadlocks as soon as all of its\nreader threads are inside such a read(2) at the same time, and every\nother task that touches a marked filesystem queues up behind it.\n\nObserved with a commercial anti-malware agent (16 reader threads) on an\nostree/composefs host: / is an overlayfs whose data layer is the ostree\nobject store on the same btrfs that holds /etc and /home, and a\nsystemd-sysext overlay sits on /usr. Every on-demand scan of /usr wedged\nthe whole machine until the group was killed. Stack of a blocked reader\nthread on 7.2.7:\n\n  fanotify_get_response\n  fanotify_handle_event\n  send_to_group\n  fsnotify\n  __fsnotify_parent\n  do_dentry_open\n  vfs_open\n  backing_file_open\n  ovl_open_realfile [overlay]\n  ovl_open [overlay]\n  do_dentry_open\n  vfs_open\n  backing_file_open\n  ovl_open_realfile [overlay]\n  ovl_open [overlay]\n  do_dentry_open\n  vfs_open\n  dentry_open_nonotify\n  copy_event_to_user\n  fanotify_read\n  vfs_read\n  ksys_read\n\nUserspace cannot avoid this: the backing open happens while the kernel\nbuilds the fd, before the event is reported, and fid reporting is not\navailable for permission event classes.\n\nMake a backing file inherit FMODE_NONOTIFY when the user file it is\nopened for must not generate events. This restores the pre-6.14\nbehaviour for the fds that fanotify creates (and for any other\nFMODE_NONOTIFY file), while ordinary opens through a stacked filesystem\nkeep generating events on the real path, as intended by bc2473c90fca.\n\nVerified with a self-contained reproducer (private tmpfs lower layers, an\noverlayfs over them, FAN_OPEN_PERM filesystem marks on the overlay and on\none lower layer, a child opening a file through the overlay) in a qemu\nVM on this tree built with defconfig plus OVERLAY_FS, FANOTIFY and\nFANOTIFY_ACCESS_PERMISSIONS: without this patch the listener\u0027s read(2)\nnever returns and the child\u0027s open is released only by the listener\u0027s\ndeath; with it read(2) returns, the event is answered and the open\ncompletes.\n\nbacking_tmpfile_open() is left alone: its only caller is\novl_create_tmpfile(), whose user file is a regular overlayfs file.\n\nFixes: ebe559609d78 (\"fs: get rid of __FMODE_NONOTIFY kludge\")\nCc: stable@vger.kernel.org\nReviewed-by: Amir Goldstein \u003camir73il@gmail.com\u003e\nSigned-off-by: Edvard Conrad \u003cedvard@tuta.io\u003e\nLink: https://patch.msgid.link/P58Wrer--F-9@tuta.io\nSigned-off-by: Christian Brauner (Amutable) \u003cbrauner@kernel.org\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "ad573f5153c7c7ebf1e91ef66e431b08fdde3626",
      "old_mode": 33188,
      "old_path": "fs/backing-file.c",
      "new_id": "5780f60662d0754182a5764a4a7a0b5266454714",
      "new_mode": 33188,
      "new_path": "fs/backing-file.c"
    }
  ]
}
