The overcommit test uses sum_total, the sum (memory and swap) to test
the overcommit settings.
This fixes two problems on 32-bit systems. The first is seen with a
integer overflow can occur when calculating sum_total * 2, if the
sum_total is larger than 2GB. The second is limited virtual address
space (2-3GB) means the test can fail from address space exhaustion
before overcommit has been tested.
Now the test runs correctly on low-memory 32-bit systems while avoiding
both the overflow bug and virtual address space issues.
Signed-off-by: Ben Copeland <ben.copeland(a)linaro.org>
---
.../kernel/mem/tunable/overcommit_memory.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/testcases/kernel/mem/tunable/overcommit_memory.c b/testcases/kernel/mem/tunable/overcommit_memory.c
index 9b2cb479d..f9f60ebc3 100644
--- a/testcases/kernel/mem/tunable/overcommit_memory.c
+++ b/testcases/kernel/mem/tunable/overcommit_memory.c
@@ -68,6 +68,7 @@
#define DEFAULT_OVER_RATIO 50L
#define EXPECT_PASS 0
#define EXPECT_FAIL 1
+#define ONE_GB (1024 * 1024 * TST_KB)
#define OVERCOMMIT_MEMORY "/proc/sys/vm/overcommit_memory"
#define OVERCOMMIT_RATIO "/proc/sys/vm/overcommit_ratio"
@@ -141,14 +142,26 @@ static void overcommit_memory_test(void)
update_mem();
alloc_and_check(free_total / 2, EXPECT_PASS);
- alloc_and_check(sum_total * 2, EXPECT_FAIL);
+ /* Skip if sum_total * 2 would exceed address space.
+ * On 32-bit, skip when sum_total > ULONG_MAX/4 (~1GB).
+ * Most 32-bit systems with <=1GB RAM can map 2x that in 3GB vaddr space.
+ * Systems with 2GB+ RAM likely cannot fit allocations in vaddr space. */
+ if (tst_kernel_bits() == 64 || (unsigned long)sum_total <= ONE_GB) {
+ alloc_and_check(sum_total * 2, EXPECT_FAIL);
+ } else {
+ tst_res(TCONF, "Skipping large allocation test due to address space limits");
+ }
/* start to test overcommit_memory=1 */
TST_SYS_CONF_LONG_SET(OVERCOMMIT_MEMORY, 1, 1);
alloc_and_check(sum_total / 2, EXPECT_PASS);
- alloc_and_check(sum_total, EXPECT_PASS);
- alloc_and_check(sum_total * 2, EXPECT_PASS);
+ if (tst_kernel_bits() == 64 || (unsigned long)sum_total <= ONE_GB) {
+ alloc_and_check(sum_total, EXPECT_PASS);
+ alloc_and_check(sum_total * 2, EXPECT_PASS);
+ } else {
+ tst_res(TCONF, "Skipping large allocation tests due to address space limits");
+ }
}
--
2.51.0
This is the start of the stable review cycle for the 6.12.51 release.
There are 10 patches in this series, all will be posted as a response
to this one. If anyone has any issues with these being applied, please
let me know.
Responses should be made by Sun, 05 Oct 2025 16:02:25 +0000.
Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.12.51-rc…
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-6.12.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Linux 6.12.51-rc1
Srinivas Kandagatla <srinivas.kandagatla(a)oss.qualcomm.com>
ASoC: qcom: audioreach: fix potential null pointer dereference
Matvey Kovalev <matvey.kovalev(a)ispras.ru>
wifi: ath11k: fix NULL dereference in ath11k_qmi_m3_load()
Charan Teja Kalla <charan.kalla(a)oss.qualcomm.com>
mm: swap: check for stable address space before operating on the VMA
Thadeu Lima de Souza Cascardo <cascardo(a)igalia.com>
media: uvcvideo: Mark invalid entities with id UVC_INVALID_ENTITY_ID
Larshin Sergey <Sergey.Larshin(a)kaspersky.com>
media: rc: fix races with imon_disconnect()
Duoming Zhou <duoming(a)zju.edu.cn>
media: tuner: xc5000: Fix use-after-free in xc5000_release
Duoming Zhou <duoming(a)zju.edu.cn>
media: b2c2: Fix use-after-free causing by irq_check_work in flexcop_pci_remove
Wang Haoran <haoranwangsec(a)gmail.com>
scsi: target: target_core_configfs: Add length check to avoid buffer overflow
Kees Cook <kees(a)kernel.org>
gcc-plugins: Remove TODO_verify_il for GCC >= 16
Breno Leitao <leitao(a)debian.org>
crypto: sha256 - fix crash at kexec
-------------
Diffstat:
Makefile | 4 +-
drivers/media/pci/b2c2/flexcop-pci.c | 2 +-
drivers/media/rc/imon.c | 27 +++++++++----
drivers/media/tuners/xc5000.c | 2 +-
drivers/media/usb/uvc/uvc_driver.c | 73 ++++++++++++++++++++++-------------
drivers/media/usb/uvc/uvcvideo.h | 2 +
drivers/net/wireless/ath/ath11k/qmi.c | 2 +-
drivers/target/target_core_configfs.c | 2 +-
include/crypto/sha256_base.h | 2 +-
mm/swapfile.c | 3 ++
scripts/gcc-plugins/gcc-common.h | 7 ++++
sound/soc/qcom/qdsp6/topology.c | 4 +-
12 files changed, 87 insertions(+), 43 deletions(-)