Re: [PATCH net] net: dev: Detect dev_hold() after netdev_wait_allrefs()
From: Jann Horn <jannh@google.com>
Date: 2022-01-28 02:27:33
Also in:
lkml
On Fri, Jan 28, 2022 at 3:23 AM Eric Dumazet [off-list ref] wrote:
On Thu, Jan 27, 2022 at 6:22 PM Jakub Kicinski [off-list ref] wrote:quoted
On Fri, 28 Jan 2022 03:14:14 +0100 Jann Horn wrote:quoted
Oh. Whoops. That's what I get for only testing without CONFIG_PCPU_DEV_REFCNT... I guess a better place to put the new check would be directly after checking for "dev->reg_state == NETREG_UNREGISTERING"? Like this?Possibly a very silly suggestion but perhaps we should set the pointer to NULL for the pcpu case and let it crash?
I like that idea... but this_cpu_dec()/this_cpu_inc() use GS-relative addressing, at least on X86-64, so NULL might make things worse, I think? /proc/kallsyms on my machine starts with: 0000000000000000 A fixed_percpu_data 0000000000000000 A __per_cpu_start 0000000000001000 A cpu_debug_store 0000000000002000 A irq_stack_backing_store 0000000000006000 A cpu_tss_rw 000000000000b000 A gdt_page 000000000000c000 A exception_stacks 0000000000010000 A entry_stack_storage 0000000000011000 A espfix_waddr So we'd probably need some different placeholder instead of NULL to actually crash...
It is already set to 0
I think he meant do it already in netdev_run_todo(), not just in free_netdev()?