mm/vmalloc: Do not trigger BUG() on BH disabled context
Subsystems (2)
Uladzislau Rezki (Sony)
maintainerPATCH 1/1 mm/vmalloc: Do not trigger BUG() on BH disabled context
__get_vm_area_node() currently triggers a BUG() if in_interrupt() returns true. However, in_interrupt() also reports true when BH are disabled.
The bridge code can call rhashtable_lookup_insert_fast() with bottom halves disabled:
__vlan_add()
-> br_fdb_add_local()
spin_lock_bh(&br->hash_lock); <-- Disable BH
-> fdb_add_local()
-> fdb_create()
-> rhashtable_lookup_insert_fast()
-> kvmalloc()
-> vmalloc()
-> __get_vm_area_node()
-> BUG_ON(in_interrupt()) spin_unlock_bh(&br->hash_lock)
this triggers the BUG() despite the caller not being in NMI or hard IRQ context.
Replace the in_interrupt() check with in_nmi() || in_hardirq().
--- mm/vmalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/vmalloc.c +1 -1
@@ -3209,7 +3209,7 @@ struct vm_struct *__get_vm_area_node(unsigned long size,struct vm_struct *area;unsigned long requested_size = size; -BUG_ON (in_interrupt ()); +BUG_ON (in_nmi () ||in_hardirq ()); size =ALIGN (size,1ul << shift);if (unlikely (!size))return NULL ;
Signature · 1 line
2.47.3
Andrew Morton
maintainerQuoted 19 lines · On Fri, 15 May 2026 17:30:09 +0200 "Uladzislau Rezki (Sony)"…
__get_vm_area_node()currently triggers aBUG()ifin_interrupt()returns true. However,in_interrupt()also reports true when BH are disabled.The bridge code can call
rhashtable_lookup_insert_fast()with bottom halves disabled:
__vlan_add()
->br_fdb_add_local()
spin_lock_bh(&br->hash_lock); <-- Disable BH
->fdb_add_local()-> fdb_create() -> rhashtable_lookup_insert_fast() -> kvmalloc() -> vmalloc() -> __get_vm_area_node() -> BUG_ON(in_interrupt())
spin_unlock_bh(&br->hash_lock)
Quoted 7 lines
this triggers the
BUG()despite the caller not being in NMI or hard IRQ context.Replace the
in_interrupt()check within_nmi()||in_hardirq().Cc Ido Schimmel <[email protected]>Fixes c6307674ed82 ("mm: kvmalloc: add non-blocking support for vmalloc")
Was added in 6.19 so I assumed we want cc:stable on this.
Quoted 3 lines
Reported-by [email protected]Signed-off-by Uladzislau Rezki (Sony) <[email protected]>
Uladzislau Rezki
maintainerQuoted 24 lines · Andrew Morton
Quoted 22 lines · On Fri, 15 May 2026 17:30:09 +0200 "Uladzislau Rezki (Sony)"…
__get_vm_area_node()currently triggers aBUG()ifin_interrupt()returns true. However,in_interrupt()also reports true when BH are disabled.The bridge code can call
rhashtable_lookup_insert_fast()with bottom halves disabled:
__vlan_add()
->br_fdb_add_local()
spin_lock_bh(&br->hash_lock); <-- Disable BH
->fdb_add_local()-> fdb_create() -> rhashtable_lookup_insert_fast() -> kvmalloc() -> vmalloc() -> __get_vm_area_node() -> BUG_ON(in_interrupt())
spin_unlock_bh(&br->hash_lock)this triggers the
BUG()despite the caller not being in NMI or hard IRQ context.
Quoted 7 lines
Quoted 4 lines
Replace the
in_interrupt()check within_nmi()||in_hardirq().Cc Ido Schimmel <[email protected]>Fixes c6307674ed82 ("mm: kvmalloc: add non-blocking support for vmalloc")Was added in 6.19 so I assumed we want cc:stable on this.
Thank you. Yep, we want cc:stable!
--
Uladzislau Rezki
Quoted 17 lines · Uladzislau Rezki (Sony)
__get_vm_area_node()currently triggers aBUG()ifin_interrupt()returns true. However,in_interrupt()also reports true when BH are disabled.The bridge code can call
rhashtable_lookup_insert_fast()with bottom halves disabled:
__vlan_add()
->br_fdb_add_local()
spin_lock_bh(&br->hash_lock); <-- Disable BH
->fdb_add_local()-> fdb_create() -> rhashtable_lookup_insert_fast() -> kvmalloc() -> vmalloc() -> __get_vm_area_node() -> BUG_ON(in_interrupt())
Quoted 4 lines
spin_unlock_bh(&br->hash_lock)this triggers the
BUG()despite the caller not being in NMI or hard IRQ context.
Because the current vmalloc supports non-blocking allocation, so we need to skip disabled BH or in_serving_softirq() cases to avoid unwanted BUG(). This change looks great to me, not sure if I undersand it correctly.
Thanks
Baoquan
Quoted 28 lines
Replace the
in_interrupt()check within_nmi()||in_hardirq().Cc Ido Schimmel <[email protected]>Fixes c6307674ed82 ("mm: kvmalloc: add non-blocking support for vmalloc")Reported-by [email protected]Signed-off-by Uladzislau Rezki (Sony) <[email protected]>--- mm/vmalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/vmalloc.c +1
-1@@ -3209,7 +3209,7 @@ struct vm_struct *__get_vm_area_node(unsigned long size,struct vm_struct *area;unsigned long requested_size = size; -BUG_ON (in_interrupt ()); +BUG_ON (in_nmi () ||in_hardirq ()); size =ALIGN (size,1ul << shift);if (unlikely (!size))return NULL ;Signature · 1 line
2.47.3
Uladzislau Rezki
maintainerQuoted 23 lines · Baoquan He
Quoted 17 lines · Uladzislau Rezki (Sony)
__get_vm_area_node()currently triggers aBUG()ifin_interrupt()returns true. However,in_interrupt()also reports true when BH are disabled.The bridge code can call
rhashtable_lookup_insert_fast()with bottom halves disabled:
__vlan_add()
->br_fdb_add_local()
spin_lock_bh(&br->hash_lock); <-- Disable BH
->fdb_add_local()-> fdb_create() -> rhashtable_lookup_insert_fast() -> kvmalloc() -> vmalloc() -> __get_vm_area_node() -> BUG_ON(in_interrupt())Quoted 4 lines
spin_unlock_bh(&br->hash_lock)this triggers the
BUG()despite the caller not being in NMI or hard IRQ context.
Quoted 7 lines
Because the current vmalloc supports non-blocking allocation, so we need to skip disabled BH or
in_serving_softirq()cases to avoid unwantedBUG(). This change looks great to me, not sure if I undersand it correctly.Reviewed-by Baoquan He <[email protected]>
Thank you!
--
Uladzislau Rezki