[Devel] [PATCH VZ7] ubc: override siginfo beancounter limit

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Thu Jun 20 10:53:39 MSK 2024


Do the same thing as is already done for rlimit for critical signals
(sig < SIGRTMIN && (is_si_special || si_code != SI_USER)) - just ignore
the limit and try to preserve siginfo.

Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 include/bc/misc.h | 3 ++-
 kernel/bc/misc.c  | 5 +++--
 kernel/signal.c   | 2 +-
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/bc/misc.h b/include/bc/misc.h
index 3d4ba162ffae..3302973ad293 100644
--- a/include/bc/misc.h
+++ b/include/bc/misc.h
@@ -22,7 +22,8 @@ UB_DECLARE_VOID_FUNC(ub_file_uncharge(struct file *f))
 UB_DECLARE_FUNC(int, ub_flock_charge(struct file_lock *fl, int hard))
 UB_DECLARE_VOID_FUNC(ub_flock_uncharge(struct file_lock *fl))
 UB_DECLARE_FUNC(int, ub_siginfo_charge(struct sigqueue *q,
-			struct user_beancounter *ub, gfp_t gfp_mask))
+			struct user_beancounter *ub, gfp_t gfp_mask,
+			int override))
 UB_DECLARE_VOID_FUNC(ub_siginfo_uncharge(struct sigqueue *q))
 UB_DECLARE_VOID_FUNC(ub_task_get(struct user_beancounter *ub,
 			struct task_struct *task))
diff --git a/kernel/bc/misc.c b/kernel/bc/misc.c
index eee8e1884164..69124eb834cd 100644
--- a/kernel/bc/misc.c
+++ b/kernel/bc/misc.c
@@ -74,9 +74,10 @@ void ub_file_uncharge(struct file *f)
  */
 
 int ub_siginfo_charge(struct sigqueue *sq, struct user_beancounter *ub,
-			gfp_t gfp_mask)
+		      gfp_t gfp_mask, int override)
 {
-	if (charge_beancounter_fast(ub, UB_NUMSIGINFO, 1, UB_HARD))
+	if (charge_beancounter_fast(ub, UB_NUMSIGINFO, 1,
+				    override ? UB_FORCE : UB_HARD))
 		goto out_num;
 
 	sq->sig_ub = get_beancounter(ub);
diff --git a/kernel/signal.c b/kernel/signal.c
index aff5a844ebe8..c725acf4ae4d 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -418,7 +418,7 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
 
 	if (override_rlimit || likely(sigpending <= task_rlimit(t, RLIMIT_SIGPENDING))) {
 		q = kmem_cache_alloc(sigqueue_cachep, flags);
-		if (q && ub_siginfo_charge(q, get_task_ub(t), flags)) {
+		if (q && ub_siginfo_charge(q, get_task_ub(t), flags, override_rlimit)) {
 			kmem_cache_free(sigqueue_cachep, q);
 			q = NULL;
 		}
-- 
2.45.2



More information about the Devel mailing list