Skip to contentSkip to conversation

elfutils: Fix gcc compile time alignment errors

PATCH In review Khem Raj 2 participants 4 messages Mar 23, 2018

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/3 elfutils: Fix gcc compile time alignment errors

Allow devtool to organize the SRC_URI

---
 meta/recipes-devtools/elfutils/elfutils_0.170.bb   |  40 +++---
 ...-packed-structs-follow-the-gcc-memory-lay.patch |  34 +++++
 ...de-alternatives-for-glibc-assumptions-hel.patch | 144 ++++++++++-----------
 3 files changed, 124 insertions(+), 94 deletions(-)
 create mode 100644 meta/recipes-devtools/elfutils/files/0001-Ensure-that-packed-structs-follow-the-gcc-memory-lay.patch
meta/recipes-devtools/elfutils/elfutils_0.170.bb +19 -21
index 9242aea26b..54d341d190 100644
@@ -5,35 +5,33 @@ LICENSE = "(GPLv3 & Elfutils-Exception)"
 LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504"
 DEPENDS = "libtool bzip2 zlib virtual/libintl"
 DEPENDS_append_libc-musl = " argp-standalone fts "
-SRC_URI = "https://sourceware.org/elfutils/ftp/${PV}/${BP}.tar.bz2"
+SRC_URI = "https://sourceware.org/elfutils/ftp/${PV}/${BP}.tar.bz2 \
+           file://0001-dso-link-change.patch \
+           file://0002-Fix-elf_cvt_gunhash-if-dest-and-src-are-same.patch \
+           file://0003-fixheadercheck.patch \
+           file://0004-Disable-the-test-to-convert-euc-jp.patch \
+           file://0005-fix-a-stack-usage-warning.patch \
+           file://0006-Fix-build-on-aarch64-musl.patch \
+           file://0007-Fix-control-path-where-we-have-str-as-uninitialized-.patch \
+           file://0001-libasm-may-link-with-libbz2-if-found.patch \
+           file://debian/hppa_backend.diff \
+           file://debian/arm_backend.diff \
+           file://debian/mips_backend.patch \
+           file://debian/mips_readelf_w.patch \
+           file://debian/0001-Ignore-differences-between-mips-machine-identifiers.patch \
+           file://debian/0002-Add-support-for-mips64-abis-in-mips_retval.c.patch \
+           file://debian/0003-Add-mips-n64-relocation-format-hack.patch \
+           file://0001-Use-fallthrough-attribute.patch \
+           file://0001-Ensure-that-packed-structs-follow-the-gcc-memory-lay.patch \
+           "
 SRC_URI[md5sum] = "03599aee98c9b726c7a732a2dd0245d5"
 SRC_URI[sha256sum] = "1f844775576b79bdc9f9c717a50058d08620323c1e935458223a12f249c9e066"
 
-SRC_URI += "\
-        file://0001-dso-link-change.patch \
-        file://0002-Fix-elf_cvt_gunhash-if-dest-and-src-are-same.patch \
-        file://0003-fixheadercheck.patch \
-        file://0004-Disable-the-test-to-convert-euc-jp.patch \
-        file://0005-fix-a-stack-usage-warning.patch \
-        file://0006-Fix-build-on-aarch64-musl.patch \
-        file://0007-Fix-control-path-where-we-have-str-as-uninitialized-.patch \
-        file://0001-libasm-may-link-with-libbz2-if-found.patch \
-"
 SRC_URI_append_libc-musl = " file://0008-build-Provide-alternatives-for-glibc-assumptions-hel.patch"
 
 # Pick patches from debian
 # http://ftp.de.debian.org/debian/pool/main/e/elfutils/elfutils_0.168-0.2.debian.tar.xz
-SRC_URI += "\
-        file://debian/hppa_backend.diff \
-        file://debian/arm_backend.diff \
-        file://debian/mips_backend.patch \
-        file://debian/mips_readelf_w.patch \
-        file://debian/0001-Ignore-differences-between-mips-machine-identifiers.patch \
-        file://debian/0002-Add-support-for-mips64-abis-in-mips_retval.c.patch \
-        file://debian/0003-Add-mips-n64-relocation-format-hack.patch \
-"
 # Fix fallthrough with GCC7
-SRC_URI += "file://0001-Use-fallthrough-attribute.patch"
 
 # The buildsystem wants to generate 2 .h files from source using a binary it just built,
 # which can not pass the cross compiling, so let's work around it by adding 2 .h files
