)]}'
{
  "commit": "cb510b8172602a66467f3551b4be1911f5a7c8c2",
  "tree": "4905ee309e3147bb64f8a8a4446937424540fd5f",
  "parents": [
    "18d96779d92902d2113b6f39bd2d42e805fa05e7"
  ],
  "author": {
    "name": "Alexey Dobriyan",
    "email": "adobriyan@sw.ru",
    "time": "Sun Jul 15 23:40:39 2007 -0700"
  },
  "committer": {
    "name": "Linus Torvalds",
    "email": "torvalds@woody.linux-foundation.org",
    "time": "Mon Jul 16 09:05:45 2007 -0700"
  },
  "message": "seq_file: more atomicity in traverse()\n\nOriginal problem: in some circumstances seq_file interface can present\ninfinite proc file to the following script when normally said proc file is\nfinite:\n\n\twhile read line; do\n\t\t[do something with $line]\n\tdone \u003c/proc/$FILE\n\nbash, to implement such loop does essentially\n\n\tread(0, buf, 128);\n\t[find \\n]\n\tlseek(0, -difference, SEEK_CUR);\n\nConsider, proc file prints list of objects each of them consists of many\nlines, each line is shorter than 128 bytes.\n\nTwo objects in list, with -\u003eindex\u0027es being 0 and 1.  Current one is 1, as\nbash prints second object line by line.\n\nImagine first object being removed right before lseek().\ntraverse() will be called, because there is negative offset.\ntraverse() will reset -\u003eindex to 0 (!).\ntraverse() will call -\u003enext() and get NULL in any usual iterate-over-list\ncode using list_for_each_entry_continue() and such. There is one object in\nlist now after all...\ntraverse() will return 0, lseek() will update file position and pretend\neverything is OK.\n\nSo, what we have now: -\u003ef_pos points to place where second object will be\nprinted, but -\u003eindex is 0.  seq_read() instead of returning EOF, will start\nprinting first line of first object every time it\u0027s called, until enough\nobjects are added to -\u003ef_pos return in bounds.\n\nFix is to update -\u003eindex only after we\u0027re sure we saw enough objects down\nthe road.\n\nSigned-off-by: Alexey Dobriyan \u003cadobriyan@sw.ru\u003e\nCc: Al Viro \u003cviro@zeniv.linux.org.uk\u003e\nSigned-off-by: Andrew Morton \u003cakpm@linux-foundation.org\u003e\nSigned-off-by: Linus Torvalds \u003ctorvalds@linux-foundation.org\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "e8e51db4989d9123bd0d8c6eb13a3a0346bf30e7",
      "old_mode": 33188,
      "old_path": "fs/seq_file.c",
      "new_id": "bbb19be260ced1be701c3651f8e5b6a94a0bb593",
      "new_mode": 33188,
      "new_path": "fs/seq_file.c"
    }
  ]
}
