)]}'
{
  "commit": "1bc63ace6716f85fe792dcea65f46313874ade7b",
  "tree": "0b7708a912480a1ddd33e1bef0822fb024ac395f",
  "parents": [
    "3f78393e3888bca4fdd7aae9d405f27017334f87"
  ],
  "author": {
    "name": "Darrick J. Wong",
    "email": "djwong@kernel.org",
    "time": "Wed Apr 12 15:49:23 2023 +1000"
  },
  "committer": {
    "name": "COS Cherry Picker",
    "email": "cloud-image-release@prod.google.com",
    "time": "Wed Jun 07 14:33:14 2023 -0700"
  },
  "message": "xfs: verify buffer contents when we skip log replay\n\nUpstream commit 22ed903eee23a5b174e240f1cdfa9acf393a5210\n\nsyzbot detected a crash during log recovery:\n\nXFS (loop0): Mounting V5 Filesystem bfdc47fc-10d8-4eed-a562-11a831b3f791\nXFS (loop0): Torn write (CRC failure) detected at log block 0x180. Truncating head block from 0x200.\nXFS (loop0): Starting recovery (logdev: internal)\n\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\nBUG: KASAN: slab-out-of-bounds in xfs_btree_lookup_get_block+0x15c/0x6d0 fs/xfs/libxfs/xfs_btree.c:1813\nRead of size 8 at addr ffff88807e89f258 by task syz-executor132/5074\n\nCPU: 0 PID: 5074 Comm: syz-executor132 Not tainted 6.2.0-rc1-syzkaller #0\nHardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022\nCall Trace:\n \u003cTASK\u003e\n __dump_stack lib/dump_stack.c:88 [inline]\n dump_stack_lvl+0x1b1/0x290 lib/dump_stack.c:106\n print_address_description+0x74/0x340 mm/kasan/report.c:306\n print_report+0x107/0x1f0 mm/kasan/report.c:417\n kasan_report+0xcd/0x100 mm/kasan/report.c:517\n xfs_btree_lookup_get_block+0x15c/0x6d0 fs/xfs/libxfs/xfs_btree.c:1813\n xfs_btree_lookup+0x346/0x12c0 fs/xfs/libxfs/xfs_btree.c:1913\n xfs_btree_simple_query_range+0xde/0x6a0 fs/xfs/libxfs/xfs_btree.c:4713\n xfs_btree_query_range+0x2db/0x380 fs/xfs/libxfs/xfs_btree.c:4953\n xfs_refcount_recover_cow_leftovers+0x2d1/0xa60 fs/xfs/libxfs/xfs_refcount.c:1946\n xfs_reflink_recover_cow+0xab/0x1b0 fs/xfs/xfs_reflink.c:930\n xlog_recover_finish+0x824/0x920 fs/xfs/xfs_log_recover.c:3493\n xfs_log_mount_finish+0x1ec/0x3d0 fs/xfs/xfs_log.c:829\n xfs_mountfs+0x146a/0x1ef0 fs/xfs/xfs_mount.c:933\n xfs_fs_fill_super+0xf95/0x11f0 fs/xfs/xfs_super.c:1666\n get_tree_bdev+0x400/0x620 fs/super.c:1282\n vfs_get_tree+0x88/0x270 fs/super.c:1489\n do_new_mount+0x289/0xad0 fs/namespace.c:3145\n do_mount fs/namespace.c:3488 [inline]\n __do_sys_mount fs/namespace.c:3697 [inline]\n __se_sys_mount+0x2d3/0x3c0 fs/namespace.c:3674\n do_syscall_x64 arch/x86/entry/common.c:50 [inline]\n do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80\n entry_SYSCALL_64_after_hwframe+0x63/0xcd\nRIP: 0033:0x7f89fa3f4aca\nCode: 83 c4 08 5b 5d c3 66 2e 0f 1f 84 00 00 00 00 00 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 49 89 ca b8 a5 00 00 00 0f 05 \u003c48\u003e 3d 01 f0 ff ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48\nRSP: 002b:00007fffd5fb5ef8 EFLAGS: 00000206 ORIG_RAX: 00000000000000a5\nRAX: ffffffffffffffda RBX: 00646975756f6e2c RCX: 00007f89fa3f4aca\nRDX: 0000000020000100 RSI: 0000000020009640 RDI: 00007fffd5fb5f10\nRBP: 00007fffd5fb5f10 R08: 00007fffd5fb5f50 R09: 000000000000970d\nR10: 0000000000200800 R11: 0000000000000206 R12: 0000000000000004\nR13: 0000555556c6b2c0 R14: 0000000000200800 R15: 00007fffd5fb5f50\n \u003c/TASK\u003e\n\nThe fuzzed image contains an AGF with an obviously garbage\nagf_refcount_level value of 32, and a dirty log with a buffer log item\nfor that AGF.  The ondisk AGF has a higher LSN than the recovered log\nitem.  xlog_recover_buf_commit_pass2 reads the buffer, compares the\nLSNs, and decides to skip replay because the ondisk buffer appears to be\nnewer.\n\nUnfortunately, the ondisk buffer is corrupt, but recovery just read the\nbuffer with no buffer ops specified:\n\n\terror \u003d xfs_buf_read(mp-\u003em_ddev_targp, buf_f-\u003eblf_blkno,\n\t\t\tbuf_f-\u003eblf_len, buf_flags, \u0026bp, NULL);\n\nSkipping the buffer leaves its contents in memory unverified.  This sets\nus up for a kernel crash because xfs_refcount_recover_cow_leftovers\nreads the buffer (which is still around in XBF_DONE state, so no read\nverification) and creates a refcountbt cursor of height 32.  This is\nimpossible so we run off the end of the cursor object and crash.\n\nFix this by invoking the verifier on all skipped buffers and aborting\nlog recovery if the ondisk buffer is corrupt.  It might be smarter to\nforce replay the log item atop the buffer and then see if it\u0027ll pass the\nwrite verifier (like ext4 does) but for now let\u0027s go with the\nconservative option where we stop immediately.\n\nBUG\u003db/284438274\nTEST\u003dhttp://sponge2/2741a196-71d0-4b16-8a35-107285da3226\nSOURCE\u003dUPSTREAM(22ed903eee23a5b174e240f1cdfa9acf393a5210)\nRELEASE_NOTE\u003dFixed CVE-2023-2124.\n\ncos-patch: security-high\nLink: https://syzkaller.appspot.com/bug?extid\u003d7e9494b8b399902e994e\nSigned-off-by: Darrick J. Wong \u003cdjwong@kernel.org\u003e\nReviewed-by: Dave Chinner \u003cdchinner@redhat.com\u003e\nSigned-off-by: Dave Chinner \u003cdavid@fromorbit.com\u003e\nSigned-off-by: Michael Kochera \u003ckochera@google.com\u003e\nChange-Id: I9bd5ad6191fc4b42f06d78c79ba000c584fa1232\nReviewed-on: https://cos-review.googlesource.com/c/third_party/kernel/+/50290\nTested-by: Cusky Presubmit Bot \u003cpresubmit@cos-infra-prod.iam.gserviceaccount.com\u003e\nMain-Branch-Verified: Cusky Presubmit Bot \u003cpresubmit@cos-infra-prod.iam.gserviceaccount.com\u003e\nReviewed-by: Meena Shanmugam \u003cmeenashanmugam@google.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "991fbf1eb56402f98d05a93d8cdf866ce33d45d0",
      "old_mode": 33188,
      "old_path": "fs/xfs/xfs_buf_item_recover.c",
      "new_id": "e04e44ef14c6df058ea4600b0dab6296d888648f",
      "new_mode": 33188,
      "new_path": "fs/xfs/xfs_buf_item_recover.c"
    }
  ]
}
