|
| 1 | +net: mana: cleanup mana struct after debugfs_remove() |
| 2 | + |
| 3 | +jira NONE_AUTOMATION |
| 4 | +Rebuild_History Non-Buildable kernel-5.14.0-570.16.1.el9_6 |
| 5 | +commit-author Shradha Gupta < [email protected]> |
| 6 | +commit 3e64bb2ae7d9f2b3a8259d4d6b86ed1984d5460a |
| 7 | +Empty-Commit: Cherry-Pick Conflicts during history rebuild. |
| 8 | +Will be included in final tarball splat. Ref for failed cherry-pick at: |
| 9 | +ciq/ciq_backports/kernel-5.14.0-570.16.1.el9_6/3e64bb2a.failed |
| 10 | + |
| 11 | +When on a MANA VM hibernation is triggered, as part of hibernate_snapshot(), |
| 12 | +mana_gd_suspend() and mana_gd_resume() are called. If during this |
| 13 | +mana_gd_resume(), a failure occurs with HWC creation, mana_port_debugfs |
| 14 | +pointer does not get reinitialized and ends up pointing to older, |
| 15 | +cleaned-up dentry. |
| 16 | +Further in the hibernation path, as part of power_down(), mana_gd_shutdown() |
| 17 | +is triggered. This call, unaware of the failures in resume, tries to cleanup |
| 18 | +the already cleaned up mana_port_debugfs value and hits the following bug: |
| 19 | + |
| 20 | +[ 191.359296] mana 7870:00:00.0: Shutdown was called |
| 21 | +[ 191.359918] BUG: kernel NULL pointer dereference, address: 0000000000000098 |
| 22 | +[ 191.360584] #PF: supervisor write access in kernel mode |
| 23 | +[ 191.361125] #PF: error_code(0x0002) - not-present page |
| 24 | +[ 191.361727] PGD 1080ea067 P4D 0 |
| 25 | +[ 191.362172] Oops: Oops: 0002 [#1] SMP NOPTI |
| 26 | +[ 191.362606] CPU: 11 UID: 0 PID: 1674 Comm: bash Not tainted 6.14.0-rc5+ #2 |
| 27 | +[ 191.363292] Hardware name: Microsoft Corporation Virtual Machine/Virtual Machine, BIOS Hyper-V UEFI Release v4.1 11/21/2024 |
| 28 | +[ 191.364124] RIP: 0010:down_write+0x19/0x50 |
| 29 | +[ 191.364537] Code: 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 0f 1f 44 00 00 55 48 89 e5 53 48 89 fb e8 de cd ff ff 31 c0 ba 01 00 00 00 <f0> 48 0f b1 13 75 16 65 48 8b 05 88 24 4c 6a 48 89 43 08 48 8b 5d |
| 30 | +[ 191.365867] RSP: 0000:ff45fbe0c1c037b8 EFLAGS: 00010246 |
| 31 | +[ 191.366350] RAX: 0000000000000000 RBX: 0000000000000098 RCX: ffffff8100000000 |
| 32 | +[ 191.366951] RDX: 0000000000000001 RSI: 0000000000000064 RDI: 0000000000000098 |
| 33 | +[ 191.367600] RBP: ff45fbe0c1c037c0 R08: 0000000000000000 R09: 0000000000000001 |
| 34 | +[ 191.368225] R10: ff45fbe0d2b01000 R11: 0000000000000008 R12: 0000000000000000 |
| 35 | +[ 191.368874] R13: 000000000000000b R14: ff43dc27509d67c0 R15: 0000000000000020 |
| 36 | +[ 191.369549] FS: 00007dbc5001e740(0000) GS:ff43dc663f380000(0000) knlGS:0000000000000000 |
| 37 | +[ 191.370213] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 |
| 38 | +[ 191.370830] CR2: 0000000000000098 CR3: 0000000168e8e002 CR4: 0000000000b73ef0 |
| 39 | +[ 191.371557] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 |
| 40 | +[ 191.372192] DR3: 0000000000000000 DR6: 00000000fffe07f0 DR7: 0000000000000400 |
| 41 | +[ 191.372906] Call Trace: |
| 42 | +[ 191.373262] <TASK> |
| 43 | +[ 191.373621] ? show_regs+0x64/0x70 |
| 44 | +[ 191.374040] ? __die+0x24/0x70 |
| 45 | +[ 191.374468] ? page_fault_oops+0x290/0x5b0 |
| 46 | +[ 191.374875] ? do_user_addr_fault+0x448/0x800 |
| 47 | +[ 191.375357] ? exc_page_fault+0x7a/0x160 |
| 48 | +[ 191.375971] ? asm_exc_page_fault+0x27/0x30 |
| 49 | +[ 191.376416] ? down_write+0x19/0x50 |
| 50 | +[ 191.376832] ? down_write+0x12/0x50 |
| 51 | +[ 191.377232] simple_recursive_removal+0x4a/0x2a0 |
| 52 | +[ 191.377679] ? __pfx_remove_one+0x10/0x10 |
| 53 | +[ 191.378088] debugfs_remove+0x44/0x70 |
| 54 | +[ 191.378530] mana_detach+0x17c/0x4f0 |
| 55 | +[ 191.378950] ? __flush_work+0x1e2/0x3b0 |
| 56 | +[ 191.379362] ? __cond_resched+0x1a/0x50 |
| 57 | +[ 191.379787] mana_remove+0xf2/0x1a0 |
| 58 | +[ 191.380193] mana_gd_shutdown+0x3b/0x70 |
| 59 | +[ 191.380642] pci_device_shutdown+0x3a/0x80 |
| 60 | +[ 191.381063] device_shutdown+0x13e/0x230 |
| 61 | +[ 191.381480] kernel_power_off+0x35/0x80 |
| 62 | +[ 191.381890] hibernate+0x3c6/0x470 |
| 63 | +[ 191.382312] state_store+0xcb/0xd0 |
| 64 | +[ 191.382734] kobj_attr_store+0x12/0x30 |
| 65 | +[ 191.383211] sysfs_kf_write+0x3e/0x50 |
| 66 | +[ 191.383640] kernfs_fop_write_iter+0x140/0x1d0 |
| 67 | +[ 191.384106] vfs_write+0x271/0x440 |
| 68 | +[ 191.384521] ksys_write+0x72/0xf0 |
| 69 | +[ 191.384924] __x64_sys_write+0x19/0x20 |
| 70 | +[ 191.385313] x64_sys_call+0x2b0/0x20b0 |
| 71 | +[ 191.385736] do_syscall_64+0x79/0x150 |
| 72 | +[ 191.386146] ? __mod_memcg_lruvec_state+0xe7/0x240 |
| 73 | +[ 191.386676] ? __lruvec_stat_mod_folio+0x79/0xb0 |
| 74 | +[ 191.387124] ? __pfx_lru_add+0x10/0x10 |
| 75 | +[ 191.387515] ? queued_spin_unlock+0x9/0x10 |
| 76 | +[ 191.387937] ? do_anonymous_page+0x33c/0xa00 |
| 77 | +[ 191.388374] ? __handle_mm_fault+0xcf3/0x1210 |
| 78 | +[ 191.388805] ? __count_memcg_events+0xbe/0x180 |
| 79 | +[ 191.389235] ? handle_mm_fault+0xae/0x300 |
| 80 | +[ 191.389588] ? do_user_addr_fault+0x559/0x800 |
| 81 | +[ 191.390027] ? irqentry_exit_to_user_mode+0x43/0x230 |
| 82 | +[ 191.390525] ? irqentry_exit+0x1d/0x30 |
| 83 | +[ 191.390879] ? exc_page_fault+0x86/0x160 |
| 84 | +[ 191.391235] entry_SYSCALL_64_after_hwframe+0x76/0x7e |
| 85 | +[ 191.391745] RIP: 0033:0x7dbc4ff1c574 |
| 86 | +[ 191.392111] Code: c7 00 16 00 00 00 b8 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 f3 0f 1e fa 80 3d d5 ea 0e 00 00 74 13 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 54 c3 0f 1f 00 55 48 89 e5 48 83 ec 20 48 89 |
| 87 | +[ 191.393412] RSP: 002b:00007ffd95a23ab8 EFLAGS: 00000202 ORIG_RAX: 0000000000000001 |
| 88 | +[ 191.393990] RAX: ffffffffffffffda RBX: 0000000000000005 RCX: 00007dbc4ff1c574 |
| 89 | +[ 191.394594] RDX: 0000000000000005 RSI: 00005a6eeadb0ce0 RDI: 0000000000000001 |
| 90 | +[ 191.395215] RBP: 00007ffd95a23ae0 R08: 00007dbc50003b20 R09: 0000000000000000 |
| 91 | +[ 191.395805] R10: 0000000000000001 R11: 0000000000000202 R12: 0000000000000005 |
| 92 | +[ 191.396404] R13: 00005a6eeadb0ce0 R14: 00007dbc500045c0 R15: 00007dbc50001ee0 |
| 93 | +[ 191.396987] </TASK> |
| 94 | + |
| 95 | +To fix this, we explicitly set such mana debugfs variables to NULL after |
| 96 | +debugfs_remove() is called. |
| 97 | + |
| 98 | +Fixes: 6607c17c6c5e ("net: mana: Enable debugfs files for MANA device") |
| 99 | + |
| 100 | + Signed-off-by: Shradha Gupta < [email protected]> |
| 101 | + Reviewed-by: Haiyang Zhang < [email protected]> |
| 102 | + Reviewed-by: Michal Kubiak < [email protected]> |
| 103 | +Link: https://patch.msgid.link/1741688260-28922-1-git-send-email-shradhagupta@linux.microsoft.com |
| 104 | + Signed-off-by: Paolo Abeni < [email protected]> |
| 105 | + |
| 106 | +(cherry picked from commit 3e64bb2ae7d9f2b3a8259d4d6b86ed1984d5460a) |
| 107 | + Signed-off-by: Jonathan Maple < [email protected]> |
| 108 | + |
| 109 | +# Conflicts: |
| 110 | +# drivers/net/ethernet/microsoft/mana/gdma_main.c |
| 111 | +# drivers/net/ethernet/microsoft/mana/mana_en.c |
| 112 | +diff --cc drivers/net/ethernet/microsoft/mana/gdma_main.c |
| 113 | +index c64e146c2832,11457b6296cc..000000000000 |
| 114 | +--- a/drivers/net/ethernet/microsoft/mana/gdma_main.c |
| 115 | ++++ b/drivers/net/ethernet/microsoft/mana/gdma_main.c |
| 116 | +@@@ -1533,6 -1540,14 +1533,17 @@@ static int mana_gd_probe(struct pci_de |
| 117 | + cleanup_gd: |
| 118 | + mana_gd_cleanup(pdev); |
| 119 | + unmap_bar: |
| 120 | +++<<<<<<< HEAD |
| 121 | +++======= |
| 122 | ++ /* |
| 123 | ++ * at this point we know that the other debugfs child dir/files |
| 124 | ++ * are either not yet created or are already cleaned up. |
| 125 | ++ * The pci debugfs folder clean-up now, will only be cleaning up |
| 126 | ++ * adapter-MTU file and apc->mana_pci_debugfs folder. |
| 127 | ++ */ |
| 128 | ++ debugfs_remove_recursive(gc->mana_pci_debugfs); |
| 129 | ++ gc->mana_pci_debugfs = NULL; |
| 130 | +++>>>>>>> 3e64bb2ae7d9 (net: mana: cleanup mana struct after debugfs_remove()) |
| 131 | + pci_iounmap(pdev, bar0_va); |
| 132 | + free_gc: |
| 133 | + pci_set_drvdata(pdev, NULL); |
| 134 | +@@@ -1553,6 -1568,10 +1564,13 @@@ static void mana_gd_remove(struct pci_d |
| 135 | + |
| 136 | + mana_gd_cleanup(pdev); |
| 137 | + |
| 138 | +++<<<<<<< HEAD |
| 139 | +++======= |
| 140 | ++ debugfs_remove_recursive(gc->mana_pci_debugfs); |
| 141 | ++ |
| 142 | ++ gc->mana_pci_debugfs = NULL; |
| 143 | ++ |
| 144 | +++>>>>>>> 3e64bb2ae7d9 (net: mana: cleanup mana struct after debugfs_remove()) |
| 145 | + pci_iounmap(pdev, gc->bar0_va); |
| 146 | + |
| 147 | + vfree(gc); |
| 148 | +@@@ -1604,6 -1623,10 +1622,13 @@@ static void mana_gd_shutdown(struct pci |
| 149 | + |
| 150 | + mana_gd_cleanup(pdev); |
| 151 | + |
| 152 | +++<<<<<<< HEAD |
| 153 | +++======= |
| 154 | ++ debugfs_remove_recursive(gc->mana_pci_debugfs); |
| 155 | ++ |
| 156 | ++ gc->mana_pci_debugfs = NULL; |
| 157 | ++ |
| 158 | +++>>>>>>> 3e64bb2ae7d9 (net: mana: cleanup mana struct after debugfs_remove()) |
| 159 | + pci_disable_device(pdev); |
| 160 | + } |
| 161 | + |
| 162 | +@@@ -1623,7 -1646,32 +1648,36 @@@ static struct pci_driver mana_driver = |
| 163 | + .shutdown = mana_gd_shutdown, |
| 164 | + }; |
| 165 | + |
| 166 | +++<<<<<<< HEAD |
| 167 | + +module_pci_driver(mana_driver); |
| 168 | +++======= |
| 169 | ++ static int __init mana_driver_init(void) |
| 170 | ++ { |
| 171 | ++ int err; |
| 172 | ++ |
| 173 | ++ mana_debugfs_root = debugfs_create_dir("mana", NULL); |
| 174 | ++ |
| 175 | ++ err = pci_register_driver(&mana_driver); |
| 176 | ++ if (err) { |
| 177 | ++ debugfs_remove(mana_debugfs_root); |
| 178 | ++ mana_debugfs_root = NULL; |
| 179 | ++ } |
| 180 | ++ |
| 181 | ++ return err; |
| 182 | ++ } |
| 183 | ++ |
| 184 | ++ static void __exit mana_driver_exit(void) |
| 185 | ++ { |
| 186 | ++ pci_unregister_driver(&mana_driver); |
| 187 | ++ |
| 188 | ++ debugfs_remove(mana_debugfs_root); |
| 189 | ++ |
| 190 | ++ mana_debugfs_root = NULL; |
| 191 | ++ } |
| 192 | ++ |
| 193 | ++ module_init(mana_driver_init); |
| 194 | ++ module_exit(mana_driver_exit); |
| 195 | +++>>>>>>> 3e64bb2ae7d9 (net: mana: cleanup mana struct after debugfs_remove()) |
| 196 | + |
| 197 | + MODULE_DEVICE_TABLE(pci, mana_id_table); |
| 198 | + |
| 199 | +diff --cc drivers/net/ethernet/microsoft/mana/mana_en.c |
| 200 | +index 2850738c9ac8,ae76ecc7a5d3..000000000000 |
| 201 | +--- a/drivers/net/ethernet/microsoft/mana/mana_en.c |
| 202 | ++++ b/drivers/net/ethernet/microsoft/mana/mana_en.c |
| 203 | +@@@ -716,6 -737,12 +716,15 @@@ static const struct net_device_ops mana |
| 204 | + |
| 205 | + static void mana_cleanup_port_context(struct mana_port_context *apc) |
| 206 | + { |
| 207 | +++<<<<<<< HEAD |
| 208 | +++======= |
| 209 | ++ /* |
| 210 | ++ * make sure subsequent cleanup attempts don't end up removing already |
| 211 | ++ * cleaned dentry pointer |
| 212 | ++ */ |
| 213 | ++ debugfs_remove(apc->mana_port_debugfs); |
| 214 | ++ apc->mana_port_debugfs = NULL; |
| 215 | +++>>>>>>> 3e64bb2ae7d9 (net: mana: cleanup mana struct after debugfs_remove()) |
| 216 | + kfree(apc->rxqs); |
| 217 | + apc->rxqs = NULL; |
| 218 | + } |
| 219 | +@@@ -1223,6 -1252,9 +1232,12 @@@ static void mana_destroy_eq(struct mana |
| 220 | + if (!ac->eqs) |
| 221 | + return; |
| 222 | + |
| 223 | +++<<<<<<< HEAD |
| 224 | +++======= |
| 225 | ++ debugfs_remove_recursive(ac->mana_eqs_debugfs); |
| 226 | ++ ac->mana_eqs_debugfs = NULL; |
| 227 | ++ |
| 228 | +++>>>>>>> 3e64bb2ae7d9 (net: mana: cleanup mana struct after debugfs_remove()) |
| 229 | + for (i = 0; i < gc->max_num_queues; i++) { |
| 230 | + eq = ac->eqs[i].eq; |
| 231 | + if (!eq) |
| 232 | +@@@ -1860,6 -1913,9 +1875,12 @@@ static void mana_destroy_txq(struct man |
| 233 | + return; |
| 234 | + |
| 235 | + for (i = 0; i < apc->num_queues; i++) { |
| 236 | +++<<<<<<< HEAD |
| 237 | +++======= |
| 238 | ++ debugfs_remove_recursive(apc->tx_qp[i].mana_tx_debugfs); |
| 239 | ++ apc->tx_qp[i].mana_tx_debugfs = NULL; |
| 240 | ++ |
| 241 | +++>>>>>>> 3e64bb2ae7d9 (net: mana: cleanup mana struct after debugfs_remove()) |
| 242 | + napi = &apc->tx_qp[i].tx_cq.napi; |
| 243 | + if (apc->tx_qp[i].txq.napi_initialized) { |
| 244 | + napi_synchronize(napi); |
| 245 | +@@@ -2016,6 -2099,9 +2037,12 @@@ static void mana_destroy_rxq(struct man |
| 246 | + if (!rxq) |
| 247 | + return; |
| 248 | + |
| 249 | +++<<<<<<< HEAD |
| 250 | +++======= |
| 251 | ++ debugfs_remove_recursive(rxq->mana_rx_debugfs); |
| 252 | ++ rxq->mana_rx_debugfs = NULL; |
| 253 | ++ |
| 254 | +++>>>>>>> 3e64bb2ae7d9 (net: mana: cleanup mana struct after debugfs_remove()) |
| 255 | + napi = &rxq->rx_cq.napi; |
| 256 | + |
| 257 | + if (napi_initialized) { |
| 258 | +* Unmerged path drivers/net/ethernet/microsoft/mana/gdma_main.c |
| 259 | +* Unmerged path drivers/net/ethernet/microsoft/mana/mana_en.c |
0 commit comments