Skip to contentSkip to conversation

thp testcase come from CVE reproducer

PATCH In review Han Pingtian 5 participants 18 messages Feb 25, 2011 – May 31, 2011 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 thp testcase come from CVE reproducer

This is a reproducer of CVE-2011-0999, which fixed by mainline commit a7d6e4ecdb7648478ddec76d30d87d03d6e22b31:

"Transparent hugepages can only be created if rmap is fully functional. So we must prevent hugepages to be created while is_vma_temporary_stack() is true."

When running in a loop, it can trigger panic like this, if kernel unpatched:

kernel BUG at mm/huge_memory.c:1260!
invalid opcode: 0000 [#1] SMP
last sysfs file: /sys/devices/system/cpu/cpu23/cache/index2/shared_cpu_map
....

So I recommend to run it as 'thp01 -I xxx'.

---
 runtest/mm                        |    2 +
 testcases/kernel/mem/thp/Makefile |   23 +++++++++
 testcases/kernel/mem/thp/thp01.c  |   99 +++++++++++++++++++++++++++++++++++++
 3 files changed, 124 insertions(+), 0 deletions(-)
 create mode 100644 testcases/kernel/mem/thp/Makefile
 create mode 100644 testcases/kernel/mem/thp/thp01.c
runtest/mm +2 -0
index f097256..6b7e003 100644
@@ -84,3 +84,5 @@ oom01 oom01
 oom02 oom02
 oom03 oom03
 oom04 oom04
+
+thp01 thp01 -I 600
testcases/kernel/mem/thp/Makefile new file +23 -0
new file mode 100644
index 0000000..dbfbc1b
@@ -0,0 +1,23 @@
+#
+#  Copyright (C) 2010  Red Hat, Inc.
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or (at
+#  your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful, but
+#  WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+#  02110-1301, USA.
+#
+
+top_srcdir              ?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/mem/thp/thp01.c new file +99 -0

99 lines not on this page · raw message

Signature · 12 lines
1.7.1

------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#1 lore raw
Quoted 13 lines · Han Pingtian

This is a reproducer of  CVE-2011-0999, which fixed by mainline commit a7d6e4ecdb7648478ddec76d30d87d03d6e22b31:

"Transparent hugepages can only be created if rmap is fully functional. So we must prevent hugepages to be created while is_vma_temporary_stack() is true."

When running in a loop, it can trigger panic like this, if kernel unpatched:

kernel BUG at mm/huge_memory.c:1260!
invalid opcode: 0000 [#1] SMP
last sysfs file: /sys/devices/system/cpu/cpu23/cache/index2/shared_cpu_map

...

testcases/kernel/mem/thp/thp01.c line 58

Quoted 8 lines
testcases/kernel/mem/thp/thp01.c new file +8 -0
+static option_t options[] = {
+       {NULL, NULL, NULL}
+};
+
+static void usage(void)
+{
+    return;
+}

You can delete this if you do what I suggest below...

...

Quoted 2 lines

+       msg = parse_opts(argc, argv, options, usage);
+       if (msg != NULL)

`if ((msg = parse_opts(argc, argv, NULL, NULL)) != NULL)' is preferred.

Quoted 2 lines

+                               if (execve("/bin/true", c, c) == -1)
+                                       tst_brkm(TBROK|TERRNO, NULL, "execve");

Not all systems have /bin/true. It would be better to do:

/bin/sh -c ':'

etc, as we have code that depends on this type of shell-required POSIX behavior.

Thanks,
-Garrett

------------------------------------------------------------------------------
What You Don't Know About Data Connectivity CAN Hurt You This paper provides an overview of data connectivity, details its effect on application quality, and explores various alternative solutions. http://p.sf.net/sfu/progress-d2d
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#2 lore raw
Quoted 28 lines · Garrett Cooper
Quoted 13 lines · Han Pingtian

This is a reproducer of  CVE-2011-0999, which fixed by mainline commit a7d6e4ecdb7648478ddec76d30d87d03d6e22b31:

"Transparent hugepages can only be created if rmap is fully functional. So we must prevent hugepages to be created while is_vma_temporary_stack() is true."

When running in a loop, it can trigger panic like this, if kernel unpatched:

kernel BUG at mm/huge_memory.c:1260!
invalid opcode: 0000 [#1] SMP
last sysfs file: /sys/devices/system/cpu/cpu23/cache/index2/shared_cpu_map

...

Review

Quoted 8 lines
(quoted diff) +8 -0
+static option_t options[] = {
+       {NULL, NULL, NULL}
+};
+
+static void usage(void)
+{
+    return;
+}

You can delete this if you do what I suggest below...

Quoted 6 lines

...

Quoted 2 lines

+       msg = parse_opts(argc, argv, options, usage);
+       if (msg != NULL)

`if ((msg = parse_opts(argc, argv, NULL, NULL)) != NULL)' is preferred.

Thanks. I have updated this according to your suggestion.

Quoted 10 lines
Quoted 3 lines

+                               if (execve("/bin/true", c, c) == -1)
+                                       tst_brkm(TBROK|TERRNO, NULL, "execve");

Not all systems have /bin/true. It would be better to do:

/bin/sh -c ':'

etc, as we have code that depends on this type of shell-required POSIX behavior.

I'm sorry for I cannot figure out how to do this way. I tried, but cannot crash unpatched kernel anymore. So I think the simple workaround is checking if /bin/true installed in the program:

+
+ if (WEXITSTATUS(st) == 2)
+ tst_brkm(TBROK, NULL, "Do you have /bin/true installed?");
+

Please review the updated version.

Quoted 2 lines

Thanks,
-Garrett

Signature · 5 lines
Han Pingtian
Quality Engineer
hpt @ #kernel-qe
Red Hat, Inc
Freedom ... courage ... Commitment ... ACCOUNTABILITY

From 38c3526fdb59c0b18015914745f2d43fc6c6b1a3 Mon Sep 17 00:00:00 2001
From: Han Pingtian <[email protected]>
Date: Fri, 25 Feb 2011 17:51:24 +0800
Subject: [PATCH] thp testcase come from CVE reproducer

This is a reproducer of CVE-2011-0999, which fixed by mainline commit a7d6e4ecdb7648478ddec76d30d87d03d6e22b31:

"Transparent hugepages can only be created if rmap is fully functional. So we must prevent hugepages to be created while is_vma_temporary_stack() is true."

When running in a loop, it can trigger panic like this, if kernel unpatched:

kernel BUG at mm/huge_memory.c:1260!
invalid opcode: 0000 [#1] SMP
last sysfs file: /sys/devices/system/cpu/cpu23/cache/index2/shared_cpu_map
....

So I recommend to run it as 'thp01 -I xxx'.

---
 runtest/mm                        |    2 +
 testcases/kernel/mem/thp/Makefile |   23 +++++++++
 testcases/kernel/mem/thp/thp01.c  |   95 +++++++++++++++++++++++++++++++++++++
 3 files changed, 120 insertions(+), 0 deletions(-)
 create mode 100644 testcases/kernel/mem/thp/Makefile
 create mode 100644 testcases/kernel/mem/thp/thp01.c
runtest/mm +2 -0
index 1296e59..51cc82d 100644
@@ -85,3 +85,5 @@ oom01 oom01
 oom02 oom02
 oom03 oom03
 oom04 oom04
+
+thp01 thp01 -I 600
testcases/kernel/mem/thp/Makefile new file +23 -0
new file mode 100644
index 0000000..dbfbc1b
@@ -0,0 +1,23 @@
+#
+#  Copyright (C) 2010  Red Hat, Inc.
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or (at
+#  your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful, but
+#  WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+#  02110-1301, USA.
+#
+
+top_srcdir              ?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/mem/thp/thp01.c new file +95 -0

95 lines not on this page · raw message

Signature · 1 line
1.7.1

------------------------------------------------------------------------------
What You Don't Know About Data Connectivity CAN Hurt You This paper provides an overview of data connectivity, details its effect on application quality, and explores various alternative solutions. http://p.sf.net/sfu/progress-d2d

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#3 lore raw
Quoted 51 lines · Han Pingtian
Quoted 28 lines · Garrett Cooper
Quoted 13 lines · Han Pingtian

This is a reproducer of  CVE-2011-0999, which fixed by mainline commit a7d6e4ecdb7648478ddec76d30d87d03d6e22b31:

"Transparent hugepages can only be created if rmap is fully functional. So we must prevent hugepages to be created while is_vma_temporary_stack() is true."

When running in a loop, it can trigger panic like this, if kernel unpatched:

kernel BUG at mm/huge_memory.c:1260!
invalid opcode: 0000 [#1] SMP
last sysfs file: /sys/devices/system/cpu/cpu23/cache/index2/shared_cpu_map

...

Review

Quoted 8 lines
(quoted diff) +8 -0
+static option_t options[] = {
+       {NULL, NULL, NULL}
+};
+
+static void usage(void)
+{
+    return;
+}

You can delete this if you do what I suggest below...

Quoted 6 lines

...

Quoted 2 lines

+       msg = parse_opts(argc, argv, options, usage);
+       if (msg != NULL)

`if ((msg = parse_opts(argc, argv, NULL, NULL)) != NULL)' is preferred.

Thanks. I have updated this according to your suggestion.

Quoted 10 lines
Quoted 3 lines

+                               if (execve("/bin/true", c, c) == -1)
+                                       tst_brkm(TBROK|TERRNO, NULL, "execve");

Not all systems have /bin/true. It would be better to do:

/bin/sh -c ':'

etc, as we have code that depends on this type of shell-required POSIX behavior.

I'm sorry for I cannot figure out how to do this way. I tried, but cannot crash unpatched kernel anymore. So I think the simple workaround is checking if /bin/true installed in the program:

testcases/kernel/mem/thp/thp01.c line 86

Quoted 4 lines
testcases/kernel/mem/thp/thp01.c new file +4 -0
+
+                               if (WEXITSTATUS(st) == 2)
+                                       tst_brkm(TBROK, NULL, "Do you have /bin/true installed?");
+

Is this acceptable, please?

Thanks.

Quoted 196 lines

Please review the updated version.

Quoted 2 lines

Thanks,
-Garrett

Signature · 5 lines
Han Pingtian
Quality Engineer
hpt @ #kernel-qe
Red Hat, Inc
Freedom ... courage ... Commitment ... ACCOUNTABILITY
Quoted 1 line

From 38c3526fdb59c0b18015914745f2d43fc6c6b1a3 Mon Sep 17 00:00:00 2001

From: Han Pingtian <[email protected]>
Date: Fri, 25 Feb 2011 17:51:24 +0800
Subject: [PATCH] thp testcase come from CVE reproducer

This is a reproducer of CVE-2011-0999, which fixed by mainline commit a7d6e4ecdb7648478ddec76d30d87d03d6e22b31:

"Transparent hugepages can only be created if rmap is fully functional. So we must prevent hugepages to be created while is_vma_temporary_stack() is true."

When running in a loop, it can trigger panic like this, if kernel unpatched:

kernel BUG at mm/huge_memory.c:1260!
invalid opcode: 0000 [#1] SMP
last sysfs file: /sys/devices/system/cpu/cpu23/cache/index2/shared_cpu_map
....

So I recommend to run it as 'thp01 -I xxx'.

---
 runtest/mm                        |    2 +
 testcases/kernel/mem/thp/Makefile |   23 +++++++++
 testcases/kernel/mem/thp/thp01.c  |   95 +++++++++++++++++++++++++++++++++++++
 3 files changed, 120 insertions(+), 0 deletions(-)
 create mode 100644 testcases/kernel/mem/thp/Makefile
 create mode 100644 testcases/kernel/mem/thp/thp01.c
runtest/mm +2 -0
index 1296e59..51cc82d 100644
@@ -85,3 +85,5 @@ oom01 oom01
 oom02 oom02
 oom03 oom03
 oom04 oom04
+
+thp01 thp01 -I 600
testcases/kernel/mem/thp/Makefile new file +23 -0
new file mode 100644
index 0000000..dbfbc1b
@@ -0,0 +1,23 @@
+#
+#  Copyright (C) 2010  Red Hat, Inc.
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or (at
+#  your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful, but
+#  WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+#  02110-1301, USA.
+#
+
+top_srcdir              ?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/mem/thp/thp01.c new file +95 -0
new file mode 100644
index 0000000..0b6ec1a
@@ -0,0 +1,95 @@
+/*
+ * This is a reproducer of  CVE-2011-0999, which fixed by mainline commit
+ * a7d6e4ecdb7648478ddec76d30d87d03d6e22b31:
+ *
+ * "Transparent hugepages can only be created if rmap is fully
+ * functional. So we must prevent hugepages to be created while
+ * is_vma_temporary_stack() is true."
+ *
+ * It will cause a panic something like this, if the patch didn't get applied:
+ *
+ * kernel BUG at mm/huge_memory.c:1260!
+ * invalid opcode: 0000 [#1] SMP
+ * last sysfs file: /sys/devices/system/cpu/cpu23/cache/index2/shared_cpu_map
+ * ....
+ *
+ * Copyright (C) 2010  Red Hat, Inc.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Further, this software is distributed without any warranty that it
+ * is free of the rightful claim of any third person regarding
+ * infringement or the like.  Any license provided herein, whether
+ * implied or otherwise, applies only to this software file.  Patent
+ * licenses, if any, provided herein do not apply to combinations of
+ * this program with other software, or any other product whatsoever.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+#include "test.h"
+#include "usctest.h"
+#include "config.h"
+
+char *TCID = "thp01";
+int TST_TOTAL = 1;
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/resource.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+int main(int argc, char **argv) {
+	int i, lc, st;
+	pid_t pid;
+	char *msg;
+	char *c[257];
+	char cc[32*4096];
+	struct rlimit rl = {
+		.rlim_cur = RLIM_INFINITY,
+		.rlim_max = RLIM_INFINITY,
+	};
+
+	if ((msg = parse_opts(argc, argv, NULL, NULL)) != NULL)
+		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+
+	for (lc = 0; TEST_LOOPING(lc); lc++) {
+		switch (pid = fork()) {
+			case -1:
+				tst_brkm(TBROK|TERRNO, NULL, "fork");
+			case 0:
+				memset(cc, 'c', 32*4096-1);
+				for (i=0;i<256;i++)
+					c[i] = cc;
+				if (setrlimit(RLIMIT_STACK, &rl) == -1)
+					tst_brkm(TBROK|TERRNO, NULL, "setrlimit");
+				if (execve("/bin/true", c, c) == -1)
+					tst_brkm(TBROK|TERRNO, NULL, "execve");
+			default:
+				if (waitpid(pid, &st, 0) == -1)
+					tst_brkm(TBROK|TERRNO, NULL, "waitpid");
+
+				if (! WIFEXITED(st))
+					tst_brkm(TBROK, NULL, "child exits abnormally");
+
+				if (WEXITSTATUS(st) == 2)
+					tst_brkm(TBROK, NULL, "Do you have /bin/true installed?");
+
+				if (WEXITSTATUS(st) != 0)
+					tst_brkm(TBROK, NULL, "chaild exits with non-zero value");
+
+				tst_resm(TPASS, "thp01 pass");
+		}
+	}
+
+        tst_exit();
+}
Signature · 13 lines
1.7.1


------------------------------------------------------------------------------
What You Don't Know About Data Connectivity CAN Hurt You
This paper provides an overview of data connectivity, details
its effect on application quality, and explores various alternative
solutions. http://p.sf.net/sfu/progress-d2d

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Signature · 15 lines
Han Pingtian
Quality Engineer
hpt @ #kernel-qe
Red Hat, Inc
Freedom ... courage ... Commitment ... ACCOUNTABILITY

------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#4 lore raw
In reply to Han Pingtian

Hi!

Quoted 9 lines
Quoted 6 lines

Not all systems have /bin/true. It would be better to do:

/bin/sh -c ':'

etc, as we have code that depends on this type of shell-required POSIX behavior.

I'm sorry for I cannot figure out how to do this way. I tried, but cannot crash unpatched kernel anymore. So I think the simple workaround is checking if /bin/true installed in the program:

It should as simple as execve("/bin/sh -c ':'", c, c), or that didn't work?

What about "/bin/sh -c ''" ?

testcases/kernel/mem/thp/thp01.c line 51

Quoted 8 lines
testcases/kernel/mem/thp/thp01.c new file +8 -0
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/resource.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+int main(int argc, char **argv) {

The curly bracked should be on new line here.

Quoted 9 lines
testcases/kernel/mem/thp/thp01.c new file +9 -0
+	int i, lc, st;
+	pid_t pid;
+	char *msg;
+	char *c[257];
+	char cc[32*4096];
+	struct rlimit rl = {
+		.rlim_cur = RLIM_INFINITY,
+		.rlim_max = RLIM_INFINITY,
+	};

testcases/kernel/mem/thp/thp01.c line 70

Quoted 10 lines
testcases/kernel/mem/thp/thp01.c new file +10 -0
+
+	if ((msg = parse_opts(argc, argv, NULL, NULL)) != NULL)
+		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+
+	for (lc = 0; TEST_LOOPING(lc); lc++) {
+		switch (pid = fork()) {
+			case -1:
+				tst_brkm(TBROK|TERRNO, NULL, "fork");
+			case 0:
+				memset(cc, 'c', 32*4096-1);

Hmm should not the cc actually be C string and so terminated with '\0'?

testcases/kernel/mem/thp/thp01.c line 82

Quoted 12 lines
testcases/kernel/mem/thp/thp01.c new file +12 -0
+				for (i=0;i<256;i++)
+					c[i] = cc;
+				if (setrlimit(RLIMIT_STACK, &rl) == -1)
+					tst_brkm(TBROK|TERRNO, NULL, "setrlimit");
+				if (execve("/bin/true", c, c) == -1)
+					tst_brkm(TBROK|TERRNO, NULL, "execve");
+			default:
+				if (waitpid(pid, &st, 0) == -1)
+					tst_brkm(TBROK|TERRNO, NULL, "waitpid");
+
+				if (! WIFEXITED(st))
+					tst_brkm(TBROK, NULL, "child exits abnormally");

Please don't add space after ! here.

Quoted 12 lines
testcases/kernel/mem/thp/thp01.c new file +12 -0
+				if (WEXITSTATUS(st) == 2)
+					tst_brkm(TBROK, NULL, "Do you have /bin/true installed?");
+
+				if (WEXITSTATUS(st) != 0)
+					tst_brkm(TBROK, NULL, "chaild exits with non-zero value");
+
+				tst_resm(TPASS, "thp01 pass");
+		}
+	}
+
+        tst_exit();
+}
Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw

Hi!

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 6 lines

Not all systems have /bin/true. It would be better to do:

/bin/sh -c ':'

etc, as we have code that depends on this type of shell-required POSIX behavior.

I'm sorry for I cannot figure out how to do this way. I tried, but cannot crash unpatched kernel anymore. So I think the simple workaround is checking if /bin/true installed in the program:

Quoted 5 lines
Quoted 1 line

It should as simple as execve("/bin/sh -c ':'", c, c), or that didn't work?

execve doesn't work that way. It should be:

execve("/bin/sh", "sh", "-c", ":");

Ahh, right, so it's difficuilt in this case as it seems that trigger is particulary big argv and envp (at least it seems so from the source, some better description wouldn't harm too).

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#7 lore raw
In reply to Han Pingtian

I'm going to be more anal retentive with this review than I was previously.

Quoted 13 lines · Han Pingtian

This is a reproducer of  CVE-2011-0999, which fixed by mainline commit a7d6e4ecdb7648478ddec76d30d87d03d6e22b31:

"Transparent hugepages can only be created if rmap is fully functional. So we must prevent hugepages to be created while is_vma_temporary_stack() is true."

When running in a loop, it can trigger panic like this, if kernel unpatched:

kernel BUG at mm/huge_memory.c:1260!
invalid opcode: 0000 [#1] SMP
last sysfs file: /sys/devices/system/cpu/cpu23/cache/index2/shared_cpu_map

...

Quoted 28 lines

So I recommend to run it as 'thp01 -I xxx'.

testcases/kernel/mem/thp/thp01.c new file +26 -0
+static option_t options[] = {
+       {NULL, NULL, NULL}
+};
+
+static void usage(void)
+{
+    return;
+}
+
+int main(int argc, char **argv) {
+       int i, lc, st;
+       pid_t pid;
+       char *msg;
+       char *c[257];
+       char cc[32*4096];
+       struct rlimit rl = {
+               .rlim_cur =RLIM_INFINITY,
+               .rlim_max=RLIM_INFINITY,
+       };
+
+       msg = parse_opts(argc, argv, options, usage);
+       if (msg != NULL)
+               tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+
+       for (lc = 0; TEST_LOOPING(lc); lc++) {
+               switch (pid = fork()) {

testcases/kernel/mem/thp/thp01.c line 86

Quoted 10 lines
testcases/kernel/mem/thp/thp01.c new file +10 -0
+                       case -1:
+                               tst_brkm(TBROK|TERRNO, NULL, "fork");
+                       case 0:
+                               memset(cc, 'c', 32*4096-1);
+                               for (i=0;i<256;i++)
+                                       c[i] = cc;
+                               if (setrlimit(RLIMIT_STACK, &rl) == -1)
+                                       tst_brkm(TBROK|TERRNO, NULL, "setrlimit");
+                               if (execve("/bin/true", c, c) == -1)
+                                       tst_brkm(TBROK|TERRNO, NULL, "execve");

I would just do perror("execve"), etc, because this is a child process and according to the style guide you shouldn't use tst_resm in child processes (I recommended that in the style guide for a very good reason that you should understand).

Quoted 6 lines

+                       default:
+                               if (waitpid(pid, &st, 0) == -1)
+                                       tst_brkm(TBROK|TERRNO, NULL, "waitpid");
+
+                               if (! WIFEXITED(st))
+                                       tst_brkm(TBROK, NULL, "child exit status is %d", WEXITSTATUS(st));

I agree with what Cyril said before about whitespace.

...

-Garrett

------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#8 lore raw

I have updated the patch based on your suggestions. Please review.

Thanks.

Han Pingtian

Quoted 75 lines · Garrett Cooper

I'm going to be more anal retentive with this review than I was previously.

Quoted 13 lines · Han Pingtian

This is a reproducer of  CVE-2011-0999, which fixed by mainline commit a7d6e4ecdb7648478ddec76d30d87d03d6e22b31:

"Transparent hugepages can only be created if rmap is fully functional. So we must prevent hugepages to be created while is_vma_temporary_stack() is true."

When running in a loop, it can trigger panic like this, if kernel unpatched:

kernel BUG at mm/huge_memory.c:1260!
invalid opcode: 0000 [#1] SMP
last sysfs file: /sys/devices/system/cpu/cpu23/cache/index2/shared_cpu_map

...

Quoted 28 lines

So I recommend to run it as 'thp01 -I xxx'.

(quoted diff) +26 -0
+static option_t options[] = {
+       {NULL, NULL, NULL}
+};
+
+static void usage(void)
+{
+    return;
+}
+
+int main(int argc, char **argv) {
+       int i, lc, st;
+       pid_t pid;
+       char *msg;
+       char *c[257];
+       char cc[32*4096];
+       struct rlimit rl = {
+               .rlim_cur =RLIM_INFINITY,
+               .rlim_max=RLIM_INFINITY,
+       };
+
+       msg = parse_opts(argc, argv, options, usage);
+       if (msg != NULL)
+               tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+
+       for (lc = 0; TEST_LOOPING(lc); lc++) {
+               switch (pid = fork()) {

Review

Quoted 10 lines
(quoted diff) +10 -0
+                       case -1:
+                               tst_brkm(TBROK|TERRNO, NULL, "fork");
+                       case 0:
+                               memset(cc, 'c', 32*4096-1);
+                               for (i=0;i<256;i++)
+                                       c[i] = cc;
+                               if (setrlimit(RLIMIT_STACK, &rl) == -1)
+                                       tst_brkm(TBROK|TERRNO, NULL, "setrlimit");
+                               if (execve("/bin/true", c, c) == -1)
+                                       tst_brkm(TBROK|TERRNO, NULL, "execve");

I would just do perror("execve"), etc, because this is a child process and according to the style guide you shouldn't use tst_resm in child processes (I recommended that in the style guide for a very good reason that you should understand).

Quoted 6 lines

+                       default:
+                               if (waitpid(pid, &st, 0) == -1)
+                                       tst_brkm(TBROK|TERRNO, NULL, "waitpid");
+
+                               if (! WIFEXITED(st))
+                                       tst_brkm(TBROK, NULL, "child exit status is %d", WEXITSTATUS(st));

I agree with what Cyril said before about whitespace.

...

-Garrett

Quoted 10 lines

------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

From 0e226273edd93e50afdf5d698bfc000cc9823a8c Mon Sep 17 00:00:00 2001
From: Han Pingtian <[email protected]>
Date: Fri, 25 Feb 2011 17:51:24 +0800
Subject: [PATCH] thp testcase come from CVE reproducer

This is a reproducer of CVE-2011-0999, which fixed by mainline commit a7d6e4ecdb7648478ddec76d30d87d03d6e22b31:

"Transparent hugepages can only be created if rmap is fully functional. So we must prevent hugepages to be created while is_vma_temporary_stack() is true."

When running in a loop, it can trigger panic like this, if kernel unpatched:

kernel BUG at mm/huge_memory.c:1260!
invalid opcode: 0000 [#1] SMP
last sysfs file: /sys/devices/system/cpu/cpu23/cache/index2/shared_cpu_map
....

So I recommend to run it as 'thp01 -I xxx'.

---
 runtest/mm                        |    2 +
 testcases/kernel/mem/thp/Makefile |   23 ++++++++
 testcases/kernel/mem/thp/thp01.c  |  102 +++++++++++++++++++++++++++++++++++++
 3 files changed, 127 insertions(+), 0 deletions(-)
 create mode 100644 testcases/kernel/mem/thp/Makefile
 create mode 100644 testcases/kernel/mem/thp/thp01.c
runtest/mm +2 -0
index f2d50d6..dded529 100644
@@ -78,3 +78,5 @@ oom01 oom01
 oom02 oom02
 oom03 oom03
 oom04 oom04
+
+thp01 thp01 -I 600
testcases/kernel/mem/thp/Makefile new file +23 -0
new file mode 100644
index 0000000..dbfbc1b
@@ -0,0 +1,23 @@
+#
+#  Copyright (C) 2010  Red Hat, Inc.
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or (at
+#  your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful, but
+#  WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+#  02110-1301, USA.
+#
+
+top_srcdir              ?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/mem/thp/thp01.c new file +102 -0

102 lines not on this page · raw message

Signature · 1 line
1.7.4.2

------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#9 lore raw
Quoted 3 lines · Han Pingtian

I have updated the patch based on your suggestions. Please review.

Thanks.

An inline diff would have been nice. Anyhow..

...

+#include "test.h"
+#include "usctest.h"
+#include "config.h"
+
+char *TCID = "thp01";
+int TST_TOTAL = 1;
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/resource.h>
+#include <sys/types.h>
+#include <sys/wait.h>

Please read the style guide and the example code I've provided in the style guide. This doesn't conform to those examples.

+int main(int argc, char **argv)
+{
+ int i, lc, st;
+ pid_t pid;
+ char *msg;
+ char *c[257];
+ char cc[32*4096];
+ struct rlimit rl = {
+ .rlim_cur = RLIM_INFINITY,
+ .rlim_max = RLIM_INFINITY,
+ };
+
+ if ((msg = parse_opts(argc, argv, NULL, NULL)) != NULL)
+ tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+
+ for (lc = 0; TEST_LOOPING(lc); lc++) {
+ switch (pid = fork()) {
+ case -1:

Unnecessary indentation.

+ tst_brkm(TBROK|TERRNO, NULL, "fork");
+ case 0:
+ memset(cc, 'c', 32*4096-1);
+ cc[32*4096-1] = '\0';

Make the magic number (32*4096-1) a number. BTW -- did you derive this from a pagesize or something? If so, you should really use the sysconf function to derive _SC_PAGESIZE.

+ for (i=0;i<256;i++)

[Lack of] whitespace.

+ c[i] = cc;
+ if (setrlimit(RLIMIT_STACK, &rl) == -1) {
+ perror("setrlimit");
+ exit(1);
+ }
+ if (execve("/bin/true", c, c) == -1) {
+ perror("execve");
+ exit(2);
+ }

So, this isn't supposed to exit I assume? Seems kind of funky (i.e. would run out of processes).

+ default:
+ if (waitpid(pid, &st, 0) == -1)
+ tst_brkm(TBROK|TERRNO, NULL, "waitpid");
+
+ if (!WIFEXITED(st))
+ tst_brkm(TBROK, NULL, "child exits abnormally");

*exited.

+ if (WEXITSTATUS(st) == 2)
+ tst_brkm(TBROK, NULL, "Do you have /bin/true installed?");

Add a check at the beginning of the test to ensure (via stat) that /bin/true exists. That way you can skip this check.

+ if (WEXITSTATUS(st) != 0)
+ tst_brkm(TBROK, NULL, "chaild exits with non-zero value");

You didn't do a proper exit(0). How is this possible (unless the forked child runs to completion and exits the loop first which just seems like a bad idea because you're executing tst_exit() at the bottom)?

+ tst_resm(TPASS, "thp01 pass");

How do you know it passes from just one run when it could cascade over several iterations? My gut feeling is that this really should be moved somewhere else.

+ }
+ }
+
+ tst_exit();

Indentation is off.

+}

------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#10 lore raw

PATCH v3 1/1 thp testcase come from CVE reproducer

This is a reproducer of CVE-2011-0999, which fixed by mainline commit a7d6e4ecdb7648478ddec76d30d87d03d6e22b31:

"Transparent hugepages can only be created if rmap is fully functional. So we must prevent hugepages to be created while is_vma_temporary_stack() is true."

When running in a loop, it can trigger panic like this, if kernel unpatched:

kernel BUG at mm/huge_memory.c:1260!
invalid opcode: 0000 [#1] SMP
last sysfs file: /sys/devices/system/cpu/cpu23/cache/index2/shared_cpu_map
....

So I recommend to run it as 'thp01 -I xxx'.

v2 & v3: update code style

---
 runtest/mm                        |    2 +
 testcases/kernel/mem/thp/Makefile |   23 +++++++
 testcases/kernel/mem/thp/thp01.c  |  127 +++++++++++++++++++++++++++++++++++++
 3 files changed, 152 insertions(+), 0 deletions(-)
 create mode 100644 testcases/kernel/mem/thp/Makefile
 create mode 100644 testcases/kernel/mem/thp/thp01.c
runtest/mm +2 -0
index f2d50d6..dded529 100644
@@ -78,3 +78,5 @@ oom01 oom01
 oom02 oom02
 oom03 oom03
 oom04 oom04
+
+thp01 thp01 -I 600
testcases/kernel/mem/thp/Makefile new file +23 -0
new file mode 100644
index 0000000..d43511a
@@ -0,0 +1,23 @@
+#
+#  Copyright (C) 2011  Red Hat, Inc.
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or (at
+#  your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful, but
+#  WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+#  02110-1301, USA.
+#
+
+top_srcdir              ?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/mem/thp/thp01.c new file +127 -0

127 lines not on this page · raw message

------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#11 lore raw

Hi!

Quoted 14 lines
testcases/kernel/mem/thp/thp01.c new file +14 -0
+#include <sys/types.h>
+#include <sys/resource.h>
+#include <sys/wait.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include "test.h"
+#include "usctest.h"
+#include "config.h"
+
+char *TCID = "thp01";
+int TST_TOTAL = 1;
+
+#define ARRAY_SZ	256

testcases/kernel/mem/thp/thp01.c line 62

Quoted 10 lines
testcases/kernel/mem/thp/thp01.c new file +10 -0
+
+static int ps;
+static long length;
+static char *array[ARRAY_SZ];
+static char *arg;
+
+struct rlimit rl = {
+	.rlim_cur = RLIM_INFINITY,
+	.rlim_max = RLIM_INFINITY,
+};

Perhaps static struct rlimit just to be consistent.

Quoted 37 lines
testcases/kernel/mem/thp/thp01.c new file +37 -0
+static void setup(void);
+static void cleanup(void);
+
+int main(int argc, char **argv)
+{
+	int i, lc, st;
+	pid_t pid;
+	char *msg;
+
+	msg = parse_opts(argc, argv, NULL, NULL);
+	if (msg != NULL)
+		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+
+	setup();
+
+	for (lc = 0; TEST_LOOPING(lc); lc++) {
+		switch (pid = fork()) {
+		case -1:
+			tst_brkm(TBROK|TERRNO, cleanup, "fork");
+		case 0:
+			memset(arg, 'c', length - 1);
+			arg[length - 1] = '\0';
+			for (i = 0; i < ARRAY_SZ; i++)
+				array[i] = arg;
+			if (setrlimit(RLIMIT_STACK, &rl) == -1) {
+				perror("setrlimit");
+				exit(1);
+			}
+			if (execve("/bin/true", array, array) == -1) {
+				perror("execve");
+				exit(1);
+			}
+		default:
+			if (waitpid(pid, &st, 0) == -1)
+				tst_brkm(TBROK|TERRNO, cleanup, "waitpid");
+			if (!WIFEXITED(st) || WEXITSTATUS(st) != 0)
+				tst_brkm(TBROK, cleanup,

testcases/kernel/mem/thp/thp01.c line 110

Quoted 10 lines
testcases/kernel/mem/thp/thp01.c new file +10 -0
+					"child exited abnormally");
+		}
+	}
+	tst_resm(TPASS, "system didn't crash, pass.");
+	cleanup();
+	tst_exit();
+}
+
+static void setup()
+{

Please void into prototypes here as well eg: static void setup(void)

testcases/kernel/mem/thp/thp01.c line 112

Quoted 2 lines
testcases/kernel/mem/thp/thp01.c new file +2 -0
+	if (access("/bin/true", F_OK) == -1)
+		tst_brkm(TBROK, NULL, "/bin/true not exist");

Should rather be "/bin/true does not exists" and maybe TCONF rather than TBROK.

testcases/kernel/mem/thp/thp01.c line 116

Quoted 3 lines
testcases/kernel/mem/thp/thp01.c new file +3 -0
+	ps = sysconf(_SC_PAGESIZE);
+	length = 32 * ps;
+	arg = malloc(length * sizeof(char));

sizeof(char) is 1 by definition

testcases/kernel/mem/thp/thp01.c line 124

Quoted 8 lines
testcases/kernel/mem/thp/thp01.c new file +8 -0
+	if (arg == NULL)
+		tst_brkm(TBROK|TERRNO, NULL, "malloc");
+
+	tst_sig(FORK, DEF_HANDLER, cleanup);
+	TEST_PAUSE;
+}
+
+static void cleanup()

Here void as vell.

Quoted 3 lines
testcases/kernel/mem/thp/thp01.c new file +3 -0
+{
+	TEST_CLEANUP;
+}
Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#12 lore raw

PATCH v4 1/1 thp testcase come from CVE reproducer

This is a reproducer of CVE-2011-0999, which fixed by mainline commit a7d6e4ecdb7648478ddec76d30d87d03d6e22b31:

"Transparent hugepages can only be created if rmap is fully functional. So we must prevent hugepages to be created while is_vma_temporary_stack() is true."

When running in a loop, it can trigger panic like this, if kernel unpatched:

kernel BUG at mm/huge_memory.c:1260!
invalid opcode: 0000 [#1] SMP
last sysfs file: /sys/devices/system/cpu/cpu23/cache/index2/shared_cpu_map
....

So I recommend to run it as 'thp01 -I xxx'.

---
 runtest/mm                        |    2 +
 testcases/kernel/mem/thp/Makefile |   23 +++++++
 testcases/kernel/mem/thp/thp01.c  |  126 +++++++++++++++++++++++++++++++++++++
 3 files changed, 151 insertions(+), 0 deletions(-)
 create mode 100644 testcases/kernel/mem/thp/Makefile
 create mode 100644 testcases/kernel/mem/thp/thp01.c
runtest/mm +2 -0
index f2d50d6..dded529 100644
@@ -78,3 +78,5 @@ oom01 oom01
 oom02 oom02
 oom03 oom03
 oom04 oom04
+
+thp01 thp01 -I 600
testcases/kernel/mem/thp/Makefile new file +23 -0
new file mode 100644
index 0000000..d43511a
@@ -0,0 +1,23 @@
+#
+#  Copyright (C) 2011  Red Hat, Inc.
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or (at
+#  your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful, but
+#  WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+#  02110-1301, USA.
+#
+
+top_srcdir              ?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/mem/thp/thp01.c new file +126 -0

126 lines not on this page · raw message

------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#13 lore raw

dont hard depend on /bin/true. simply execute it through $PATH ... i.e. use execvp().
-mike

------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#14 lore raw

PATCH v5 1/1 thp testcase come from CVE reproducer

This is a reproducer of CVE-2011-0999, which fixed by mainline commit a7d6e4ecdb7648478ddec76d30d87d03d6e22b31:

"Transparent hugepages can only be created if rmap is fully functional. So we must prevent hugepages to be created while is_vma_temporary_stack() is true."

When running in a loop, it can trigger panic like this, if kernel unpatched:

kernel BUG at mm/huge_memory.c:1260!
invalid opcode: 0000 [#1] SMP
last sysfs file: /sys/devices/system/cpu/cpu23/cache/index2/shared_cpu_map
....

So I recommend to run it as 'thp01 -I xxx'.

v5: not using hard depend on /bin/true, use execvp() and "true" instead.

---
 runtest/mm                        |    2 +
 testcases/kernel/mem/thp/Makefile |   23 +++++++
 testcases/kernel/mem/thp/thp01.c  |  124 +++++++++++++++++++++++++++++++++++++
 3 files changed, 149 insertions(+), 0 deletions(-)
 create mode 100644 testcases/kernel/mem/thp/Makefile
 create mode 100644 testcases/kernel/mem/thp/thp01.c
runtest/mm +2 -0
index f2d50d6..dded529 100644
@@ -78,3 +78,5 @@ oom01 oom01
 oom02 oom02
 oom03 oom03
 oom04 oom04
+
+thp01 thp01 -I 600
testcases/kernel/mem/thp/Makefile new file +23 -0
new file mode 100644
index 0000000..d43511a
@@ -0,0 +1,23 @@
+#
+#  Copyright (C) 2011  Red Hat, Inc.
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or (at
+#  your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful, but
+#  WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+#  02110-1301, USA.
+#
+
+top_srcdir              ?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/mem/thp/thp01.c new file +124 -0

124 lines not on this page · raw message

------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#15 lore raw
Quoted 22 lines · Caspar Zhang

This is a reproducer of CVE-2011-0999, which fixed by mainline commit a7d6e4ecdb7648478ddec76d30d87d03d6e22b31:

"Transparent hugepages can only be created if rmap is fully functional. So we must prevent hugepages to be created while is_vma_temporary_stack() is true."

When running in a loop, it can trigger panic like this, if kernel unpatched:

kernel BUG at mm/huge_memory.c:1260!
invalid opcode: 0000 [#1] SMP
last sysfs file: /sys/devices/system/cpu/cpu23/cache/index2/shared_cpu_map
....

So I recommend to run it as 'thp01 -I xxx'.

v5: not using hard depend on /bin/true, use execvp() and "true" instead.

Quoted 8 lines
---
 runtest/mm                        |    2 +
 testcases/kernel/mem/thp/Makefile |   23 +++++++
 testcases/kernel/mem/thp/thp01.c  |  124 +++++++++++++++++++++++++++++++++++++
 3 files changed, 149 insertions(+), 0 deletions(-)
 create mode 100644 testcases/kernel/mem/thp/Makefile
 create mode 100644 testcases/kernel/mem/thp/thp01.c

Hi all, I've modified the patch as suggested and tested it. Any comments on this new case?

Thanks,
Caspar

------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Ltp-list mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#16 lore raw
In reply to Caspar Zhang

Hi!

runtest/mm oom01 oom01 · line 82

Quoted 10 lines
runtest/mm +2 -0
index f2d50d6..dded529 100644
@@ -78,3 +78,5 @@ oom01 oom01
 oom02 oom02
 oom03 oom03
 oom04 oom04
+
+thp01 thp01 -I 600

On my machine this runs for 10 minutes (-I 1 runs for more than second). Is this amount of iterations really needed?

The rest looks good enough.

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#17 lore raw

PATCH v6 1/1 mm: thp testcase come from CVE reproducer

This is a reproducer of CVE-2011-0999, which fixed by mainline commit a7d6e4ecdb7648478ddec76d30d87d03d6e22b31:

"Transparent hugepages can only be created if rmap is fully functional. So we must prevent hugepages to be created while is_vma_temporary_stack() is true."

When running in a loop, it can trigger panic like this, if kernel unpatched:

kernel BUG at mm/huge_memory.c:1260!
invalid opcode: 0000 [#1] SMP
last sysfs file:
/sys/devices/system/cpu/cpu23/cache/index2/shared_cpu_map
....

So I recommend to run it as 'thp01 -I xxx'.

v5: not using hard depend on /bin/true, use execvp() and "true" instead.
v6: set testing time to 2 min.

---
 runtest/mm                        |    2 +
 testcases/kernel/mem/thp/Makefile |   23 +++++++
 testcases/kernel/mem/thp/thp01.c  |  124 +++++++++++++++++++++++++++++++++++++
 3 files changed, 149 insertions(+), 0 deletions(-)
 create mode 100644 testcases/kernel/mem/thp/Makefile
 create mode 100644 testcases/kernel/mem/thp/thp01.c
runtest/mm +2 -0
index f2d50d6..df7d0cb 100644
@@ -78,3 +78,5 @@ oom01 oom01
 oom02 oom02
 oom03 oom03
 oom04 oom04
+
+thp01 thp01 -I 120
testcases/kernel/mem/thp/Makefile new file +23 -0
new file mode 100644
index 0000000..d43511a
@@ -0,0 +1,23 @@
+#
+#  Copyright (C) 2011  Red Hat, Inc.
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or (at
+#  your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful, but
+#  WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+#  02110-1301, USA.
+#
+
+top_srcdir              ?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/mem/thp/thp01.c new file +124 -0

124 lines not on this page · raw message

------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security. With the market-leading solution for virtual backup and recovery, you get blazing-fast, flexible, and affordable data protection. Download your free trial now.
http://p.sf.net/sfu/quest-d2dcopy1

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#18 lore raw

Re: [LTP] [PATCH v6] mm: thp testcase come from CVE reproducer

Hi!
Commited, thanks.

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger. 
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today. 
http://p.sf.net/sfu/quest-sfdev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list