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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220301151438.166118-2-yejiajian2018@email.szu.edu.cn>
Date:   Tue,  1 Mar 2022 23:14:37 +0800
From:   Jiajian Ye <yejiajian2018@...il.szu.edu.cn>
To:     akpm@...ux-foundation.org
Cc:     sfr@...b.auug.org.au, caoyixuan2019@...il.szu.edu.cn,
        hanshenghong2019@...il.szu.edu.cn,
        zhaochongxi2019@...il.szu.edu.cn, weizhenliang@...wei.com,
        zhangyinan2019@...il.szu.edu.cn, linux-kernel@...r.kernel.org,
        Jiajian Ye <yejiajian2018@...il.szu.edu.cn>
Subject: [PATCH 2/3] tools/vm/page_owner_sort.c: add a security check

Add a security check after using malloc() to allocate memory.

Signed-off-by: Jiajian Ye <yejiajian2018@...il.szu.edu.cn>
---
 tools/vm/page_owner_sort.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/vm/page_owner_sort.c b/tools/vm/page_owner_sort.c
index 79d69c3b84ed..69fb6ca7c0b7 100644
--- a/tools/vm/page_owner_sort.c
+++ b/tools/vm/page_owner_sort.c
@@ -217,7 +217,13 @@ static void add_list(char *buf, int len)
 		printf("max_size too small??\n");
 		exit(1);
 	}
+
 	list[list_size].txt = malloc(len+1);
+	if (!list[list_size].txt) {
+		printf("Out of memory\n");
+		exit(1);
+	}
+
 	list[list_size].len = len;
 	list[list_size].num = 1;
 	list[list_size].page_num = get_page_num(buf);
-- 
2.25.1



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