)]}'
{
  "commit": "c8585e2312256e860351eb05836e6a3518026cff",
  "tree": "15eff2953c6d741ffd909a1b115d4bf70bd67956",
  "parents": [
    "fc52ee68eb28fbb3d7451ad556f2571f729deac8"
  ],
  "author": {
    "name": "valis",
    "email": "sec@valis.email",
    "time": "Fri Sep 01 12:22:37 2023 -0400"
  },
  "committer": {
    "name": "COS Cherry Picker",
    "email": "cloud-image-release@prod.google.com",
    "time": "Fri Sep 22 12:43:21 2023 -0700"
  },
  "message": "net: sched: sch_qfq: Fix UAF in qfq_dequeue()\n\n[ Upstream commit 8fc134fee27f2263988ae38920bc03da416b03d8 ]\n\nWhen the plug qdisc is used as a class of the qfq qdisc it could trigger a\nUAF. This issue can be reproduced with following commands:\n\n  tc qdisc add dev lo root handle 1: qfq\n  tc class add dev lo parent 1: classid 1:1 qfq weight 1 maxpkt 512\n  tc qdisc add dev lo parent 1:1 handle 2: plug\n  tc filter add dev lo parent 1: basic classid 1:1\n  ping -c1 127.0.0.1\n\nand boom:\n\n[  285.353793] BUG: KASAN: slab-use-after-free in qfq_dequeue+0xa7/0x7f0\n[  285.354910] Read of size 4 at addr ffff8880bad312a8 by task ping/144\n[  285.355903]\n[  285.356165] CPU: 1 PID: 144 Comm: ping Not tainted 6.5.0-rc3+ #4\n[  285.357112] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-2 04/01/2014\n[  285.358376] Call Trace:\n[  285.358773]  \u003cIRQ\u003e\n[  285.359109]  dump_stack_lvl+0x44/0x60\n[  285.359708]  print_address_description.constprop.0+0x2c/0x3c0\n[  285.360611]  kasan_report+0x10c/0x120\n[  285.361195]  ? qfq_dequeue+0xa7/0x7f0\n[  285.361780]  qfq_dequeue+0xa7/0x7f0\n[  285.362342]  __qdisc_run+0xf1/0x970\n[  285.362903]  net_tx_action+0x28e/0x460\n[  285.363502]  __do_softirq+0x11b/0x3de\n[  285.364097]  do_softirq.part.0+0x72/0x90\n[  285.364721]  \u003c/IRQ\u003e\n[  285.365072]  \u003cTASK\u003e\n[  285.365422]  __local_bh_enable_ip+0x77/0x90\n[  285.366079]  __dev_queue_xmit+0x95f/0x1550\n[  285.366732]  ? __pfx_csum_and_copy_from_iter+0x10/0x10\n[  285.367526]  ? __pfx___dev_queue_xmit+0x10/0x10\n[  285.368259]  ? __build_skb_around+0x129/0x190\n[  285.368960]  ? ip_generic_getfrag+0x12c/0x170\n[  285.369653]  ? __pfx_ip_generic_getfrag+0x10/0x10\n[  285.370390]  ? csum_partial+0x8/0x20\n[  285.370961]  ? raw_getfrag+0xe5/0x140\n[  285.371559]  ip_finish_output2+0x539/0xa40\n[  285.372222]  ? __pfx_ip_finish_output2+0x10/0x10\n[  285.372954]  ip_output+0x113/0x1e0\n[  285.373512]  ? __pfx_ip_output+0x10/0x10\n[  285.374130]  ? icmp_out_count+0x49/0x60\n[  285.374739]  ? __pfx_ip_finish_output+0x10/0x10\n[  285.375457]  ip_push_pending_frames+0xf3/0x100\n[  285.376173]  raw_sendmsg+0xef5/0x12d0\n[  285.376760]  ? do_syscall_64+0x40/0x90\n[  285.377359]  ? __static_call_text_end+0x136578/0x136578\n[  285.378173]  ? do_syscall_64+0x40/0x90\n[  285.378772]  ? kasan_enable_current+0x11/0x20\n[  285.379469]  ? __pfx_raw_sendmsg+0x10/0x10\n[  285.380137]  ? __sock_create+0x13e/0x270\n[  285.380673]  ? __sys_socket+0xf3/0x180\n[  285.381174]  ? __x64_sys_socket+0x3d/0x50\n[  285.381725]  ? entry_SYSCALL_64_after_hwframe+0x6e/0xd8\n[  285.382425]  ? __rcu_read_unlock+0x48/0x70\n[  285.382975]  ? ip4_datagram_release_cb+0xd8/0x380\n[  285.383608]  ? __pfx_ip4_datagram_release_cb+0x10/0x10\n[  285.384295]  ? preempt_count_sub+0x14/0xc0\n[  285.384844]  ? __list_del_entry_valid+0x76/0x140\n[  285.385467]  ? _raw_spin_lock_bh+0x87/0xe0\n[  285.386014]  ? __pfx__raw_spin_lock_bh+0x10/0x10\n[  285.386645]  ? release_sock+0xa0/0xd0\n[  285.387148]  ? preempt_count_sub+0x14/0xc0\n[  285.387712]  ? freeze_secondary_cpus+0x348/0x3c0\n[  285.388341]  ? aa_sk_perm+0x177/0x390\n[  285.388856]  ? __pfx_aa_sk_perm+0x10/0x10\n[  285.389441]  ? check_stack_object+0x22/0x70\n[  285.390032]  ? inet_send_prepare+0x2f/0x120\n[  285.390603]  ? __pfx_inet_sendmsg+0x10/0x10\n[  285.391172]  sock_sendmsg+0xcc/0xe0\n[  285.391667]  __sys_sendto+0x190/0x230\n[  285.392168]  ? __pfx___sys_sendto+0x10/0x10\n[  285.392727]  ? kvm_clock_get_cycles+0x14/0x30\n[  285.393328]  ? set_normalized_timespec64+0x57/0x70\n[  285.393980]  ? _raw_spin_unlock_irq+0x1b/0x40\n[  285.394578]  ? __x64_sys_clock_gettime+0x11c/0x160\n[  285.395225]  ? __pfx___x64_sys_clock_gettime+0x10/0x10\n[  285.395908]  ? _copy_to_user+0x3e/0x60\n[  285.396432]  ? exit_to_user_mode_prepare+0x1a/0x120\n[  285.397086]  ? syscall_exit_to_user_mode+0x22/0x50\n[  285.397734]  ? do_syscall_64+0x71/0x90\n[  285.398258]  __x64_sys_sendto+0x74/0x90\n[  285.398786]  do_syscall_64+0x64/0x90\n[  285.399273]  ? exit_to_user_mode_prepare+0x1a/0x120\n[  285.399949]  ? syscall_exit_to_user_mode+0x22/0x50\n[  285.400605]  ? do_syscall_64+0x71/0x90\n[  285.401124]  entry_SYSCALL_64_after_hwframe+0x6e/0xd8\n[  285.401807] RIP: 0033:0x495726\n[  285.402233] Code: ff ff ff f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b8 0f 1f 00 41 89 ca 64 8b 04 25 18 00 00 00 85 c0 75 11 b8 2c 00 00 00 0f 09\n[  285.404683] RSP: 002b:00007ffcc25fb618 EFLAGS: 00000246 ORIG_RAX: 000000000000002c\n[  285.405677] RAX: ffffffffffffffda RBX: 0000000000000040 RCX: 0000000000495726\n[  285.406628] RDX: 0000000000000040 RSI: 0000000002518750 RDI: 0000000000000000\n[  285.407565] RBP: 00000000005205ef R08: 00000000005f8838 R09: 000000000000001c\n[  285.408523] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000002517634\n[  285.409460] R13: 00007ffcc25fb6f0 R14: 0000000000000003 R15: 0000000000000000\n[  285.410403]  \u003c/TASK\u003e\n[  285.410704]\n[  285.410929] Allocated by task 144:\n[  285.411402]  kasan_save_stack+0x1e/0x40\n[  285.411926]  kasan_set_track+0x21/0x30\n[  285.412442]  __kasan_slab_alloc+0x55/0x70\n[  285.412973]  kmem_cache_alloc_node+0x187/0x3d0\n[  285.413567]  __alloc_skb+0x1b4/0x230\n[  285.414060]  __ip_append_data+0x17f7/0x1b60\n[  285.414633]  ip_append_data+0x97/0xf0\n[  285.415144]  raw_sendmsg+0x5a8/0x12d0\n[  285.415640]  sock_sendmsg+0xcc/0xe0\n[  285.416117]  __sys_sendto+0x190/0x230\n[  285.416626]  __x64_sys_sendto+0x74/0x90\n[  285.417145]  do_syscall_64+0x64/0x90\n[  285.417624]  entry_SYSCALL_64_after_hwframe+0x6e/0xd8\n[  285.418306]\n[  285.418531] Freed by task 144:\n[  285.418960]  kasan_save_stack+0x1e/0x40\n[  285.419469]  kasan_set_track+0x21/0x30\n[  285.419988]  kasan_save_free_info+0x27/0x40\n[  285.420556]  ____kasan_slab_free+0x109/0x1a0\n[  285.421146]  kmem_cache_free+0x1c2/0x450\n[  285.421680]  __netif_receive_skb_core+0x2ce/0x1870\n[  285.422333]  __netif_receive_skb_one_core+0x97/0x140\n[  285.423003]  process_backlog+0x100/0x2f0\n[  285.423537]  __napi_poll+0x5c/0x2d0\n[  285.424023]  net_rx_action+0x2be/0x560\n[  285.424510]  __do_softirq+0x11b/0x3de\n[  285.425034]\n[  285.425254] The buggy address belongs to the object at ffff8880bad31280\n[  285.425254]  which belongs to the cache skbuff_head_cache of size 224\n[  285.426993] The buggy address is located 40 bytes inside of\n[  285.426993]  freed 224-byte region [ffff8880bad31280, ffff8880bad31360)\n[  285.428572]\n[  285.428798] The buggy address belongs to the physical page:\n[  285.429540] page:00000000f4b77674 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0xbad31\n[  285.430758] flags: 0x100000000000200(slab|node\u003d0|zone\u003d1)\n[  285.431447] page_type: 0xffffffff()\n[  285.431934] raw: 0100000000000200 ffff88810094a8c0 dead000000000122 0000000000000000\n[  285.432757] raw: 0000000000000000 00000000800c000c 00000001ffffffff 0000000000000000\n[  285.433562] page dumped because: kasan: bad access detected\n[  285.434144]\n[  285.434320] Memory state around the buggy address:\n[  285.434828]  ffff8880bad31180: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc\n[  285.435580]  ffff8880bad31200: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc\n[  285.436264] \u003effff8880bad31280: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb\n[  285.436777]                                   ^\n[  285.437106]  ffff8880bad31300: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc\n[  285.437616]  ffff8880bad31380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc\n[  285.438126] \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\n[  285.438662] Disabling lock debugging due to kernel taint\n\nFix this by:\n1. Changing sch_plug\u0027s .peek handler to qdisc_peek_dequeued(), a\nfunction compatible with non-work-conserving qdiscs\n2. Checking the return value of qdisc_dequeue_peeked() in sch_qfq.\n\nBUG\u003db/301063661\nTEST\u003dpresubmit\nRELEASE_NOTE\u003dFix CVE-2023-4921 in the Linux Kernel.\n\ncos-patch: security-high\nFixes: 462dbc9101ac (\"pkt_sched: QFQ Plus: fair-queueing service at DRR cost\")\nReported-by: valis \u003csec@valis.email\u003e\nChange-Id: I76324fdc5ec8dbf7b1e6ad7458c1d7b8bdf3d164\nSigned-off-by: valis \u003csec@valis.email\u003e\nSigned-off-by: Jamal Hadi Salim \u003cjhs@mojatatu.com\u003e\nLink: https://lore.kernel.org/r/20230901162237.11525-1-jhs@mojatatu.com\nSigned-off-by: Paolo Abeni \u003cpabeni@redhat.com\u003e\nSigned-off-by: Sasha Levin \u003csashal@kernel.org\u003e\nReviewed-on: https://cos-review.googlesource.com/c/third_party/kernel/+/57669\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: Oleksandr Tymoshenko \u003covt@google.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "ea8c4a7174bba0880851be8631f9234bdecc3ada",
      "old_mode": 33188,
      "old_path": "net/sched/sch_plug.c",
      "new_id": "35f49edf63dbf2cbdb7010871d7e430cd9d6ed97",
      "new_mode": 33188,
      "new_path": "net/sched/sch_plug.c"
    },
    {
      "type": "modify",
      "old_id": "e150d08f182d81d4b8ebfbad751a7b892589dac7",
      "old_mode": 33188,
      "old_path": "net/sched/sch_qfq.c",
      "new_id": "ed01634af82c2108d30618b9cf1152e32ab3e922",
      "new_mode": 33188,
      "new_path": "net/sched/sch_qfq.c"
    }
  ]
}
