Blame SOURCES/CVE-2023-4921.patch

edb02f
From 84eda7845563ee9c0cc215fe9d0a3c67cb4903fd Mon Sep 17 00:00:00 2001
edb02f
From: Ryan Sullivan <rysulliv@redhat.com>
edb02f
Date: Thu, 1 Feb 2024 14:36:30 -0500
edb02f
Subject: [KPATCH CVE-2023-4921] kpatch fixes for CVE-2023-4921
edb02f
edb02f
Kernels:
edb02f
3.10.0-1160.95.1.el7
edb02f
3.10.0-1160.99.1.el7
edb02f
3.10.0-1160.102.1.el7
edb02f
3.10.0-1160.105.1.el7
edb02f
3.10.0-1160.108.1.el7
edb02f
edb02f
Kpatch-MR: https://gitlab.com/redhat/prdsc/rhel/src/kpatch/rhel-7/-/merge_requests/67
edb02f
Approved-by: Joe Lawrence (@joe.lawrence)
edb02f
Changes since last build:
edb02f
[x86_64]:
edb02f
igb_main.o: changed function: igb_configure
edb02f
l2cap_core.o: changed function: l2cap_chan_hold
edb02f
l2cap_core.o: changed function: l2cap_conn_get
edb02f
l2cap_core.o: changed function: l2cap_global_chan_by_psm
edb02f
l2cap_core.o: changed function: l2cap_recv_frame
edb02f
l2cap_core.o: new function: klp_l2cap_le_sig_cmd
edb02f
sch_atm.o: changed function: atm_tc_peek
edb02f
sch_atm.o: changed function: sch_atm_dequeue
edb02f
sch_drr.o: changed function: drr_dequeue
edb02f
sch_dsmark.o: changed function: dsmark_peek
edb02f
sch_hfsc.o: changed function: hfsc_enqueue
edb02f
sch_hfsc.o: changed function: qdisc_peek_len
edb02f
sch_multiq.o: changed function: multiq_peek
edb02f
sch_prio.o: changed function: prio_peek
edb02f
sch_qfq.o: changed function: qfq_change_class
edb02f
sch_qfq.o: changed function: qfq_dequeue
edb02f
sch_red.o: changed function: red_peek
edb02f
sch_sfb.o: changed function: sfb_peek
edb02f
sch_tbf.o: changed function: tbf_dequeue
edb02f
edb02f
[ppc64le]:
edb02f
l2cap_core.o: changed function: __l2cap_chan_add
edb02f
l2cap_core.o: changed function: __l2cap_physical_cfm
edb02f
l2cap_core.o: changed function: __set_monitor_timer
edb02f
l2cap_core.o: changed function: __set_retrans_timer.part.24
edb02f
l2cap_core.o: changed function: l2cap_ack_timeout
edb02f
l2cap_core.o: changed function: l2cap_build_conf_req
edb02f
l2cap_core.o: changed function: l2cap_chan_busy
edb02f
l2cap_core.o: changed function: l2cap_chan_close
edb02f
l2cap_core.o: changed function: l2cap_chan_connect
edb02f
l2cap_core.o: changed function: l2cap_chan_del
edb02f
l2cap_core.o: changed function: l2cap_chan_hold
edb02f
l2cap_core.o: changed function: l2cap_chan_put
edb02f
l2cap_core.o: changed function: l2cap_chan_send
edb02f
l2cap_core.o: changed function: l2cap_chan_timeout
edb02f
l2cap_core.o: changed function: l2cap_conn_add.part.28
edb02f
l2cap_core.o: changed function: l2cap_conn_del
edb02f
l2cap_core.o: changed function: l2cap_conn_start
edb02f
l2cap_core.o: changed function: l2cap_connect
edb02f
l2cap_core.o: changed function: l2cap_connect_cfm
edb02f
l2cap_core.o: changed function: l2cap_connect_create_rsp
edb02f
l2cap_core.o: changed function: l2cap_data_channel
edb02f
l2cap_core.o: changed function: l2cap_disconn_cfm
edb02f
l2cap_core.o: changed function: l2cap_do_create
edb02f
l2cap_core.o: changed function: l2cap_do_start
edb02f
l2cap_core.o: changed function: l2cap_ertm_resend
edb02f
l2cap_core.o: changed function: l2cap_ertm_send
edb02f
l2cap_core.o: changed function: l2cap_global_fixed_chan
edb02f
l2cap_core.o: changed function: l2cap_handle_rej
edb02f
l2cap_core.o: changed function: l2cap_handle_srej
edb02f
l2cap_core.o: changed function: l2cap_logical_cfm
edb02f
l2cap_core.o: changed function: l2cap_monitor_timeout
edb02f
l2cap_core.o: changed function: l2cap_move_done
edb02f
l2cap_core.o: changed function: l2cap_move_setup
edb02f
l2cap_core.o: changed function: l2cap_parse_conf_rsp.constprop.36
edb02f
l2cap_core.o: changed function: l2cap_pass_to_tx
edb02f
l2cap_core.o: changed function: l2cap_process_reqseq
edb02f
l2cap_core.o: changed function: l2cap_recv_frame
edb02f
l2cap_core.o: changed function: l2cap_retrans_timeout
edb02f
l2cap_core.o: changed function: l2cap_retransmit_all
edb02f
l2cap_core.o: changed function: l2cap_rx
edb02f
l2cap_core.o: changed function: l2cap_rx_state_recv
edb02f
l2cap_core.o: changed function: l2cap_security_cfm
edb02f
l2cap_core.o: changed function: l2cap_send_ack
edb02f
l2cap_core.o: changed function: l2cap_send_efs_conf_rsp
edb02f
l2cap_core.o: changed function: l2cap_send_i_or_rr_or_rnr
edb02f
l2cap_core.o: changed function: l2cap_send_move_chan_cfm
edb02f
l2cap_core.o: changed function: l2cap_send_move_chan_cfm_icid
edb02f
l2cap_core.o: changed function: l2cap_send_move_chan_req
edb02f
l2cap_core.o: changed function: l2cap_send_rr_or_rnr
edb02f
l2cap_core.o: changed function: l2cap_send_sframe
edb02f
l2cap_core.o: changed function: l2cap_send_srej
edb02f
l2cap_core.o: changed function: l2cap_send_srej_tail
edb02f
l2cap_core.o: changed function: l2cap_start_connection
edb02f
l2cap_core.o: new function: l2cap_connect_req
edb02f
sch_atm.o: changed function: atm_tc_bind_filter
edb02f
sch_atm.o: changed function: atm_tc_change
edb02f
sch_atm.o: changed function: atm_tc_delete
edb02f
sch_atm.o: changed function: atm_tc_destroy
edb02f
sch_atm.o: changed function: atm_tc_enqueue
edb02f
sch_atm.o: changed function: atm_tc_find
edb02f
sch_atm.o: changed function: atm_tc_graft
edb02f
sch_atm.o: changed function: atm_tc_leaf
edb02f
sch_atm.o: changed function: atm_tc_peek
edb02f
sch_atm.o: changed function: atm_tc_put
edb02f
sch_atm.o: changed function: atm_tc_reset
edb02f
sch_atm.o: changed function: atm_tc_tcf_block
edb02f
sch_atm.o: changed function: sch_atm_dequeue
edb02f
sch_drr.o: changed function: drr_dequeue
edb02f
sch_dsmark.o: changed function: dsmark_bind_filter
edb02f
sch_dsmark.o: changed function: dsmark_change
edb02f
sch_dsmark.o: changed function: dsmark_destroy
edb02f
sch_dsmark.o: changed function: dsmark_dump_class
edb02f
sch_dsmark.o: changed function: dsmark_init
edb02f
sch_dsmark.o: changed function: dsmark_peek
edb02f
sch_dsmark.o: changed function: dsmark_reset
edb02f
sch_hfsc.o: changed function: hfsc_change_class
edb02f
sch_hfsc.o: changed function: hfsc_dequeue
edb02f
sch_hfsc.o: changed function: hfsc_enqueue
edb02f
sch_multiq.o: changed function: multiq_peek
edb02f
sch_prio.o: changed function: prio_peek
edb02f
sch_qfq.o: changed function: qfq_change_class
edb02f
sch_qfq.o: changed function: qfq_dequeue
edb02f
sch_red.o: changed function: red_peek
edb02f
sch_sfb.o: changed function: sfb_peek
edb02f
sch_tbf.o: changed function: tbf_dequeue
edb02f
edb02f
---------------------------
edb02f
edb02f
Modifications:
edb02f
- redirected to qdisc_peek_dequeued() by modifying functions that
edb02f
called '->peek(qdisc)' to call klp_cve_2023_4921_peek() rather than by
edb02f
modifying plug_qdisc_ops
edb02f
- don't remove existing WARN_ONCE instances to avoid kpatch-build
edb02f
"unreconcilable difference" error in .data.once section
edb02f
edb02f
commit faf95907a10c29861882d7885b6e04ebe20057c8
edb02f
Author: Davide Caratti <dcaratti@redhat.com>
edb02f
Date:   Fri Oct 27 17:22:42 2023 +0200
edb02f
edb02f
    net: sched: sch_qfq: Fix UAF in qfq_dequeue()
