lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20240819113619.1267937-1-vernon2gm@gmail.com>
Date: Mon, 19 Aug 2024 19:36:19 +0800
From: Vernon Yang <vernon2gm@...il.com>
To: akpm@...ux-foundation.org
Cc: linux-mm@...ck.org,
	linux-kernel@...r.kernel.org,
	Vernon Yang <vernon2gm@...il.com>
Subject: [PATCH] mm/util: Fix meminfo CommitLimit

On a machine with 8GB memory, no any swap device, the /proc/meminfo
CommitLimit shows 4070944KB regardless of overcommit_memory being set to
0/1/2. This patch fixes this bug, and the final effect is as follows:

- when overcommit_memory being set to 0  ## OVERCOMMIT_GUESS
CommitLimit:     8141884 kB
- when overcommit_memory being set to 1  ## OVERCOMMIT_ALWAYS
CommitLimit:           0 kB
- when overcommit_memory being set to 2  ## OVERCOMMIT_NEVER
  and overcommit_ratio 50
CommitLimit:     4070940 kB

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Vernon Yang <vernon2gm@...il.com>
---
 mm/util.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/mm/util.c b/mm/util.c
index bd283e2132e0..4ee93c11dd62 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -932,12 +932,21 @@ int overcommit_kbytes_handler(const struct ctl_table *table, int write, void *bu
 }
 
 /*
- * Committed memory limit enforced when OVERCOMMIT_NEVER policy is used
+ * Committed virtual memory limit
+ *
+ * return 0 if OVERCOMMIT_ALWAYS policy is used, otherwise return committed
+ * memory limit enforced if OVERCOMMIT_GUESS or OVERCOMMIT_NEVER policy is used.
  */
 unsigned long vm_commit_limit(void)
 {
 	unsigned long allowed;
 
+	if (sysctl_overcommit_memory == OVERCOMMIT_ALWAYS)
+		return 0;
+
+	if (sysctl_overcommit_memory == OVERCOMMIT_GUESS)
+		return totalram_pages() + total_swap_pages;
+
 	if (sysctl_overcommit_kbytes)
 		allowed = sysctl_overcommit_kbytes >> (PAGE_SHIFT - 10);
 	else

base-commit: 47ac09b91befbb6a235ab620c32af719f8208399
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