[Devel] [PATCH RHEL7 COMMIT] ub: ub_ratelimit does not initialize ub_ratelimit->lock

Vasily Averin vvs at virtuozzo.com
Tue Jun 15 16:05:59 MSK 2021


The commit is pushed to "branch-rh7-3.10.0-1160.31.1.vz7.181.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.31.1.vz7.181.3
------>
commit 2db0f3333215ed3ca72866fa67be74d6bf477faa
Author: Vasily Averin <vvs at virtuozzo.com>
Date:   Tue Jun 15 16:05:59 2021 +0300

    ub: ub_ratelimit does not initialize ub_ratelimit->lock
    
    repro02 from PSBM-130602 executed on debug kernel inside centos7
    container triggers the following message:
    
     INFO: trying to register non-static key.
     the code is fine but needs lockdep annotation.
     turning off the locking correctness validator.
     Call Trace:
      [<ffffffff96ec9edc>] dump_stack+0x19/0x1b
      [<ffffffff96ec21fa>] register_lock_class.part.27+0x38/0x3c
      [<ffffffff96760426>] __lock_acquire+0x1276/0x1630
      [<ffffffff967610c9>] lock_acquire+0x99/0x1e0
      [<ffffffff96ed50d4>] _raw_spin_trylock+0x64/0x80
      [<ffffffff96a5bb11>] ___ratelimit+0x51/0x140
      [<ffffffff9674a707>] __charge_beancounter_locked+0x147/0x170
      [<ffffffff9674a77f>] charge_beancounter+0x4f/0x80
      [<ffffffff96da822e>] xt_replace_table+0x1de/0x3d0
       ...
     Fatal resource shortage: numiptent, UB xxxx
    
    This happen because of ub.ub_ratelimit does not have properly
    initialized 'lock' spinlock.
    
    https://jira.sw.ru/browse/PSBM-130672
    Signed-off-by: Vasily Averin <vvs at virtuozzo.com>
---
 kernel/bc/beancounter.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/bc/beancounter.c b/kernel/bc/beancounter.c
index 287d4c5..5e04d6c 100644
--- a/kernel/bc/beancounter.c
+++ b/kernel/bc/beancounter.c
@@ -1067,8 +1067,7 @@ static void init_beancounter_nolimits(struct user_beancounter *ub)
 	ub->ub_parms[UB_OOMGUARPAGES].barrier = totalram_pages * 3 / 4;
 
 	/* Ratelimit for messages in the kernel log */
-	ub->ub_ratelimit.burst = 4;
-	ub->ub_ratelimit.interval = 300*HZ;
+	ratelimit_state_init(&ub->ub_ratelimit, 300*HZ, 4);
 }
 
 static DEFINE_PER_CPU(struct ub_percpu_struct, ub0_percpu);


More information about the Devel mailing list