edb02f
edb02f
    JIRA: https://issues.redhat.com/browse/RHEL-14397
edb02f
    CVE: CVE-2023-4921
edb02f
    Upstream Status: net.git commit 8fc134fee27f2263988ae38920bc03da416b03d8
edb02f
edb02f
    commit 8fc134fee27f2263988ae38920bc03da416b03d8
edb02f
    Author: valis <sec@valis.email>
edb02f
    Date:   Fri Sep 1 12:22:37 2023 -0400
edb02f
edb02f
        net: sched: sch_qfq: Fix UAF in qfq_dequeue()
edb02f
edb02f
        When the plug qdisc is used as a class of the qfq qdisc it could trigger a
edb02f
        UAF. This issue can be reproduced with following commands:
edb02f
edb02f
          tc qdisc add dev lo root handle 1: qfq
edb02f
          tc class add dev lo parent 1: classid 1:1 qfq weight 1 maxpkt 512
edb02f
          tc qdisc add dev lo parent 1:1 handle 2: plug
edb02f
          tc filter add dev lo parent 1: basic classid 1:1
edb02f
          ping -c1 127.0.0.1
edb02f
edb02f
        and boom:
edb02f
edb02f
        [  285.353793] BUG: KASAN: slab-use-after-free in qfq_dequeue+0xa7/0x7f0
edb02f
        [  285.354910] Read of size 4 at addr ffff8880bad312a8 by task ping/144
edb02f
        [  285.355903]
edb02f
        [  285.356165] CPU: 1 PID: 144 Comm: ping Not tainted 6.5.0-rc3+ #4
edb02f
        [  285.357112] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-2 04/01/2014
edb02f
        [  285.358376] Call Trace:
edb02f
        [  285.358773]  <IRQ>
edb02f
        [  285.359109]  dump_stack_lvl+0x44/0x60