meta/recipes-devtools/elfutils/files/0001-Ensure-that-packed-structs-follow-the-gcc-memory-lay.patch new file +34 -0
new file mode 100644
index 0000000000..cf4d1dfe75
@@ -0,0 +1,34 @@
+From 732913a8c35c7b25c0cbf6903cab1ad6b602b525 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Thu, 22 Mar 2018 22:44:03 -0700
+Subject: [PATCH] Ensure that packed structs follow the gcc memory layout
+
+Partial backport of
+https://sourceware.org/git/?p=elfutils.git;a=commit;h=17d7194d291bf91d130b78e06cbe27b290e0376d
+
+Helps fixing alignment errors e.g.
+linux-core-note.c:116:1: error: alignment 2 of 'struct m68k_prstatus
+' is less than 4 [-Werror=packed-not-aligned]
+ ;
+ ^
+
+Upstream-Status: Backport [https://sourceware.org/git/?p=elfutils.git;a=commit;h=17d7194d291bf91d130b78e06cbe27b290e0376d]
+
+Signed-off-by: Khem Raj <[email protected]>
+---
+ backends/linux-core-note.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/backends/linux-core-note.c b/backends/linux-core-note.c
+index 5f06c896..9faae4c3 100644
+--- a/backends/linux-core-note.c
++++ b/backends/linux-core-note.c
+@@ -111,7 +111,7 @@ struct EBLHOOK(prstatus)
+   FIELD (INT, pr_fpvalid);
+ }
+ #ifdef ALIGN_PRSTATUS
+-  __attribute__ ((packed, aligned (ALIGN_PRSTATUS)))
++  attribute_packed __attribute__ ((aligned (ALIGN_PRSTATUS)))
+ #endif
+ ;
+ 
meta/recipes-devtools/elfutils/files/0008-build-Provide-alternatives-for-glibc-assumptions-hel.patch +71 -73

570 lines not on this page · raw message

Signature · 1 line
2.16.2
author
#1 lore raw

PATCH 2/3 glibc: Replace strncpy with memccpy to fix -Wstringop-truncation.

---
 ...ncpy-with-memccpy-to-fix-Wstringop-trunca.patch | 39 ++++++++++++++++++++++
 meta/recipes-core/glibc/glibc_2.27.bb              |  1 +
 2 files changed, 40 insertions(+)
 create mode 100644 meta/recipes-core/glibc/glibc/0029-Replace-strncpy-with-memccpy-to-fix-Wstringop-trunca.patch
