)]}'
{
  "commit": "648895da69ced90ca770fd941c3d9479a9d72c16",
  "tree": "d0dd60013f490cd62ce13ce418ba6ecee8a62265",
  "parents": [
    "8bb5b72dbd9ab91edf3ae616e7907c83c259beb0"
  ],
  "author": {
    "name": "David Howells",
    "email": "dhowells@redhat.com",
    "time": "Fri Mar 11 13:23:31 2022 +0000"
  },
  "committer": {
    "name": "Greg Kroah-Hartman",
    "email": "gregkh@linuxfoundation.org",
    "time": "Wed Mar 16 14:16:03 2022 +0100"
  },
  "message": "watch_queue: Fix filter limit check\n\ncommit c993ee0f9f81caf5767a50d1faeba39a0dc82af2 upstream.\n\nIn watch_queue_set_filter(), there are a couple of places where we check\nthat the filter type value does not exceed what the type_filter bitmap\ncan hold.  One place calculates the number of bits by:\n\n   if (tf[i].type \u003e\u003d sizeof(wfilter-\u003etype_filter) * 8)\n\nwhich is fine, but the second does:\n\n   if (tf[i].type \u003e\u003d sizeof(wfilter-\u003etype_filter) * BITS_PER_LONG)\n\nwhich is not.  This can lead to a couple of out-of-bounds writes due to\na too-large type:\n\n (1) __set_bit() on wfilter-\u003etype_filter\n (2) Writing more elements in wfilter-\u003efilters[] than we allocated.\n\nFix this by just using the proper WATCH_TYPE__NR instead, which is the\nnumber of types we actually know about.\n\nThe bug may cause an oops looking something like:\n\n  BUG: KASAN: slab-out-of-bounds in watch_queue_set_filter+0x659/0x740\n  Write of size 4 at addr ffff88800d2c66bc by task watch_queue_oob/611\n  ...\n  Call Trace:\n   \u003cTASK\u003e\n   dump_stack_lvl+0x45/0x59\n   print_address_description.constprop.0+0x1f/0x150\n   ...\n   kasan_report.cold+0x7f/0x11b\n   ...\n   watch_queue_set_filter+0x659/0x740\n   ...\n   __x64_sys_ioctl+0x127/0x190\n   do_syscall_64+0x43/0x90\n   entry_SYSCALL_64_after_hwframe+0x44/0xae\n\n  Allocated by task 611:\n   kasan_save_stack+0x1e/0x40\n   __kasan_kmalloc+0x81/0xa0\n   watch_queue_set_filter+0x23a/0x740\n   __x64_sys_ioctl+0x127/0x190\n   do_syscall_64+0x43/0x90\n   entry_SYSCALL_64_after_hwframe+0x44/0xae\n\n  The buggy address belongs to the object at ffff88800d2c66a0\n   which belongs to the cache kmalloc-32 of size 32\n  The buggy address is located 28 bytes inside of\n   32-byte region [ffff88800d2c66a0, ffff88800d2c66c0)\n\nFixes: c73be61cede5 (\"pipe: Add general notification queue support\")\nReported-by: Jann Horn \u003cjannh@google.com\u003e\nSigned-off-by: David Howells \u003cdhowells@redhat.com\u003e\nSigned-off-by: Linus Torvalds \u003ctorvalds@linux-foundation.org\u003e\nSigned-off-by: Greg Kroah-Hartman \u003cgregkh@linuxfoundation.org\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "c994d1b2cdbaa2abb313170749d0ee396a807a90",
      "old_mode": 33188,
      "old_path": "include/linux/watch_queue.h",
      "new_id": "3b9a40ae8bdba76dec83554989fa67f98cb59aba",
      "new_mode": 33188,
      "new_path": "include/linux/watch_queue.h"
    },
    {
      "type": "modify",
      "old_id": "65bd65fec23df051b6e6f5a040bb7863584ca151",
      "old_mode": 33188,
      "old_path": "kernel/watch_queue.c",
      "new_id": "e3f144d9602617c5b6a77d35799dc1c0d4e1988e",
      "new_mode": 33188,
      "new_path": "kernel/watch_queue.c"
    }
  ]
}
