)]}'
{
  "commit": "478ba09edc1f2f2ee27180a06150cb2d1a686f9c",
  "tree": "84615f1570076f3c5b74790496c62761db7c6662",
  "parents": [
    "987a64850996db22bbcf2c1d0a051446a343fa2c"
  ],
  "author": {
    "name": "Greg Kurz",
    "email": "groug@kaod.org",
    "time": "Wed Sep 23 22:11:45 2020 +0800"
  },
  "committer": {
    "name": "Dominique Martinet",
    "email": "asmadeus@codewreck.org",
    "time": "Tue Nov 03 09:29:56 2020 +0100"
  },
  "message": "fs/9p: search open fids first\n\nA previous patch fixed the \"create-unlink-getattr\" idiom: if getattr is\ncalled on an unlinked file, we try to find an open fid attached to the\ncorresponding inode.\n\nWe have a similar issue with file permissions and setattr:\n\nopen(\"./test.txt\", O_RDWR|O_CREAT, 0666) \u003d 4\nchmod(\"./test.txt\", 0)                  \u003d 0\ntruncate(\"./test.txt\", 0)               \u003d -1 EACCES (Permission denied)\nftruncate(4, 0)                         \u003d -1 EACCES (Permission denied)\n\nThe failure is expected with truncate() but not with ftruncate().\n\nThis happens because the lookup code does find a matching fid in the\ndentry list. Unfortunately, this is not an open fid and the server\nwill be forced to rely on the path name, rather than on an open file\ndescriptor. This is the case in QEMU: the setattr operation will use\ntruncate() and fail because of bad write permissions.\n\nThis patch changes the logic in the lookup code, so that we consider\nopen fids first. It gives a chance to the server to match this open\nfid to an open file descriptor and use ftruncate() instead of truncate().\nThis does not change the current behaviour for truncate() and other\npath name based syscalls, since file permissions are checked earlier\nin the VFS layer.\n\nWith this patch, we get:\n\nopen(\"./test.txt\", O_RDWR|O_CREAT, 0666) \u003d 4\nchmod(\"./test.txt\", 0)                  \u003d 0\ntruncate(\"./test.txt\", 0)               \u003d -1 EACCES (Permission denied)\nftruncate(4, 0)                         \u003d 0\n\nLink: http://lkml.kernel.org/r/20200923141146.90046-4-jianyong.wu@arm.com\nSigned-off-by: Greg Kurz \u003cgroug@kaod.org\u003e\nSigned-off-by: Jianyong Wu \u003cjianyong.wu@arm.com\u003e\nSigned-off-by: Dominique Martinet \u003casmadeus@codewreck.org\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "d11dd430590dc96e227cfba61cb6530782a4978f",
      "old_mode": 33188,
      "old_path": "fs/9p/fid.c",
      "new_id": "0b23b0fe6c5155c8e2b0978395a8312c9561b3ef",
      "new_mode": 33188,
      "new_path": "fs/9p/fid.c"
    }
  ]
}
