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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 12 Aug 2016 19:56:52 +0530
From:	Ronit Halder <ronit.crj@...il.com>
To:	linux-kernel@...r.kernel.org
Cc:	tglx@...utronix.de, mingo@...hat.com, hpa@...or.com, bp@...e.de,
	dyoung@...hat.com, jroedel@...e.de, krzysiek@...lesie.net,
	msalter@...hat.com, ebiederm@...ssion.com,
	akpm@...ux-foundation.org, bhe@...hat.com, vgoyal@...hat.com,
	mnfhuang@...il.com, kexec@...ts.infradead.org,
	kirill.shutemov@...ux.intel.com, mchehab@....samsung.com,
	aarcange@...hat.com, vdavydov@...allels.com,
	dan.j.williams@...el.com, jack@...e.cz, linux-mm@...ck.org,
	Ronit Halder <ronit.crj@...il.com>
Subject: [RFC 4/4] Enable memory allocation through sysfs interface

Modify the sysfs entry "kernel/kexec_crash_size" to allocate or
release memory at run time. The memory size will be written to
the entry in MB. If the user uses high memory (in x86_64). Then
size will be only set for high memory. The low memory will be
allocated automatically. If the size set is zero, the both the
allocated region in low and high memory will be released.

Signed-off-by: Ronit Halder <ronit.crj@...il.com>

---
 kernel/ksysfs.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
index e83b264..4cc286d 100644
--- a/kernel/ksysfs.c
+++ b/kernel/ksysfs.c
@@ -116,10 +116,31 @@ static ssize_t kexec_crash_size_store(struct kobject *kobj,
 {
 	unsigned long cnt;
 	int ret;
+	int size;
 
 	if (kstrtoul(buf, 0, &cnt))
 		return -EINVAL;
-
+#ifdef CONFIG_KEXEC_CMA
+#ifdef CONFIG_X86
+	size = cnt << 20;
+	if (cnt == 0) {
+		crash_free_memory_low();
+		ret = crash_free_memory(crash_get_memory_size());
+	} else if (cnt > 0) {
+		if (!crash_get_memory_size_low() && crash_alloc_memory_low())
+			return -ENOMEM;
+		ret = crash_free_memory(crash_get_memory_size());
+		if (ret)
+			return ret;
+		ret = crash_alloc_memory(size);
+		if (ret)
+			return ret;
+	} else {
+		return -EINVAL;
+	}
+	return count;
+#endif
+#endif
 	ret = crash_shrink_memory(cnt);
 	return ret < 0 ? ret : count;
 }
-- 
2.9.0.GIT

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