edb02f
        [  285.359708]  print_address_description.constprop.0+0x2c/0x3c0
edb02f
        [  285.360611]  kasan_report+0x10c/0x120
edb02f
        [  285.361195]  ? qfq_dequeue+0xa7/0x7f0
edb02f
        [  285.361780]  qfq_dequeue+0xa7/0x7f0
edb02f
        [  285.362342]  __qdisc_run+0xf1/0x970
edb02f
        [  285.362903]  net_tx_action+0x28e/0x460
edb02f
        [  285.363502]  __do_softirq+0x11b/0x3de
edb02f
        [  285.364097]  do_softirq.part.0+0x72/0x90
edb02f
        [  285.364721]  </IRQ>
edb02f
        [  285.365072]  <TASK>
edb02f
        [  285.365422]  __local_bh_enable_ip+0x77/0x90
edb02f
        [  285.366079]  __dev_queue_xmit+0x95f/0x1550
edb02f
        [  285.366732]  ? __pfx_csum_and_copy_from_iter+0x10/0x10
edb02f
        [  285.367526]  ? __pfx___dev_queue_xmit+0x10/0x10
edb02f
        [  285.368259]  ? __build_skb_around+0x129/0x190
edb02f
        [  285.368960]  ? ip_generic_getfrag+0x12c/0x170
edb02f
        [  285.369653]  ? __pfx_ip_generic_getfrag+0x10/0x10
edb02f
        [  285.370390]  ? csum_partial+0x8/0x20
edb02f
        [  285.370961]  ? raw_getfrag+0xe5/0x140
edb02f
        [  285.371559]  ip_finish_output2+0x539/0xa40
edb02f
        [  285.372222]  ? __pfx_ip_finish_output2+0x10/0x10
edb02f
        [  285.372954]  ip_output+0x113/0x1e0
edb02f
        [  285.373512]  ? __pfx_ip_output+0x10/0x10
edb02f
        [  285.374130]  ? icmp_out_count+0x49/0x60
edb02f
        [  285.374739]  ? __pfx_ip_finish_output+0x10/0x10
edb02f
        [  285.375457]  ip_push_pending_frames+0xf3/0x100
edb02f
        [  285.376173]  raw_sendmsg+0xef5/0x12d0
edb02f
        [  285.376760]  ? do_syscall_64+0x40/0x90
edb02f
        [  285.377359]  ? __static_call_text_end+0x136578/0x136578
edb02f
        [  285.378173]  ? do_syscall_64+0x40/0x90
edb02f
        [  285.378772]  ? kasan_enable_current+0x11/0x20
edb02f
        [  285.379469]  ? __pfx_raw_sendmsg+0x10/0x10
edb02f
        [  285.380137]  ? __sock_create+0x13e/0x270
edb02f
        [  285.380673]  ? __sys_socket+0xf3/0x180
edb02f
        [  285.381174]  ? __x64_sys_socket+0x3d/0x50
edb02f
        [  285.381725]  ? entry_SYSCALL_64_after_hwframe+0x6e/0xd8
edb02f
        [  285.382425]  ? __rcu_read_unlock+0x48/0x70
edb02f
        [  285.382975]  ? ip4_datagram_release_cb+0xd8/0x380
edb02f
        [  285.383608]  ? __pfx_ip4_datagram_release_cb+0x10/0x10
edb02f
        [  285.384295]  ? preempt_count_sub+0x14/0xc0
edb02f
        [  285.384844]  ? __list_del_entry_valid+0x76/0x140
edb02f
        [  285.385467]  ? _raw_spin_lock_bh+0x87/0xe0
edb02f
        [  285.386014]  ? __pfx__raw_spin_lock_bh+0x10/0x10
edb02f
        [  285.386645]  ? release_sock+0xa0/0xd0
edb02f
        [  285.387148]  ? preempt_count_sub+0x14/0xc0
edb02f
        [  285.387712]  ? freeze_secondary_cpus+0x348/0x3c0
edb02f
        [  285.388341]  ? aa_sk_perm+0x177/0x390
edb02f
        [  285.388856]  ? __pfx_aa_sk_perm+0x10/0x10
edb02f
        [  285.389441]  ? check_stack_object+0x22/0x70
edb02f
        [  285.390032]  ? inet_send_prepare+0x2f/0x120
edb02f
        [  285.390603]  ? __pfx_inet_sendmsg+0x10/0x10
edb02f
        [  285.391172]  sock_sendmsg+0xcc/0xe0
edb02f
        [  285.391667]  __sys_sendto+0x190/0x230
edb02f
        [  285.392168]  ? __pfx___sys_sendto+0x10/0x10
edb02f
        [  285.392727]  ? kvm_clock_get_cycles+0x14/0x30
edb02f
        [  285.393328]  ? set_normalized_timespec64+0x57/0x70
edb02f
        [  285.393980]  ? _raw_spin_unlock_irq+0x1b/0x40
edb02f
        [  285.394578]  ? __x64_sys_clock_gettime+0x11c/0x160
edb02f
        [  285.395225]  ? __pfx___x64_sys_clock_gettime+0x10/0x10
edb02f
        [  285.395908]  ? _copy_to_user+0x3e/0x60
edb02f
        [  285.396432]  ? exit_to_user_mode_prepare+0x1a/0x120
edb02f
        [  285.397086]  ? syscall_exit_to_user_mode+0x22/0x50
edb02f
        [  285.397734]  ? do_syscall_64+0x71/0x90
edb02f
        [  285.398258]  __x64_sys_sendto+0x74/0x90
