This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/2] jmpbuf: Add paddings for target specific usage


On 11/14/2017 12:22 AM, H.J. Lu wrote:
diff --git a/setjmp/tst-sigsetjmp2.c b/setjmp/tst-sigsetjmp2.c
new file mode 100644
index 0000000000..131531feb0
--- /dev/null
+++ b/setjmp/tst-sigsetjmp2.c
@@ -0,0 +1,50 @@
+/* Test that sigprocmask does not read from the unused part of jmpbuf.
+   Copyright (C) 2017 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
+<http://www.gnu.org/licenses/>.  */
+
+#include <stdlib.h>
+#include <signal.h>
+#include <setjmp.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <jmp_buf-macros.h>
+#include <support/next_to_fault.h>
+
+static int
+do_test (void)
+{
+  struct support_next_to_fault jmpbuf
+    = support_next_to_fault_allocate (SAVED_MASK_OFFSET + (_NSIG / 8));
+  struct __jmp_buf_tag *sj = (struct __jmp_buf_tag *) jmpbuf.buffer;
+
+  errno = 0;
+  if (sigsetjmp (sj, 1) == 0)
+    {
+      siglongjmp (sj, 1);
+      return EXIT_FAILURE;
+    }
+  if (errno != 0)
+    {
+      printf ("sigsetjmp: %s\n", strerror (errno));
+      return EXIT_FAILURE;
+    }
+  return EXIT_SUCCESS;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"

Please use <support/test-driver.c>.

Wouldn't the test start to fail if sigsetjmp/siglongjmp actually started using the padding you are freeing up for use?

I think you need test sigprocmask directly to ensure it has the desired property of not clobbering the padding.

Thanks,
Florian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]