From dba4138305c5cd28e33775d6d4059a1c5fe2292d Mon Sep 17 00:00:00 2001 From: "Adam C. Foltzer" Date: Wed, 26 Jun 2019 15:51:08 -0700 Subject: [PATCH 1/5] remove newer `__ssp` field from `ucontext_t` for earlier glib compat Per discussion in #1410, this is necessary to avoid struct size mismatches between Rust and C on systems with glibc < 2.28. --- libc-test/build.rs | 5 ++++- src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 06386f81d2661..dc4fcc7344fdf 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1950,7 +1950,6 @@ fn test_linux(target: &str) { "syslog.h", "termios.h", "time.h", - "ucontext.h", "unistd.h", "utime.h", "utmp.h", @@ -1968,6 +1967,10 @@ fn test_linux(target: &str) { // is not supported by musl: // https://www.openwall.com/lists/musl/2015/04/09/3 [!musl]: "execinfo.h", + // ucontext_t added a new field as of glibc 2.28; our struct definition is + // conservative and omits the field, but that means the size doesn't match for newer + // glibcs + [!gnu]: "ucontext.h", } // Include linux headers at the end: diff --git a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs index 1318713a424b6..10d74e41252d2 100644 --- a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs @@ -285,7 +285,6 @@ s_no_extra_traits! { pub uc_mcontext: mcontext_t, pub uc_sigmask: ::sigset_t, __private: [u8; 512], - __ssp: [::c_ulonglong; 4], } } From 886bb3f2f863459b0651b6a22c9e57d4ac6dce61 Mon Sep 17 00:00:00 2001 From: "Adam C. Foltzer" Date: Wed, 26 Jun 2019 16:56:53 -0700 Subject: [PATCH 2/5] filter out the struct test rather than removing the header --- libc-test/build.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index dc4fcc7344fdf..55f823187d56d 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1950,6 +1950,7 @@ fn test_linux(target: &str) { "syslog.h", "termios.h", "time.h", + "ucontext.h", "unistd.h", "utime.h", "utmp.h", @@ -1967,10 +1968,6 @@ fn test_linux(target: &str) { // is not supported by musl: // https://www.openwall.com/lists/musl/2015/04/09/3 [!musl]: "execinfo.h", - // ucontext_t added a new field as of glibc 2.28; our struct definition is - // conservative and omits the field, but that means the size doesn't match for newer - // glibcs - [!gnu]: "ucontext.h", } // Include linux headers at the end: @@ -2101,6 +2098,11 @@ fn test_linux(target: &str) { // FIXME: musl version using by mips build jobs 1.0.15 is ancient: "ifmap" | "ifreq" | "ifconf" if mips32_musl => true, + // ucontext_t added a new field as of glibc 2.28; our struct definition is + // conservative and omits the field, but that means the size doesn't match for newer + // glibcs (see https://github.com/rust-lang/libc/issues/1410) + "ucontext_t" if gnu => true, + _ => false, } }); From 339fe2265392a1c2bad861043c79c42d29867331 Mon Sep 17 00:00:00 2001 From: "Adam C. Foltzer" Date: Thu, 27 Jun 2019 09:32:52 -0700 Subject: [PATCH 3/5] add fixmes for the ucontext_t shadow stack field --- libc-test/build.rs | 1 + src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs | 3 +++ 2 files changed, 4 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 55f823187d56d..722a513c32fea 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2098,6 +2098,7 @@ fn test_linux(target: &str) { // FIXME: musl version using by mips build jobs 1.0.15 is ancient: "ifmap" | "ifreq" | "ifconf" if mips32_musl => true, + // FIXME: remove once Ubuntu 20.04 LTS is released, somewhere in 2020. // ucontext_t added a new field as of glibc 2.28; our struct definition is // conservative and omits the field, but that means the size doesn't match for newer // glibcs (see https://github.com/rust-lang/libc/issues/1410) diff --git a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs index 10d74e41252d2..ad66123c84fe8 100644 --- a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs @@ -285,6 +285,9 @@ s_no_extra_traits! { pub uc_mcontext: mcontext_t, pub uc_sigmask: ::sigset_t, __private: [u8; 512], + // FIXME: the shadow stack field requires glibc >= 2.28. + // Re-add once we drop compatibility with glibc versions older than 2.28. + // __ssp: [::c_ulonglong; 4], } } From e94fffc3099f85dcece9f77cac9275d80bc70e2f Mon Sep 17 00:00:00 2001 From: "Adam C. Foltzer" Date: Thu, 27 Jun 2019 10:57:07 -0700 Subject: [PATCH 4/5] replace deprecated string functions in style script --- ci/style.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/style.rs b/ci/style.rs index 481f57f74d0bc..70fc0a0814377 100644 --- a/ci/style.rs +++ b/ci/style.rs @@ -117,7 +117,7 @@ fn check_style(file: &str, path: &Path, err: &mut Errors) { } else { prev_blank = false; } - if line != line.trim_right() { + if line != line.trim_end() { err.error(path, i, "trailing whitespace"); } if line.contains("\t") { @@ -139,7 +139,7 @@ fn check_style(file: &str, path: &Path, err: &mut Errors) { } } - let line = line.trim_left(); + let line = line.trim_start(); let is_pub = line.starts_with("pub "); let line = if is_pub {&line[4..]} else {line}; From f6e48fc77c87fa51027e1bf6eb6ff2dc2f4845af Mon Sep 17 00:00:00 2001 From: "Adam C. Foltzer" Date: Thu, 27 Jun 2019 11:42:22 -0700 Subject: [PATCH 5/5] fix line length --- src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs index ad66123c84fe8..f3b10084fdecd 100644 --- a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs @@ -286,7 +286,9 @@ s_no_extra_traits! { pub uc_sigmask: ::sigset_t, __private: [u8; 512], // FIXME: the shadow stack field requires glibc >= 2.28. - // Re-add once we drop compatibility with glibc versions older than 2.28. + // Re-add once we drop compatibility with glibc versions older than + // 2.28. + // // __ssp: [::c_ulonglong; 4], } }