edb02f
        [  285.398786]  do_syscall_64+0x64/0x90
edb02f
        [  285.399273]  ? exit_to_user_mode_prepare+0x1a/0x120
edb02f
        [  285.399949]  ? syscall_exit_to_user_mode+0x22/0x50
edb02f
        [  285.400605]  ? do_syscall_64+0x71/0x90
edb02f
        [  285.401124]  entry_SYSCALL_64_after_hwframe+0x6e/0xd8
edb02f
        [  285.401807] RIP: 0033:0x495726
edb02f
        [  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
edb02f
        [  285.404683] RSP: 002b:00007ffcc25fb618 EFLAGS: 00000246 ORIG_RAX: 000000000000002c
edb02f
        [  285.405677] RAX: ffffffffffffffda RBX: 0000000000000040 RCX: 0000000000495726
edb02f
        [  285.406628] RDX: 0000000000000040 RSI: 0000000002518750 RDI: 0000000000000000
edb02f
        [  285.407565] RBP: 00000000005205ef R08: 00000000005f8838 R09: 000000000000001c
edb02f
        [  285.408523] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000002517634
edb02f
        [  285.409460] R13: 00007ffcc25fb6f0 R14: 0000000000000003 R15: 0000000000000000
edb02f
        [  285.410403]  </TASK>
edb02f
        [  285.410704]
edb02f
        [  285.410929] Allocated by task 144:
edb02f
        [  285.411402]  kasan_save_stack+0x1e/0x40
edb02f
        [  285.411926]  kasan_set_track+0x21/0x30
edb02f
        [  285.412442]  __kasan_slab_alloc+0x55/0x70
edb02f
        [  285.412973]  kmem_cache_alloc_node+0x187/0x3d0
edb02f
        [  285.413567]  __alloc_skb+0x1b4/0x230
edb02f
        [  285.414060]  __ip_append_data+0x17f7/0x1b60
edb02f
        [  285.414633]  ip_append_data+0x97/0xf0
edb02f
        [  285.415144]  raw_sendmsg+0x5a8/0x12d0
edb02f
        [  285.415640]  sock_sendmsg+0xcc/0xe0
edb02f
        [  285.416117]  __sys_sendto+0x190/0x230
edb02f
        [  285.416626]  __x64_sys_sendto+0x74/0x90
edb02f
        [  285.417145]  do_syscall_64+0x64/0x90
edb02f
        [  285.417624]  entry_SYSCALL_64_after_hwframe+0x6e/0xd8
edb02f
        [  285.418306]
edb02f
        [  285.418531] Freed by task 144:
edb02f
        [  285.418960]  kasan_save_stack+0x1e/0x40
edb02f
        [  285.419469]  kasan_set_track+0x21/0x30
edb02f
        [  285.419988]  kasan_save_free_info+0x27/0x40
edb02f
        [  285.420556]  ____kasan_slab_free+0x109/0x1a0
edb02f
        [  285.421146]  kmem_cache_free+0x1c2/0x450
edb02f
        [  285.421680]  __netif_receive_skb_core+0x2ce/0x1870
edb02f
        [  285.422333]  __netif_receive_skb_one_core+0x97/0x140
edb02f
        [  285.423003]  process_backlog+0x100/0x2f0
edb02f
        [  285.423537]  __napi_poll+0x5c/0x2d0
edb02f
        [  285.424023]  net_rx_action+0x2be/0x560
edb02f
        [  285.424510]  __do_softirq+0x11b/0x3de
edb02f
        [  285.425034]
edb02f
        [  285.425254] The buggy address belongs to the object at ffff8880bad31280
edb02f
        [  285.425254]  which belongs to the cache skbuff_head_cache of size 224
edb02f
        [  285.426993] The buggy address is located 40 bytes inside of
edb02f
        [  285.426993]  freed 224-byte region [ffff8880bad31280, ffff8880bad31360)
edb02f
        [  285.428572]
edb02f
        [  285.428798] The buggy address belongs to the physical page:
edb02f
        [  285.429540] page:00000000f4b77674 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0xbad31
edb02f
        [  285.430758] flags: 0x100000000000200(slab|node=0|zone=1)
edb02f
        [  285.431447] page_type: 0xffffffff()
edb02f
        [  285.431934] raw: 0100000000000200 ffff88810094a8c0 dead000000000122 0000000000000000
edb02f
        [  285.432757] raw: 0000000000000000 00000000800c000c 00000001ffffffff 0000000000000000
edb02f
        [  285.433562] page dumped because: kasan: bad access detected
edb02f
        [  285.434144]
edb02f
        [  285.434320] Memory state around the buggy address:
edb02f
        [  285.434828]  ffff8880bad31180: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
edb02f
        [  285.435580]  ffff8880bad31200: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
edb02f
        [  285.436264] >ffff8880bad31280: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
edb02f
        [  285.436777]                                   ^
edb02f
        [  285.437106]  ffff8880bad31300: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
edb02f
        [  285.437616]  ffff8880bad31380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
edb02f
        [  285.438126] ==================================================================
edb02f
        [  285.438662] Disabling lock debugging due to kernel taint
edb02f
edb02f
        Fix this by:
edb02f
        1. Changing sch_plug's .peek handler to qdisc_peek_dequeued(), a
edb02f
        function compatible with non-work-conserving qdiscs
edb02f
        2. Checking the return value of qdisc_dequeue_peeked() in sch_qfq.
edb02f
edb02f
        Fixes: 462dbc9101ac ("pkt_sched: QFQ Plus: fair-queueing service at DRR cost")
edb02f
        Reported-by: valis <sec@valis.email>
edb02f
        Signed-off-by: valis <sec@valis.email>
edb02f
        Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
edb02f
        Link: https://lore.kernel.org/r/20230901162237.11525-1-jhs@mojatatu.com
edb02f
        Signed-off-by: Paolo Abeni <pabeni@redhat.com>
edb02f
edb02f
    Signed-off-by: Davide Caratti <dcaratti@redhat.com>
edb02f
edb02f
commit eb76ae2165f95d31ad199d706840140b271c719e
edb02f
Author: Davide Caratti <dcaratti@redhat.com>
edb02f
Date:   Thu Jan 25 15:45:42 2024 +0100
edb02f
edb02f
    net: sched: sch_qfq: Use non-work-conserving warning handler
edb02f
edb02f
    JIRA: https://issues.redhat.com/browse/RHEL-14397
edb02f
    Upstream Status: net.git commit 6d25d1dc76bf5943a5c1f4bb74d66d5eac58eb77
edb02f
edb02f
    commit 6d25d1dc76bf5943a5c1f4bb74d66d5eac58eb77
edb02f
    Author: Liu Jian <liujian56@huawei.com>
edb02f
    Date:   Mon Oct 23 14:47:29 2023 +0800
edb02f
edb02f
        net: sched: sch_qfq: Use non-work-conserving warning handler
edb02f
edb02f
        A helper function for printing non-work-conserving alarms is added in
edb02f
        commit b00355db3f88 ("pkt_sched: sch_hfsc: sch_htb: Add non-work-conserving
edb02f
         warning handler."). In this commit, use qdisc_warn_nonwc() instead of
edb02f
        WARN_ONCE() to handle the non-work-conserving warning in qfq Qdisc.
edb02f
edb02f
        Signed-off-by: Liu Jian <liujian56@huawei.com>
edb02f
        Link: https://lore.kernel.org/r/20231023064729.370649-1-liujian56@huawei.com
edb02f
        Signed-off-by: Paolo Abeni <pabeni@redhat.com>
edb02f
edb02f
    Signed-off-by: Davide Caratti <dcaratti@redhat.com>
edb02f
edb02f
Signed-off-by: Ryan Sullivan <rysulliv@redhat.com>
edb02f
---
edb02f
 net/sched/klp_cve_2023_4921.h | 16 +++++++++++++
edb02f
 net/sched/sch_atm.c           |  5 ++--
edb02f
 net/sched/sch_drr.c           |  3 ++-
edb02f
 net/sched/sch_dsmark.c        |  3 ++-
edb02f
 net/sched/sch_hfsc.c          |  7 +++---
edb02f
 net/sched/sch_multiq.c        |  4 +++-
edb02f
 net/sched/sch_prio.c          |  6 ++++-
edb02f
 net/sched/sch_qfq.c           | 43 ++++++++++++++++++++++++++---------
edb02f
 net/sched/sch_red.c           |  3 ++-
edb02f
 net/sched/sch_sfb.c           |  3 ++-
edb02f
 net/sched/sch_tbf.c           |  3 ++-
edb02f
 11 files changed, 73 insertions(+), 23 deletions(-)
edb02f
 create mode 100644 net/sched/klp_cve_2023_4921.h
edb02f
edb02f
diff --git a/net/sched/klp_cve_2023_4921.h b/net/sched/klp_cve_2023_4921.h
edb02f
new file mode 100644
edb02f
index 000000000000..07a5624a487c
edb02f
--- /dev/null
edb02f
+++ b/net/sched/klp_cve_2023_4921.h
edb02f
@@ -0,0 +1,16 @@
edb02f
+#ifndef __KLP_CVE_2023_4921__
edb02f
+#define __KLP_CVE_2023_4921__
edb02f
+
edb02f
+static inline struct sk_buff *klp_cve_2023_4921_peek(struct Qdisc *sch)
edb02f
+{
edb02f
+	/*
edb02f
+	 * kpatch workaround: can't modify plug_qdisc_ops structure, so
edb02f
+	 * provide a peek pivot based on the underlying qdisc ops id
edb02f
+	 */
edb02f
+	if (strcmp(sch->ops->id, "plug") == 0)
edb02f
+		return qdisc_peek_dequeued(sch);
edb02f
+
edb02f
+	return sch->ops->peek(sch);
edb02f
+}
edb02f
+
edb02f
+#endif
edb02f
diff --git a/net/sched/sch_atm.c b/net/sched/sch_atm.c
edb02f
index 7c8966a42794..d58c84b3fba2 100644
edb02f
--- a/net/sched/sch_atm.c
edb02f
+++ b/net/sched/sch_atm.c
edb02f
@@ -16,6 +16,7 @@
edb02f
 #include <net/netlink.h>
edb02f
 #include <net/pkt_sched.h>
edb02f
 #include <net/pkt_cls.h>
edb02f
+#include "klp_cve_2023_4921.h"
edb02f
 
edb02f
 /*
edb02f
  * The ATM queuing discipline provides a framework for invoking classifiers
edb02f
@@ -474,7 +475,7 @@ static void sch_atm_dequeue(unsigned long data)
edb02f
 		 * If traffic is properly shaped, this won't generate nasty
edb02f
 		 * little bursts. Otherwise, it may ... (but that's okay)
edb02f
 		 */
edb02f
-		while ((skb = flow->q->ops->peek(flow->q))) {
edb02f
+		while ((skb = klp_cve_2023_4921_peek(flow->q))) {
edb02f
 			if (!atm_may_send(flow->vcc, skb->truesize))
edb02f
 				break;
edb02f
 
edb02f
@@ -528,7 +529,7 @@ static struct sk_buff *atm_tc_peek(struct Qdisc *sch)
edb02f
 
edb02f
 	pr_debug("atm_tc_peek(sch %p,[qdisc %p])\n", sch, p);
edb02f
 
edb02f
-	return p->link.q->ops->peek(p->link.q);
edb02f
+	return klp_cve_2023_4921_peek(p->link.q);
edb02f
 }
edb02f
 
edb02f
 static int atm_tc_init(struct Qdisc *sch, struct nlattr *opt)
edb02f
diff --git a/net/sched/sch_drr.c b/net/sched/sch_drr.c
edb02f
index 9bfe7b50115f..27dd8e610da2 100644
edb02f
--- a/net/sched/sch_drr.c
edb02f
+++ b/net/sched/sch_drr.c
edb02f
@@ -17,6 +17,7 @@
edb02f
 #include <net/sch_generic.h>
edb02f
 #include <net/pkt_sched.h>
edb02f
 #include <net/pkt_cls.h>
edb02f
+#include "klp_cve_2023_4921.h"
edb02f
 
edb02f
 struct drr_class {
edb02f
 	struct Qdisc_class_common	common;
edb02f
@@ -378,7 +379,7 @@ static struct sk_buff *drr_dequeue(struct Qdisc *sch)
edb02f
 		goto out;
edb02f
 	while (1) {
edb02f
 		cl = list_first_entry(&q->active, struct drr_class, alist);
edb02f
-		skb = cl->qdisc->ops->peek(cl->qdisc);
edb02f
+		skb = klp_cve_2023_4921_peek(cl->qdisc);
edb02f
 		if (skb == NULL) {
edb02f
 			qdisc_warn_nonwc(__func__, cl->qdisc);
edb02f
 			goto out;
edb02f
diff --git a/net/sched/sch_dsmark.c b/net/sched/sch_dsmark.c
edb02f
index df08e15e6f19..06b6e03f89ea 100644
edb02f
--- a/net/sched/sch_dsmark.c
edb02f
+++ b/net/sched/sch_dsmark.c
edb02f
@@ -17,6 +17,7 @@
edb02f
 #include <net/dsfield.h>
edb02f
 #include <net/inet_ecn.h>
edb02f
 #include <asm/byteorder.h>
edb02f
+#include "klp_cve_2023_4921.h"
edb02f
 
edb02f
 /*
edb02f
  * classid	class		marking
edb02f
@@ -327,7 +328,7 @@ static struct sk_buff *dsmark_peek(struct Qdisc *sch)
edb02f
 
edb02f
 	pr_debug("%s(sch %p,[qdisc %p])\n", __func__, sch, p);
edb02f
 
edb02f
-	return p->q->ops->peek(p->q);
edb02f
+	return klp_cve_2023_4921_peek(p->q);
edb02f
 }
edb02f
 
edb02f
 static int dsmark_init(struct Qdisc *sch, struct nlattr *opt)
edb02f
diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c
edb02f
index fb14b551f65d..466244c57737 100644
edb02f
--- a/net/sched/sch_hfsc.c
edb02f
+++ b/net/sched/sch_hfsc.c
edb02f
@@ -67,6 +67,7 @@
edb02f
 #include <net/pkt_sched.h>
edb02f
 #include <net/pkt_cls.h>
edb02f
 #include <asm/div64.h>
edb02f
+#include "klp_cve_2023_4921.h"
edb02f
 
edb02f
 /*
edb02f
  * kernel internal service curve representation:
edb02f
@@ -834,7 +835,8 @@ qdisc_peek_len(struct Qdisc *sch)
edb02f
 	struct sk_buff *skb;
edb02f
 	unsigned int len;
edb02f
 
edb02f
-	skb = sch->ops->peek(sch);
edb02f
+	skb = klp_cve_2023_4921_peek(sch);
edb02f
+
edb02f
 	if (unlikely(skb == NULL)) {
edb02f
 		qdisc_warn_nonwc("qdisc_peek_len", sch);
edb02f
 		return 0;
edb02f
@@ -1567,8 +1569,7 @@ hfsc_enqueue(struct sk_buff *skb, struct Qdisc *sch, struct sk_buff **to_free)
edb02f
 		 * to invalidate the deadline.
edb02f
 		 */
edb02f
 		if (cl->cl_flags & HFSC_RSC)
edb02f
-			cl->qdisc->ops->peek(cl->qdisc);
edb02f
-
edb02f
+			klp_cve_2023_4921_peek(cl->qdisc);
edb02f
 	}
edb02f
 
edb02f
 	qdisc_qstats_backlog_inc(sch, skb);
edb02f
diff --git a/net/sched/sch_multiq.c b/net/sched/sch_multiq.c
edb02f
index 31e0a284eeff..8f6e85b2c8b8 100644
edb02f
--- a/net/sched/sch_multiq.c
edb02f
+++ b/net/sched/sch_multiq.c
edb02f
@@ -26,6 +26,7 @@
edb02f
 #include <net/netlink.h>
edb02f
 #include <net/pkt_sched.h>
edb02f
 #include <net/pkt_cls.h>
edb02f
+#include "klp_cve_2023_4921.h"
edb02f
 
edb02f
 struct multiq_sched_data {
edb02f
 	u16 bands;
edb02f
@@ -145,7 +146,8 @@ static struct sk_buff *multiq_peek(struct Qdisc *sch)
edb02f
 		if (!netif_xmit_stopped(
edb02f
 		    netdev_get_tx_queue(qdisc_dev(sch), curband))) {
edb02f
 			qdisc = q->queues[curband];
edb02f
-			skb = qdisc->ops->peek(qdisc);
edb02f
+			skb = klp_cve_2023_4921_peek(qdisc);
edb02f
+
edb02f
 			if (skb)
edb02f
 				return skb;
edb02f
 		}
edb02f
diff --git a/net/sched/sch_prio.c b/net/sched/sch_prio.c
edb02f
index faf447b60b68..23526ef54f0c 100644
edb02f
--- a/net/sched/sch_prio.c
edb02f
+++ b/net/sched/sch_prio.c
edb02f
@@ -21,6 +21,7 @@
edb02f
 #include <net/netlink.h>
edb02f
 #include <net/pkt_sched.h>
edb02f
 #include <net/pkt_cls.h>
edb02f
+#include "klp_cve_2023_4921.h"
edb02f
 
edb02f
 struct prio_sched_data {
edb02f
 	int bands;
edb02f
@@ -103,7 +104,10 @@ static struct sk_buff *prio_peek(struct Qdisc *sch)
edb02f
 
edb02f
 	for (prio = 0; prio < q->bands; prio++) {
edb02f
 		struct Qdisc *qdisc = q->queues[prio];
edb02f
-		struct sk_buff *skb = qdisc->ops->peek(qdisc);
edb02f
+		struct sk_buff *skb;
edb02f
+
edb02f
+		skb = klp_cve_2023_4921_peek(qdisc);
edb02f
+
edb02f
 		if (skb)
edb02f
 			return skb;
edb02f
 	}
edb02f
diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c
edb02f
index ca8c79456c80..134cd66225c0 100644
edb02f
--- a/net/sched/sch_qfq.c
edb02f
+++ b/net/sched/sch_qfq.c
edb02f
@@ -18,6 +18,8 @@
edb02f
 #include <net/sch_generic.h>
edb02f
 #include <net/pkt_sched.h>
edb02f
 #include <net/pkt_cls.h>
edb02f
+#include <linux/string.h>
edb02f
+#include "klp_cve_2023_4921.h"
edb02f
 
edb02f
 
edb02f
 /*  Quick Fair Queueing Plus
edb02f
@@ -984,19 +986,24 @@ static void qfq_update_eligible(struct qfq_sched *q)
edb02f
 }
edb02f
 
edb02f
 /* Dequeue head packet of the head class in the DRR queue of the aggregate. */
edb02f
-static void agg_dequeue(struct qfq_aggregate *agg,
edb02f
-			struct qfq_class *cl, unsigned int len)
edb02f
+static struct sk_buff *agg_dequeue(struct qfq_aggregate *agg,
edb02f
+				   struct qfq_class *cl, unsigned int len)
edb02f
 {
edb02f
-	qdisc_dequeue_peeked(cl->qdisc);
edb02f
+	struct sk_buff *skb = qdisc_dequeue_peeked(cl->qdisc);
edb02f
+
edb02f
+	if (!skb)
edb02f
+		return NULL;
edb02f
 
edb02f
 	cl->deficit -= (int) len;
edb02f
 
edb02f
 	if (cl->qdisc->q.qlen == 0) /* no more packets, remove from list */
edb02f
 		list_del(&cl->alist);
edb02f
-	else if (cl->deficit < qdisc_pkt_len(cl->qdisc->ops->peek(cl->qdisc))) {
edb02f
+	else if (cl->deficit < qdisc_pkt_len(klp_cve_2023_4921_peek(cl->qdisc))) {
edb02f
 		cl->deficit += agg->lmax;
edb02f
 		list_move_tail(&cl->alist, &agg->active);
edb02f
 	}
edb02f
+
edb02f
+	return skb;
edb02f
 }
edb02f
 
edb02f
 static inline struct sk_buff *qfq_peek_skb(struct qfq_aggregate *agg,
edb02f
@@ -1006,10 +1013,16 @@ static inline struct sk_buff *qfq_peek_skb(struct qfq_aggregate *agg,
edb02f
 	struct sk_buff *skb;
edb02f
 
edb02f
 	*cl = list_first_entry(&agg->active, struct qfq_class, alist);
edb02f
-	skb = (*cl)->qdisc->ops->peek((*cl)->qdisc);
edb02f
-	if (skb == NULL)
edb02f
-		WARN_ONCE(1, "qfq_dequeue: non-workconserving leaf\n");
edb02f
-	else
edb02f
+	skb = klp_cve_2023_4921_peek((*cl)->qdisc);
edb02f
+	if (skb == NULL) {
edb02f
+		/*
edb02f
+		 * kpatch-build workaround: keep old WARN_ONCE to avoid
edb02f
+		 * create-diff-object unreconcilable difference from
edb02f
+		 * unsupported .data.once section change.
edb02f
+		 */
edb02f
+		WARN_ONCE(!jiffies, "qfq_dequeue: non-workconserving leaf\n");
edb02f
+		qdisc_warn_nonwc("qfq_dequeue", (*cl)->qdisc);
edb02f
+	} else
edb02f
 		*len = qdisc_pkt_len(skb);
edb02f
 
edb02f
 	return skb;
edb02f
@@ -1142,11 +1155,18 @@ static struct sk_buff *qfq_dequeue(struct Qdisc *sch)
edb02f
 	if (!skb)
edb02f
 		return NULL;
edb02f
 
edb02f
-	qdisc_qstats_backlog_dec(sch, skb);
edb02f
 	sch->q.qlen--;
edb02f
+
edb02f
+	skb = agg_dequeue(in_serv_agg, cl, len);
edb02f
+
edb02f
+	if (!skb) {
edb02f
+		sch->q.qlen++;
edb02f
+		return NULL;
edb02f
+	}
edb02f
+
edb02f
+	qdisc_qstats_backlog_dec(sch, skb);
edb02f
 	qdisc_bstats_update(sch, skb);
edb02f
 
edb02f
-	agg_dequeue(in_serv_agg, cl, len);
edb02f
 	/* If lmax is lowered, through qfq_change_class, for a class
edb02f
 	 * owning pending packets with larger size than the new value
edb02f
 	 * of lmax, then the following condition may hold.
edb02f
@@ -1224,6 +1244,7 @@ static int qfq_enqueue(struct sk_buff *skb, struct Qdisc *sch,
edb02f
 	}
edb02f
 	pr_debug("qfq_enqueue: cl = %x\n", cl->common.classid);
edb02f
 
edb02f
+
edb02f
 	if (unlikely(cl->agg->lmax < qdisc_pkt_len(skb))) {
edb02f
 		pr_debug("qfq: increasing maxpkt from %u to %u for class %u",
edb02f
 			 cl->agg->lmax, qdisc_pkt_len(skb), cl->common.classid);
edb02f
@@ -1252,7 +1273,7 @@ static int qfq_enqueue(struct sk_buff *skb, struct Qdisc *sch,
edb02f
 	agg = cl->agg;
edb02f
 	/* if the queue was not empty, then done here */
edb02f
 	if (cl->qdisc->q.qlen != 1) {
edb02f
-		if (unlikely(skb == cl->qdisc->ops->peek(cl->qdisc)) &&
edb02f
+		if (unlikely(skb == klp_cve_2023_4921_peek(cl->qdisc)) &&
edb02f
 		    list_first_entry(&agg->active, struct qfq_class, alist)
edb02f
 		    == cl && cl->deficit < qdisc_pkt_len(skb))
edb02f
 			list_move_tail(&cl->alist, &agg->active);
edb02f
diff --git a/net/sched/sch_red.c b/net/sched/sch_red.c
edb02f
index e4789760457a..eea80e402219 100644
edb02f
--- a/net/sched/sch_red.c
edb02f
+++ b/net/sched/sch_red.c
edb02f
@@ -22,6 +22,7 @@
edb02f
 #include <net/pkt_cls.h>
edb02f
 #include <net/inet_ecn.h>
edb02f
 #include <net/red.h>
edb02f
+#include "klp_cve_2023_4921.h"
edb02f
 
edb02f
 
edb02f
 /*	Parameters, settable by user:
edb02f
@@ -135,7 +136,7 @@ static struct sk_buff *red_peek(struct Qdisc *sch)
edb02f
 	struct red_sched_data *q = qdisc_priv(sch);
edb02f
 	struct Qdisc *child = q->qdisc;
edb02f
 
edb02f
-	return child->ops->peek(child);
edb02f
+	return klp_cve_2023_4921_peek(child);
edb02f
 }
edb02f
 
edb02f
 static void red_reset(struct Qdisc *sch)
edb02f
diff --git a/net/sched/sch_sfb.c b/net/sched/sch_sfb.c
edb02f
index aeb509bde740..f8d75735351f 100644
edb02f
--- a/net/sched/sch_sfb.c
edb02f
+++ b/net/sched/sch_sfb.c
edb02f
@@ -27,6 +27,7 @@
edb02f
 #include <net/pkt_sched.h>
edb02f
 #include <net/pkt_cls.h>
edb02f
 #include <net/inet_ecn.h>
edb02f
+#include "klp_cve_2023_4921.h"
edb02f
 
edb02f
 /*
edb02f
  * SFB uses two B[l][n] : L x N arrays of bins (L levels, N bins per level)
edb02f
@@ -445,7 +446,7 @@ static struct sk_buff *sfb_peek(struct Qdisc *sch)
edb02f
 	struct sfb_sched_data *q = qdisc_priv(sch);
edb02f
 	struct Qdisc *child = q->qdisc;
edb02f
 
edb02f
-	return child->ops->peek(child);
edb02f
+	return klp_cve_2023_4921_peek(child);
edb02f
 }
edb02f
 
edb02f
 /* No sfb_drop -- impossible since the child doesn't return the dropped skb. */
edb02f
diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
edb02f
index 15a19519aa9c..9957adc1b951 100644
edb02f
--- a/net/sched/sch_tbf.c
edb02f
+++ b/net/sched/sch_tbf.c
edb02f
@@ -21,6 +21,7 @@
edb02f
 #include <net/netlink.h>
edb02f
 #include <net/sch_generic.h>
edb02f
 #include <net/pkt_sched.h>
edb02f
+#include "klp_cve_2023_4921.h"
edb02f
 
edb02f
 
edb02f
 /*	Simple Token Bucket Filter.
edb02f
@@ -214,7 +215,7 @@ static struct sk_buff *tbf_dequeue(struct Qdisc *sch)
edb02f
 	struct tbf_sched_data *q = qdisc_priv(sch);
edb02f
 	struct sk_buff *skb;
edb02f
 
edb02f
-	skb = q->qdisc->ops->peek(q->qdisc);
edb02f
+	skb = klp_cve_2023_4921_peek(q->qdisc);
edb02f
 
edb02f
 	if (skb) {
edb02f
 		s64 now;
edb02f
-- 
edb02f
2.44.0
edb02f
edb02f