meta/recipes-core/glibc/glibc/0029-Replace-strncpy-with-memccpy-to-fix-Wstringop-trunca.patch new file +39 -0
new file mode 100644
index 0000000000..d65a293748
@@ -0,0 +1,39 @@
+From 113e0516fbd3ce18253f0423762416d4c4b38fb0 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Thu, 22 Mar 2018 17:57:37 -0700
+Subject: [PATCH 29/29] Replace strncpy with memccpy to fix
+ -Wstringop-truncation.
+
+	* nis/nss_nisplus/nisplus-parser.c: Replace strncpy with memcpy to
+	avoid -Wstringop-truncation.
+---
+Upstream-Status: Submitted [https://sourceware.org/ml/libc-alpha/2018-03/msg00531.html]
+
+ nis/nss_nisplus/nisplus-parser.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/nis/nss_nisplus/nisplus-parser.c b/nis/nss_nisplus/nisplus-parser.c
+index 8dc021e73d..b53284f889 100644
+--- a/nis/nss_nisplus/nisplus-parser.c
++++ b/nis/nss_nisplus/nisplus-parser.c
+@@ -87,7 +87,7 @@ _nss_nisplus_parse_pwent (nis_result *result, struct passwd *pw,
+       if (len >= room_left)
+ 	goto no_more_room;
+ 
+-      strncpy (first_unused, numstr, len);
++      memcpy (first_unused, numstr, len);
+       first_unused[len] = '\0';
+       numstr = first_unused;
+     }
+@@ -103,7 +103,7 @@ _nss_nisplus_parse_pwent (nis_result *result, struct passwd *pw,
+       if (len >= room_left)
+ 	goto no_more_room;
+ 
+-      strncpy (first_unused, numstr, len);
++      memcpy (first_unused, numstr, len);
+       first_unused[len] = '\0';
+       numstr = first_unused;
+     }
+-- 
+2.16.2
+
meta/recipes-core/glibc/glibc_2.27.bb +1 -0
index 4f6f58ccb1..4a461ab283 100644
@@ -43,6 +43,7 @@ SRC_URI = "${GLIBC_GIT_URI};branch=${SRCBRANCH};name=glibc \
            file://0026-reset-dl_load_write_lock-after-forking.patch \
            file://0027-Acquire-ld.so-lock-before-switching-to-malloc_atfork.patch \
            file://0028-bits-siginfo-consts.h-enum-definition-for-TRAP_HWBKP.patch \
+           file://0029-Replace-strncpy-with-memccpy-to-fix-Wstringop-trunca.patch \
 "
 
 NATIVESDKFIXES ?= ""
Signature · 1 line
2.16.2
author
#2 lore raw

PATCH 3/3 nss: Use snprintf in sign.c

In reply to Khem Raj

Fies security warnings
| sign.c:86:31: error: 'sprintf' may write a terminating nul past the end of the destination [-Werror=format-overflow=]
| sprintf(fullfn, "%s/%s", tree, tempfn);

---
 ...1437734-Use-snprintf-in-sign.c-r-ttaubert.patch | 119 +++++++++++++++++++++
 meta/recipes-support/nss/nss_3.34.1.bb             |   1 +
 2 files changed, 120 insertions(+)
 create mode 100644 meta/recipes-support/nss/nss/0001-Bug-1437734-Use-snprintf-in-sign.c-r-ttaubert.patch
meta/recipes-support/nss/nss/0001-Bug-1437734-Use-snprintf-in-sign.c-r-ttaubert.patch new file +119 -0
new file mode 100644
index 0000000000..bc10f3385d
@@ -0,0 +1,119 @@
+From 6f7d7be9997ba6727a5ad7c3800df9051160dc12 Mon Sep 17 00:00:00 2001
+From: Martin Thomson <[email protected]>
+Date: Tue, 13 Feb 2018 12:30:58 +1100
+Subject: [PATCH] Bug 1437734 - Use snprintf in sign.c, r=ttaubert
+
+--HG--
+extra : rebase_source : 97921ece71ff86b18d32b891591608290eed4d83
+---
+Signed-off-by: Khem Raj <[email protected]>
+Upstream-Status: Backport [https://github.com/nss-dev/nss/commit/0a9078b3cde97add7c825c9d13467a8401ad0c88#diff-b42512151dc137537091f823f7701804.patch]
+
+ nss/cmd/signtool/sign.c | 58 ++++++++++++++++++++++++++++++++++++++++---------
+ 1 file changed, 48 insertions(+), 10 deletions(-)
+
+diff --git a/nss/cmd/signtool/sign.c b/nss/cmd/signtool/sign.c
+index 6e776069a..6f8e43946 100644
+--- a/nss/cmd/signtool/sign.c
++++ b/nss/cmd/signtool/sign.c
+@@ -43,6 +43,7 @@ SignArchive(char *tree, char *keyName, char *zip_file, int javascript,
+     int status;
+     char tempfn[FNSIZE], fullfn[FNSIZE];
+     int keyType = rsaKey;
++    int count;
+ 
+     metafile = meta_file;
+     optimize = _optimize;
+@@ -81,9 +82,18 @@ SignArchive(char *tree, char *keyName, char *zip_file, int javascript,
+         }
+ 
+         /* rsa/dsa to zip */
+-        sprintf(tempfn, "META-INF/%s.%s", base, (keyType == dsaKey ? "dsa"
+-                                                                   : "rsa"));
+-        sprintf(fullfn, "%s/%s", tree, tempfn);
++        count = snprintf(tempfn, sizeof(tempfn), "META-INF/%s.%s", base, (keyType == dsaKey ? "dsa" : "rsa"));
++        if (count >= sizeof(tempfn)) {
++            PR_fprintf(errorFD, "unable to write key metadata\n");
++            errorCount++;
++            exit(ERRX);
++        }
++        count = snprintf(fullfn, sizeof(fullfn), "%s/%s", tree, tempfn);
++        if (count >= sizeof(fullfn)) {
++            PR_fprintf(errorFD, "unable to write key metadata\n");
++            errorCount++;
++            exit(ERRX);
++        }
+         JzipAdd(fullfn, tempfn, zipfile, compression_level);
+ 
+         /* Loop through all files & subdirectories, add to archive */
+@@ -93,20 +103,44 @@ SignArchive(char *tree, char *keyName, char *zip_file, int javascript,
+     }
+     /* mf to zip */
+     strcpy(tempfn, "META-INF/manifest.mf");
+-    sprintf(fullfn, "%s/%s", tree, tempfn);
++    count = snprintf(fullfn, sizeof(fullfn), "%s/%s", tree, tempfn);
++    if (count >= sizeof(fullfn)) {
++        PR_fprintf(errorFD, "unable to write manifest\n");
++        errorCount++;
++        exit(ERRX);
++    }
+     JzipAdd(fullfn, tempfn, zipfile, compression_level);
+ 
+     /* sf to zip */
+-    sprintf(tempfn, "META-INF/%s.sf", base);
+-    sprintf(fullfn, "%s/%s", tree, tempfn);
++    count = snprintf(tempfn, sizeof(tempfn), "META-INF/%s.sf", base);
++    if (count >= sizeof(tempfn)) {
++        PR_fprintf(errorFD, "unable to write sf metadata\n");
++        errorCount++;
++        exit(ERRX);
++    }
++    count = snprintf(fullfn, sizeof(fullfn), "%s/%s", tree, tempfn);
++    if (count >= sizeof(fullfn)) {
++        PR_fprintf(errorFD, "unable to write sf metadata\n");
++        errorCount++;
++        exit(ERRX);
++    }
+     JzipAdd(fullfn, tempfn, zipfile, compression_level);
+ 
+     /* Add the rsa/dsa file to the zip archive normally */
+     if (!xpi_arc) {
+         /* rsa/dsa to zip */
+-        sprintf(tempfn, "META-INF/%s.%s", base, (keyType == dsaKey ? "dsa"
+-                                                                   : "rsa"));
+-        sprintf(fullfn, "%s/%s", tree, tempfn);
++        count = snprintf(tempfn, sizeof(tempfn), "META-INF/%s.%s", base, (keyType == dsaKey ? "dsa" : "rsa"));
++        if (count >= sizeof(tempfn)) {
++            PR_fprintf(errorFD, "unable to write key metadata\n");
++            errorCount++;
++            exit(ERRX);
++        }
++        count = snprintf(fullfn, sizeof(fullfn), "%s/%s", tree, tempfn);
++        if (count >= sizeof(fullfn)) {
++            PR_fprintf(errorFD, "unable to write key metadata\n");
++            errorCount++;
++            exit(ERRX);
++        }
+         JzipAdd(fullfn, tempfn, zipfile, compression_level);
+     }
+ 
+@@ -408,6 +442,7 @@ static int
+ manifesto_xpi_fn(char *relpath, char *basedir, char *reldir, char *filename, void *arg)
+ {
+     char fullname[FNSIZE];
++    int count;
+ 
+     if (verbosity >= 0) {
+         PR_fprintf(outputFD, "--> %s\n", relpath);
+@@ -421,7 +456,10 @@ manifesto_xpi_fn(char *relpath, char *basedir, char *reldir, char *filename, voi
+         if (!PL_HashTableLookup(extensions, ext))
+             return 0;
+     }
+-    sprintf(fullname, "%s/%s", basedir, relpath);
++    count = snprintf(fullname, sizeof(fullname), "%s/%s", basedir, relpath);
++    if (count >= sizeof(fullname)) {
++        return 1;
++    }
+     JzipAdd(fullname, relpath, zipfile, compression_level);
+ 
+     return 0;
meta/recipes-support/nss/nss_3.34.1.bb +1 -0
index ae52a95a30..1af68acfb3 100644
@@ -26,6 +26,7 @@ SRC_URI = "http://ftp.mozilla.org/pub/mozilla.org/security/nss/releases/${VERSIO
            file://disable-Wvarargs-with-clang.patch \
            file://pqg.c-ULL_addend.patch \
            file://Fix-compilation-for-X32.patch \
+           file://0001-Bug-1437734-Use-snprintf-in-sign.c-r-ttaubert.patch \
            "
 
 SRC_URI[md5sum] = "5922468bb1c54e4c8067f153fcf467e5"
Signature · 1 line
2.16.2
#3 lore raw

✗ patchtest: failure for "elfutils: Fix gcc compile time..." and 2 more

In reply to Khem Raj

== Series Details ==

Series: "elfutils: Fix gcc compile time..." and 2 more
Revision: 1
URL : https://patchwork.openembedded.org/series/11549/
State : failure

== Summary ==

Thank you for submitting this patch series to OpenEmbedded Core. This is an automated response. Several tests have been executed on the proposed series by patchtest resulting in the following failures:

* Issue A patch file has been added, but does not have a Signed-off-by tag [test_signed_off_by_presence]
Suggested fix Sign off the added patch file (meta/recipes-core/glibc/glibc/0029-Replace-strncpy-with-memccpy-to-fix-Wstringop-trunca.patch)

If you believe any of these test results are incorrect, please reply to the mailing list ([email protected]) raising your concerns. Otherwise we would appreciate you correcting the issues and submitting a new version of the patchset if applicable. Please ensure you add/increment the version number when sending the new version (i.e. [PATCH] -> [PATCH v2] -> [PATCH v3] -> ...).

---

Guidelines:     https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines
Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest
Test suite:     http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe