public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/arm/morello/main] cheri: stdio-common: Add test for %#p printf modifier
@ 2022-10-26 15:21 Szabolcs Nagy
0 siblings, 0 replies; 4+ messages in thread
From: Szabolcs Nagy @ 2022-10-26 15:21 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=22e29c18815cc9e0cf1a15efe69518337e735405
commit 22e29c18815cc9e0cf1a15efe69518337e735405
Author: Carlos Eduardo Seo <carlos.seo@arm.com>
Date: Mon Aug 8 16:09:37 2022 -0300
cheri: stdio-common: Add test for %#p printf modifier
Testcase for printing capabilities.
Diff:
---
sysdeps/aarch64/Makefile | 6 ++
sysdeps/aarch64/morello/tst-printf-cap.c | 95 ++++++++++++++++++++++++++++++++
2 files changed, 101 insertions(+)
diff --git a/sysdeps/aarch64/Makefile b/sysdeps/aarch64/Makefile
index 9d6e16f66e..560e0e9c8f 100644
--- a/sysdeps/aarch64/Makefile
+++ b/sysdeps/aarch64/Makefile
@@ -68,3 +68,9 @@ endif
ifeq ($(subdir),malloc)
sysdep_malloc_debug_routines = __mtag_tag_zero_region __mtag_tag_region
endif
+
+ifeq (yes,$(aarch64-purecap))
+ifeq ($(subdir),stdio-common)
+tests += tst-printf-cap
+endif
+endif
diff --git a/sysdeps/aarch64/morello/tst-printf-cap.c b/sysdeps/aarch64/morello/tst-printf-cap.c
new file mode 100644
index 0000000000..4d0f58fcb5
--- /dev/null
+++ b/sysdeps/aarch64/morello/tst-printf-cap.c
@@ -0,0 +1,95 @@
+/* Check printf for capabilities functionality.
+ Copyright (C) 2022 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <support/check.h>
+#include <support/xunistd.h>
+#include <support/test-driver.h>
+
+int check_match (char *ptr, const char *pattern)
+{
+ char str[100];
+ sprintf (str, "%#p", ptr);
+ verbose_printf ("Test permission \"%s\" in \"%s\".\n", pattern, str);
+ if (!strstr(str, pattern))
+ {
+ printf ("FAIL: permission \"%s\" in \"%s\".\n", pattern, str);
+ return 1;
+ }
+ return 0;
+}
+
+int check_bounds (char *ptr, uint64_t len)
+{
+ char str[100];
+ char u_bound[100];
+ sprintf (str, "%#p", ptr);
+ sprintf (u_bound, "%p", (ptr + len));
+ verbose_printf ("Test bounds \"%s\" in \"%s\"\n", u_bound, str);
+ if (!strstr (str, u_bound))
+ {
+ printf ("FAIL: bounds \"%s\" in \"%s\"\n", u_bound, str);
+ return 1;
+ }
+ return 0;
+}
+
+static void *
+map (int prot)
+{
+ return xmmap (0, 16, prot, MAP_ANONYMOUS | MAP_PRIVATE, -1);
+}
+
+static int
+do_test (void)
+{
+ static const int x;
+ static int y;
+ void *r_global = (void *) &x;
+ void *rw_global = &y;
+ void *rx_global = (void *) do_test;
+ void *rw_malloc = malloc (16);
+ void *none_map = map (PROT_NONE);
+ void *r_map = map (PROT_READ);
+ void *rw_map = map (PROT_READ | PROT_WRITE);
+ void *rx_map = map (PROT_READ | PROT_EXEC);
+ void *rwx_map = map (PROT_READ | PROT_WRITE | PROT_EXEC);
+ int ret = 0;
+
+ /* Test permissions. */
+ ret += check_match (none_map, "[,");
+ ret += check_match (r_global, "[rR,");
+ ret += check_match (r_map, "[rR,");
+ ret += check_match (rw_global, "[rwRW,");
+ ret += check_match (rw_malloc, "[rwRW,");
+ ret += check_match (rw_map, "[rwRW,");
+ ret += check_match (rx_global, "[rxRE,");
+ ret += check_match (rx_map, "[rxRE,");
+ ret += check_match (rwx_map, "[rwxRWE,");
+
+ /* Test bounds. */
+ ret += check_bounds (rw_malloc, 16);
+
+ return ret;
+}
+
+#include <support/test-driver.c>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [glibc/arm/morello/main] cheri: stdio-common: Add test for %#p printf modifier
@ 2022-11-23 14:49 Szabolcs Nagy
0 siblings, 0 replies; 4+ messages in thread
From: Szabolcs Nagy @ 2022-11-23 14:49 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=eb7d21e59be30fcd837961bc4a0f7b48a56f2cbb
commit eb7d21e59be30fcd837961bc4a0f7b48a56f2cbb
Author: Carlos Eduardo Seo <carlos.seo@arm.com>
Date: Mon Aug 8 16:09:37 2022 -0300
cheri: stdio-common: Add test for %#p printf modifier
Testcase for printing capabilities.
Diff:
---
sysdeps/aarch64/Makefile | 6 ++
sysdeps/aarch64/morello/tst-printf-cap.c | 95 ++++++++++++++++++++++++++++++++
2 files changed, 101 insertions(+)
diff --git a/sysdeps/aarch64/Makefile b/sysdeps/aarch64/Makefile
index 9d6e16f66e..560e0e9c8f 100644
--- a/sysdeps/aarch64/Makefile
+++ b/sysdeps/aarch64/Makefile
@@ -68,3 +68,9 @@ endif
ifeq ($(subdir),malloc)
sysdep_malloc_debug_routines = __mtag_tag_zero_region __mtag_tag_region
endif
+
+ifeq (yes,$(aarch64-purecap))
+ifeq ($(subdir),stdio-common)
+tests += tst-printf-cap
+endif
+endif
diff --git a/sysdeps/aarch64/morello/tst-printf-cap.c b/sysdeps/aarch64/morello/tst-printf-cap.c
new file mode 100644
index 0000000000..4d0f58fcb5
--- /dev/null
+++ b/sysdeps/aarch64/morello/tst-printf-cap.c
@@ -0,0 +1,95 @@
+/* Check printf for capabilities functionality.
+ Copyright (C) 2022 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <support/check.h>
+#include <support/xunistd.h>
+#include <support/test-driver.h>
+
+int check_match (char *ptr, const char *pattern)
+{
+ char str[100];
+ sprintf (str, "%#p", ptr);
+ verbose_printf ("Test permission \"%s\" in \"%s\".\n", pattern, str);
+ if (!strstr(str, pattern))
+ {
+ printf ("FAIL: permission \"%s\" in \"%s\".\n", pattern, str);
+ return 1;
+ }
+ return 0;
+}
+
+int check_bounds (char *ptr, uint64_t len)
+{
+ char str[100];
+ char u_bound[100];
+ sprintf (str, "%#p", ptr);
+ sprintf (u_bound, "%p", (ptr + len));
+ verbose_printf ("Test bounds \"%s\" in \"%s\"\n", u_bound, str);
+ if (!strstr (str, u_bound))
+ {
+ printf ("FAIL: bounds \"%s\" in \"%s\"\n", u_bound, str);
+ return 1;
+ }
+ return 0;
+}
+
+static void *
+map (int prot)
+{
+ return xmmap (0, 16, prot, MAP_ANONYMOUS | MAP_PRIVATE, -1);
+}
+
+static int
+do_test (void)
+{
+ static const int x;
+ static int y;
+ void *r_global = (void *) &x;
+ void *rw_global = &y;
+ void *rx_global = (void *) do_test;
+ void *rw_malloc = malloc (16);
+ void *none_map = map (PROT_NONE);
+ void *r_map = map (PROT_READ);
+ void *rw_map = map (PROT_READ | PROT_WRITE);
+ void *rx_map = map (PROT_READ | PROT_EXEC);
+ void *rwx_map = map (PROT_READ | PROT_WRITE | PROT_EXEC);
+ int ret = 0;
+
+ /* Test permissions. */
+ ret += check_match (none_map, "[,");
+ ret += check_match (r_global, "[rR,");
+ ret += check_match (r_map, "[rR,");
+ ret += check_match (rw_global, "[rwRW,");
+ ret += check_match (rw_malloc, "[rwRW,");
+ ret += check_match (rw_map, "[rwRW,");
+ ret += check_match (rx_global, "[rxRE,");
+ ret += check_match (rx_map, "[rxRE,");
+ ret += check_match (rwx_map, "[rwxRWE,");
+
+ /* Test bounds. */
+ ret += check_bounds (rw_malloc, 16);
+
+ return ret;
+}
+
+#include <support/test-driver.c>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [glibc/arm/morello/main] cheri: stdio-common: Add test for %#p printf modifier
@ 2022-10-27 13:59 Szabolcs Nagy
0 siblings, 0 replies; 4+ messages in thread
From: Szabolcs Nagy @ 2022-10-27 13:59 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=29d90ec1f5c11ad65ccebb5b9e3280649343810f
commit 29d90ec1f5c11ad65ccebb5b9e3280649343810f
Author: Carlos Eduardo Seo <carlos.seo@arm.com>
Date: Mon Aug 8 16:09:37 2022 -0300
cheri: stdio-common: Add test for %#p printf modifier
Testcase for printing capabilities.
Diff:
---
sysdeps/aarch64/Makefile | 6 ++
sysdeps/aarch64/morello/tst-printf-cap.c | 95 ++++++++++++++++++++++++++++++++
2 files changed, 101 insertions(+)
diff --git a/sysdeps/aarch64/Makefile b/sysdeps/aarch64/Makefile
index 9d6e16f66e..560e0e9c8f 100644
--- a/sysdeps/aarch64/Makefile
+++ b/sysdeps/aarch64/Makefile
@@ -68,3 +68,9 @@ endif
ifeq ($(subdir),malloc)
sysdep_malloc_debug_routines = __mtag_tag_zero_region __mtag_tag_region
endif
+
+ifeq (yes,$(aarch64-purecap))
+ifeq ($(subdir),stdio-common)
+tests += tst-printf-cap
+endif
+endif
diff --git a/sysdeps/aarch64/morello/tst-printf-cap.c b/sysdeps/aarch64/morello/tst-printf-cap.c
new file mode 100644
index 0000000000..4d0f58fcb5
--- /dev/null
+++ b/sysdeps/aarch64/morello/tst-printf-cap.c
@@ -0,0 +1,95 @@
+/* Check printf for capabilities functionality.
+ Copyright (C) 2022 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <support/check.h>
+#include <support/xunistd.h>
+#include <support/test-driver.h>
+
+int check_match (char *ptr, const char *pattern)
+{
+ char str[100];
+ sprintf (str, "%#p", ptr);
+ verbose_printf ("Test permission \"%s\" in \"%s\".\n", pattern, str);
+ if (!strstr(str, pattern))
+ {
+ printf ("FAIL: permission \"%s\" in \"%s\".\n", pattern, str);
+ return 1;
+ }
+ return 0;
+}
+
+int check_bounds (char *ptr, uint64_t len)
+{
+ char str[100];
+ char u_bound[100];
+ sprintf (str, "%#p", ptr);
+ sprintf (u_bound, "%p", (ptr + len));
+ verbose_printf ("Test bounds \"%s\" in \"%s\"\n", u_bound, str);
+ if (!strstr (str, u_bound))
+ {
+ printf ("FAIL: bounds \"%s\" in \"%s\"\n", u_bound, str);
+ return 1;
+ }
+ return 0;
+}
+
+static void *
+map (int prot)
+{
+ return xmmap (0, 16, prot, MAP_ANONYMOUS | MAP_PRIVATE, -1);
+}
+
+static int
+do_test (void)
+{
+ static const int x;
+ static int y;
+ void *r_global = (void *) &x;
+ void *rw_global = &y;
+ void *rx_global = (void *) do_test;
+ void *rw_malloc = malloc (16);
+ void *none_map = map (PROT_NONE);
+ void *r_map = map (PROT_READ);
+ void *rw_map = map (PROT_READ | PROT_WRITE);
+ void *rx_map = map (PROT_READ | PROT_EXEC);
+ void *rwx_map = map (PROT_READ | PROT_WRITE | PROT_EXEC);
+ int ret = 0;
+
+ /* Test permissions. */
+ ret += check_match (none_map, "[,");
+ ret += check_match (r_global, "[rR,");
+ ret += check_match (r_map, "[rR,");
+ ret += check_match (rw_global, "[rwRW,");
+ ret += check_match (rw_malloc, "[rwRW,");
+ ret += check_match (rw_map, "[rwRW,");
+ ret += check_match (rx_global, "[rxRE,");
+ ret += check_match (rx_map, "[rxRE,");
+ ret += check_match (rwx_map, "[rwxRWE,");
+
+ /* Test bounds. */
+ ret += check_bounds (rw_malloc, 16);
+
+ return ret;
+}
+
+#include <support/test-driver.c>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [glibc/arm/morello/main] cheri: stdio-common: Add test for %#p printf modifier
@ 2022-10-26 14:51 Szabolcs Nagy
0 siblings, 0 replies; 4+ messages in thread
From: Szabolcs Nagy @ 2022-10-26 14:51 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=42c99ba55f30d8e704e164675399ff16c91382b1
commit 42c99ba55f30d8e704e164675399ff16c91382b1
Author: Carlos Eduardo Seo <carlos.seo@arm.com>
Date: Mon Aug 8 16:09:37 2022 -0300
cheri: stdio-common: Add test for %#p printf modifier
Testcase for printing capabilities.
Diff:
---
sysdeps/aarch64/Makefile | 6 ++
sysdeps/aarch64/morello/tst-printf-cap.c | 95 ++++++++++++++++++++++++++++++++
2 files changed, 101 insertions(+)
diff --git a/sysdeps/aarch64/Makefile b/sysdeps/aarch64/Makefile
index 9d6e16f66e..560e0e9c8f 100644
--- a/sysdeps/aarch64/Makefile
+++ b/sysdeps/aarch64/Makefile
@@ -68,3 +68,9 @@ endif
ifeq ($(subdir),malloc)
sysdep_malloc_debug_routines = __mtag_tag_zero_region __mtag_tag_region
endif
+
+ifeq (yes,$(aarch64-purecap))
+ifeq ($(subdir),stdio-common)
+tests += tst-printf-cap
+endif
+endif
diff --git a/sysdeps/aarch64/morello/tst-printf-cap.c b/sysdeps/aarch64/morello/tst-printf-cap.c
new file mode 100644
index 0000000000..4d0f58fcb5
--- /dev/null
+++ b/sysdeps/aarch64/morello/tst-printf-cap.c
@@ -0,0 +1,95 @@
+/* Check printf for capabilities functionality.
+ Copyright (C) 2022 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <support/check.h>
+#include <support/xunistd.h>
+#include <support/test-driver.h>
+
+int check_match (char *ptr, const char *pattern)
+{
+ char str[100];
+ sprintf (str, "%#p", ptr);
+ verbose_printf ("Test permission \"%s\" in \"%s\".\n", pattern, str);
+ if (!strstr(str, pattern))
+ {
+ printf ("FAIL: permission \"%s\" in \"%s\".\n", pattern, str);
+ return 1;
+ }
+ return 0;
+}
+
+int check_bounds (char *ptr, uint64_t len)
+{
+ char str[100];
+ char u_bound[100];
+ sprintf (str, "%#p", ptr);
+ sprintf (u_bound, "%p", (ptr + len));
+ verbose_printf ("Test bounds \"%s\" in \"%s\"\n", u_bound, str);
+ if (!strstr (str, u_bound))
+ {
+ printf ("FAIL: bounds \"%s\" in \"%s\"\n", u_bound, str);
+ return 1;
+ }
+ return 0;
+}
+
+static void *
+map (int prot)
+{
+ return xmmap (0, 16, prot, MAP_ANONYMOUS | MAP_PRIVATE, -1);
+}
+
+static int
+do_test (void)
+{
+ static const int x;
+ static int y;
+ void *r_global = (void *) &x;
+ void *rw_global = &y;
+ void *rx_global = (void *) do_test;
+ void *rw_malloc = malloc (16);
+ void *none_map = map (PROT_NONE);
+ void *r_map = map (PROT_READ);
+ void *rw_map = map (PROT_READ | PROT_WRITE);
+ void *rx_map = map (PROT_READ | PROT_EXEC);
+ void *rwx_map = map (PROT_READ | PROT_WRITE | PROT_EXEC);
+ int ret = 0;
+
+ /* Test permissions. */
+ ret += check_match (none_map, "[,");
+ ret += check_match (r_global, "[rR,");
+ ret += check_match (r_map, "[rR,");
+ ret += check_match (rw_global, "[rwRW,");
+ ret += check_match (rw_malloc, "[rwRW,");
+ ret += check_match (rw_map, "[rwRW,");
+ ret += check_match (rx_global, "[rxRE,");
+ ret += check_match (rx_map, "[rxRE,");
+ ret += check_match (rwx_map, "[rwxRWE,");
+
+ /* Test bounds. */
+ ret += check_bounds (rw_malloc, 16);
+
+ return ret;
+}
+
+#include <support/test-driver.c>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-11-23 14:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-26 15:21 [glibc/arm/morello/main] cheri: stdio-common: Add test for %#p printf modifier Szabolcs Nagy
-- strict thread matches above, loose matches on Subject: below --
2022-11-23 14:49 Szabolcs Nagy
2022-10-27 13:59 Szabolcs Nagy
2022-10-26 14:51 Szabolcs Nagy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).