Skip to content

Commit 7ddf2fd

Browse files
committed
Patches for
- sigstksz: stop making SIGSTKSZ an integer constant - posix-io: Use glibc's closefrom. Since 2.34 glibc - disable raw header
1 parent 22c0a62 commit 7ddf2fd

5 files changed

Lines changed: 128 additions & 1 deletion

File tree

meta/recipes-core/util-linux/util-linux_2.36.2.bb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,3 +330,6 @@ do_install_ptest() {
330330
sed -i 's|@base_sbindir@|${base_sbindir}|g' ${D}${PTEST_PATH}/run-ptest
331331

332332
}
333+
334+
EXTRA_OECONF_append = " --disable-raw"
335+

meta/recipes-devtools/m4/m4-1.4.18.inc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ inherit autotools texinfo ptest
99
SRC_URI = "${GNU_MIRROR}/m4/m4-${PV}.tar.gz \
1010
file://ac_config_links.patch \
1111
file://m4-1.4.18-glibc-change-work-around.patch \
12-
"
12+
file://04-fix-sigstksz.patch \
13+
"
1314
SRC_URI_append_class-target = " file://0001-Unset-need_charset_alias-when-building-for-musl.patch \
1415
file://run-ptest \
1516
file://serial-tests-config.patch \
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
From f9e2b20a12a230efa30f1d479563ae07d276a94b Mon Sep 17 00:00:00 2001
2+
From: Paul Eggert <eggert@cs.ucla.edu>
3+
Date: Wed, 30 Sep 2020 13:50:36 -0700
4+
Subject: [PATCH] c-stack: stop using SIGSTKSZ
5+
MIME-Version: 1.0
6+
Content-Type: text/plain; charset=utf8
7+
Content-Transfer-Encoding: 8bit
8+
9+
It's been proposed to stop making SIGSTKSZ an integer constant:
10+
https://sourceware.org/pipermail/libc-alpha/2020-September/118028.html
11+
Also, using SIGSTKSZ in #if did not conform to current POSIX.
12+
Also, avoiding SIGSTKSZ makes the code simpler and easier to grok.
13+
* lib/c-stack.c (SIGSTKSZ): Remove.
14+
(alternate_signal_stack): Now a 64 KiB array, for simplicity.
15+
All uses changed.
16+
17+
(Note for Ubuntu: The patch originates from gnulib, not m4, and has been
18+
heavily edited to fit the older version used in our current version of m4)
19+
20+
--- a/lib/c-stack.c
21+
+++ b/lib/c-stack.c
22+
@@ -50,15 +50,16 @@
23+
#if ! HAVE_STACK_T && ! defined stack_t
24+
typedef struct sigaltstack stack_t;
25+
#endif
26+
-#ifndef SIGSTKSZ
27+
-# define SIGSTKSZ 16384
28+
-#elif HAVE_LIBSIGSEGV && SIGSTKSZ < 16384
29+
-/* libsigsegv 2.6 through 2.8 have a bug where some architectures use
30+
- more than the Linux default of an 8k alternate stack when deciding
31+
- if a fault was caused by stack overflow. */
32+
-# undef SIGSTKSZ
33+
-# define SIGSTKSZ 16384
34+
-#endif
35+
+/* Storage for the alternate signal stack.
36+
+ 64 KiB is not too large for Gnulib-using apps, and is large enough
37+
+ for all known platforms. Smaller sizes may run into trouble.
38+
+ For example, libsigsegv 2.6 through 2.8 have a bug where some
39+
+ architectures use more than the Linux default of an 8 KiB alternate
40+
+ stack when deciding if a fault was caused by stack overflow. */
41+
+static max_align_t alternate_signal_stack[(64 * 1024
42+
+ + sizeof (max_align_t) - 1)
43+
+ / sizeof (max_align_t)];
44+
+
45+
46+
#include <stdlib.h>
47+
#include <string.h>
48+
@@ -128,18 +129,6 @@
49+
#if (HAVE_SIGALTSTACK && HAVE_DECL_SIGALTSTACK \
50+
&& HAVE_STACK_OVERFLOW_HANDLING) || HAVE_LIBSIGSEGV
51+
52+
-/* Storage for the alternate signal stack. */
53+
-static union
54+
-{
55+
- char buffer[SIGSTKSZ];
56+
-
57+
- /* These other members are for proper alignment. There's no
58+
- standard way to guarantee stack alignment, but this seems enough
59+
- in practice. */
60+
- long double ld;
61+
- long l;
62+
- void *p;
63+
-} alternate_signal_stack;
64+
65+
static void
66+
null_action (int signo __attribute__ ((unused)))
67+
@@ -205,8 +194,8 @@
68+
69+
/* Always install the overflow handler. */
70+
if (stackoverflow_install_handler (overflow_handler,
71+
- alternate_signal_stack.buffer,
72+
- sizeof alternate_signal_stack.buffer))
73+
+ alternate_signal_stack,
74+
+ sizeof alternate_signal_stack))
75+
{
76+
errno = ENOTSUP;
77+
return -1;
78+
@@ -279,14 +268,14 @@
79+
stack_t st;
80+
struct sigaction act;
81+
st.ss_flags = 0;
82+
+ st.ss_sp = alternate_signal_stack;
83+
+ st.ss_size = sizeof alternate_signal_stack;
84+
# if SIGALTSTACK_SS_REVERSED
85+
/* Irix mistakenly treats ss_sp as the upper bound, rather than
86+
lower bound, of the alternate stack. */
87+
- st.ss_sp = alternate_signal_stack.buffer + SIGSTKSZ - sizeof (void *);
88+
- st.ss_size = sizeof alternate_signal_stack.buffer - sizeof (void *);
89+
-# else
90+
- st.ss_sp = alternate_signal_stack.buffer;
91+
- st.ss_size = sizeof alternate_signal_stack.buffer;
92+
+ st.ss_size -= sizeof (void *);
93+
+ char *ss_sp = st.ss_sp;
94+
+ st.ss_sp = ss_sp + st.ss_size;
95+
# endif
96+
r = sigaltstack (&st, NULL);
97+
if (r != 0)
98+
--- a/lib/c-stack.h
99+
+++ b/lib/c-stack.h
100+
@@ -34,7 +34,7 @@
101+
A null ACTION acts like an action that does nothing.
102+
103+
ACTION must be async-signal-safe. ACTION together with its callees
104+
- must not require more than SIGSTKSZ bytes of stack space. Also,
105+
+ must not require more than 64 KiB of stack space. Also,
106+
ACTION should not call longjmp, because this implementation does
107+
not guarantee that it is safe to return to the original stack.
108+
109+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--- a/src/posix-io.c
2+
+++ b/src/posix-io.c
3+
@@ -570,7 +570,7 @@ _gpgme_io_spawn (const char *path, char *const argv[], unsigned int flags,
4+
if (fd_list[i].fd > fd)
5+
fd = fd_list[i].fd;
6+
fd++;
7+
-#if defined(__sun) || defined(__FreeBSD__)
8+
+#if defined(__sun) || defined(__FreeBSD__) || defined(__GLIBC__)
9+
closefrom (fd);
10+
max_fds = fd;
11+
#else /*!__sun */
12+
13+

meta/recipes-support/gpgme/gpgme_1.15.1.bb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ SRC_URI = "${GNUPG_MIRROR}/gpgme/${BP}.tar.bz2 \
2020
file://0006-fix-build-path-issue.patch \
2121
file://0007-python-Add-variables-to-tests.patch \
2222
file://0008-do-not-auto-check-var-PYTHON.patch \
23+
file://0009-fix-posix-io.patch \
2324
"
2425

2526
SRC_URI[sha256sum] = "eebc3c1b27f1c8979896ff361ba9bb4778b508b2496c2fc10e3775a40b1de1ad"

0 commit comments

Comments
 (0)