From patchwork Thu Dec 22 16:17:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Koen Vandeputte X-Patchwork-Id: 708292 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tkxZw6Yb6z9t1F for ; Fri, 23 Dec 2016 03:20:40 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ncentric.com header.i=@ncentric.com header.b="ZaHTJ2n7"; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cK64h-00073J-1I; Thu, 22 Dec 2016 16:18:35 +0000 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cK644-0006Vi-K5 for lede-dev@lists.infradead.org; Thu, 22 Dec 2016 16:18:07 +0000 Received: by mail-wm0-x22d.google.com with SMTP id a197so179655714wmd.0 for ; Thu, 22 Dec 2016 08:17:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ncentric.com; s=google; h=from:to:cc:subject:date:message-id; bh=xtQQIGTTSVKFQMQcL6XkQmeN3jnlD7EupFhhsVUpho8=; b=ZaHTJ2n7WbrpRW6orMNSGlo7MmhIVDmQpdZAPnQFBfvfBcU9ohmsmFHkVqegDIJaYI S/45Mzed4c9VQezh47wM7ewviXhaK+a37/VoentRBKEYzOP5sxuU+ZqSpyhN07rehzfW BCPDtjKPK0C3N1Q7/EVvacfJWkeAkSKeBF6pQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=xtQQIGTTSVKFQMQcL6XkQmeN3jnlD7EupFhhsVUpho8=; b=b4F34r2HQCahCpkHxNWLDwfQakYTUmn5MMk4jCTKa6F/hAsTIh9USH83Di34HGz3k4 CJMX9r1iiMu1BBQg5lqkY4TUA7NXaLCWdUGYv6ysHn/HjkOr55XITOcJGqQiadfWB4Uc tgS49x7inB61CwM06pIDiHH32PplPqBRwK+hXNGRy3xoWajOGDeNwAcKHXthpVdMPzY1 B1CrBvXxVtxsJl7Sr/jBtWv0v2+gdF69ocCsjiwAn6+a2K6w0v4dlcdeG3rLQ41jYFKI RTKWX+Y6pKIJBrCXnJGl+89mh2guUNHPjXCLMDcOfcZDTOzNiV85t0lVLhdnMLq5WmMO bnig== X-Gm-Message-State: AIkVDXKGsrlEst1qPKyUMaXFSjm0nLXMbE/kum32XzyAgFQvo+JMi4ORjJWi6ZPNjIcfisxq X-Received: by 10.28.191.219 with SMTP id o88mr3174761wmi.30.1482423454147; Thu, 22 Dec 2016 08:17:34 -0800 (PST) Received: from localhost.localdomain (d515300d8.static.telenet.be. [81.83.0.216]) by smtp.googlemail.com with ESMTPSA id l67sm31700298wmf.0.2016.12.22.08.17.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Dec 2016 08:17:33 -0800 (PST) From: Koen Vandeputte To: lede-dev@lists.infradead.org Date: Thu, 22 Dec 2016 17:17:03 +0100 Message-Id: <1482423425-29260-1-git-send-email-koen.vandeputte@ncentric.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161222_081757_303109_8A3CD06A X-CRM114-Status: GOOD ( 17.18 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:22d listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid Subject: [LEDE-DEV] [PATCH v2 1/3] musl: rename a custom backport patch X-BeenThere: lede-dev@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: chunkeey@googlemail.com, hauke@hauke-m.de, nbd@nbd.name, Koen Vandeputte , john@phrozen.org MIME-Version: 1.0 Sender: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Ensure there is room in the numbering for next patches Signed-off-by: Koen Vandeputte --- ...t-attribute-to-some-function-declarations.patch | 197 --------------------- ...t-attribute-to-some-function-declarations.patch | 197 +++++++++++++++++++++ 2 files changed, 197 insertions(+), 197 deletions(-) delete mode 100644 toolchain/musl/patches/040-Add-format-attribute-to-some-function-declarations.patch create mode 100644 toolchain/musl/patches/099-Add-format-attribute-to-some-function-declarations.patch diff --git a/toolchain/musl/patches/040-Add-format-attribute-to-some-function-declarations.patch b/toolchain/musl/patches/040-Add-format-attribute-to-some-function-declarations.patch deleted file mode 100644 index c495d67..0000000 --- a/toolchain/musl/patches/040-Add-format-attribute-to-some-function-declarations.patch +++ /dev/null @@ -1,197 +0,0 @@ -From e6683d001a95d7c3d4d992496f00f77e01fcd268 Mon Sep 17 00:00:00 2001 -From: Hauke Mehrtens -Date: Sun, 22 Nov 2015 15:04:23 +0100 -Subject: [PATCH v2] Add format attribute to some function declarations - -GCC and Clang are able to check the format arguments given to a -function and warn the user if there is a error in the format arguments -or if there is a potential uncontrolled format string security problem -in the code. GCC does this automatically for some functions like -printf(), but it is also possible to annotate other functions in a way -that it will check them too. This feature is used by glibc for many -functions. This patch adds the attribute to the some functions of musl -expect for these functions where gcc automatically adds it. - -GCC automatically adds checks for these functions: printf, fprintf, -sprintf, scanf, fscanf, sscanf, strftime, vprintf, vfprintf and -vsprintf. - -The documentation from gcc is here: -https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html - -The documentation from Clang is here: -http://clang.llvm.org/docs/AttributeReference.html#format-gnu-format - -Signed-off-by: Hauke Mehrtens ---- - include/err.h | 26 +++++++++++++++++--------- - include/monetary.h | 12 ++++++++++-- - include/stdio.h | 29 ++++++++++++++++++++--------- - include/syslog.h | 12 ++++++++++-- - 4 files changed, 57 insertions(+), 22 deletions(-) - ---- a/include/err.h -+++ b/include/err.h -@@ -8,15 +8,23 @@ - extern "C" { - #endif - --void warn(const char *, ...); --void vwarn(const char *, va_list); --void warnx(const char *, ...); --void vwarnx(const char *, va_list); -+#if __GNUC__ >= 3 -+#define __fp(x, y) __attribute__ ((__format__ (__printf__, x, y))) -+#else -+#define __fp(x, y) -+#endif - --_Noreturn void err(int, const char *, ...); --_Noreturn void verr(int, const char *, va_list); --_Noreturn void errx(int, const char *, ...); --_Noreturn void verrx(int, const char *, va_list); -+void warn(const char *, ...) __fp(1, 2); -+void vwarn(const char *, va_list) __fp(1, 0); -+void warnx(const char *, ...) __fp(1, 2); -+void vwarnx(const char *, va_list) __fp(1, 0); -+ -+_Noreturn void err(int, const char *, ...) __fp(2, 3); -+_Noreturn void verr(int, const char *, va_list) __fp(2, 0); -+_Noreturn void errx(int, const char *, ...) __fp(2, 3); -+_Noreturn void verrx(int, const char *, va_list) __fp(2, 0); -+ -+#undef __fp - - #ifdef __cplusplus - } ---- a/include/monetary.h -+++ b/include/monetary.h -@@ -13,8 +13,16 @@ extern "C" { - - #include - --ssize_t strfmon(char *__restrict, size_t, const char *__restrict, ...); --ssize_t strfmon_l(char *__restrict, size_t, locale_t, const char *__restrict, ...); -+#if __GNUC__ >= 3 -+#define __fsfm(x, y) __attribute__ ((__format__ (__strfmon__, x, y))) -+#else -+#define __fsfm(x, y) -+#endif -+ -+ssize_t strfmon(char *__restrict, size_t, const char *__restrict, ...) __fsfm(3, 4); -+ssize_t strfmon_l(char *__restrict, size_t, locale_t, const char *__restrict, ...) __fsfm(4, 5); -+ -+#undef __fsfm - - #ifdef __cplusplus - } ---- a/include/stdio.h -+++ b/include/stdio.h -@@ -21,6 +21,14 @@ extern "C" { - - #include - -+#if __GNUC__ >= 3 -+#define __fp(x, y) __attribute__ ((__format__ (__printf__, x, y))) -+#define __fs(x, y) __attribute__ ((__format__ (__scanf__, x, y))) -+#else -+#define __fp(x, y) -+#define __fs(x, y) -+#endif -+ - #ifdef __cplusplus - #define NULL 0L - #else -@@ -102,19 +110,19 @@ int puts(const char *); - int printf(const char *__restrict, ...); - int fprintf(FILE *__restrict, const char *__restrict, ...); - int sprintf(char *__restrict, const char *__restrict, ...); --int snprintf(char *__restrict, size_t, const char *__restrict, ...); -+int snprintf(char *__restrict, size_t, const char *__restrict, ...) __fp(3, 4); - - int vprintf(const char *__restrict, __isoc_va_list); - int vfprintf(FILE *__restrict, const char *__restrict, __isoc_va_list); - int vsprintf(char *__restrict, const char *__restrict, __isoc_va_list); --int vsnprintf(char *__restrict, size_t, const char *__restrict, __isoc_va_list); -+int vsnprintf(char *__restrict, size_t, const char *__restrict, __isoc_va_list) __fp(3, 0); - - int scanf(const char *__restrict, ...); - int fscanf(FILE *__restrict, const char *__restrict, ...); - int sscanf(const char *__restrict, const char *__restrict, ...); --int vscanf(const char *__restrict, __isoc_va_list); --int vfscanf(FILE *__restrict, const char *__restrict, __isoc_va_list); --int vsscanf(const char *__restrict, const char *__restrict, __isoc_va_list); -+int vscanf(const char *__restrict, __isoc_va_list) __fs(1, 0); -+int vfscanf(FILE *__restrict, const char *__restrict, __isoc_va_list) __fs(2, 0); -+int vsscanf(const char *__restrict, const char *__restrict, __isoc_va_list) __fs(2, 0); - - void perror(const char *); - -@@ -135,8 +143,8 @@ int pclose(FILE *); - int fileno(FILE *); - int fseeko(FILE *, off_t, int); - off_t ftello(FILE *); --int dprintf(int, const char *__restrict, ...); --int vdprintf(int, const char *__restrict, __isoc_va_list); -+int dprintf(int, const char *__restrict, ...) __fp(2, 3); -+int vdprintf(int, const char *__restrict, __isoc_va_list) __fp(2, 0); - void flockfile(FILE *); - int ftrylockfile(FILE *); - void funlockfile(FILE *); -@@ -175,8 +183,8 @@ int fileno_unlocked(FILE *); - int getw(FILE *); - int putw(int, FILE *); - char *fgetln(FILE *, size_t *); --int asprintf(char **, const char *, ...); --int vasprintf(char **, const char *, __isoc_va_list); -+int asprintf(char **, const char *, ...) __fp(2, 3); -+int vasprintf(char **, const char *, __isoc_va_list) __fp(2, 0); - #endif - - #ifdef _GNU_SOURCE -@@ -184,6 +192,9 @@ char *fgets_unlocked(char *, int, FILE * - int fputs_unlocked(const char *, FILE *); - #endif - -+#undef __fp -+#undef __fs -+ - #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) - #define tmpfile64 tmpfile - #define fopen64 fopen ---- a/include/syslog.h -+++ b/include/syslog.h -@@ -56,16 +56,22 @@ extern "C" { - #define LOG_NOWAIT 0x10 - #define LOG_PERROR 0x20 - -+#if __GNUC__ >= 3 -+#define __fp(x, y) __attribute__ ((__format__ (__printf__, x, y))) -+#else -+#define __fp(x, y) -+#endif -+ - void closelog (void); - void openlog (const char *, int, int); - int setlogmask (int); --void syslog (int, const char *, ...); -+void syslog (int, const char *, ...) __fp(2, 3); - - #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) - #define _PATH_LOG "/dev/log" - #define __NEED_va_list - #include --void vsyslog (int, const char *, va_list); -+void vsyslog (int, const char *, va_list) __fp(2, 0); - #if defined(SYSLOG_NAMES) - #define INTERNAL_NOPRI 0x10 - #define INTERNAL_MARK (LOG_NFACILITIES<<3) -@@ -93,6 +99,8 @@ typedef struct { - #endif - #endif - -+#undef __fp -+ - #ifdef __cplusplus - } - #endif diff --git a/toolchain/musl/patches/099-Add-format-attribute-to-some-function-declarations.patch b/toolchain/musl/patches/099-Add-format-attribute-to-some-function-declarations.patch new file mode 100644 index 0000000..c495d67 --- /dev/null +++ b/toolchain/musl/patches/099-Add-format-attribute-to-some-function-declarations.patch @@ -0,0 +1,197 @@ +From e6683d001a95d7c3d4d992496f00f77e01fcd268 Mon Sep 17 00:00:00 2001 +From: Hauke Mehrtens +Date: Sun, 22 Nov 2015 15:04:23 +0100 +Subject: [PATCH v2] Add format attribute to some function declarations + +GCC and Clang are able to check the format arguments given to a +function and warn the user if there is a error in the format arguments +or if there is a potential uncontrolled format string security problem +in the code. GCC does this automatically for some functions like +printf(), but it is also possible to annotate other functions in a way +that it will check them too. This feature is used by glibc for many +functions. This patch adds the attribute to the some functions of musl +expect for these functions where gcc automatically adds it. + +GCC automatically adds checks for these functions: printf, fprintf, +sprintf, scanf, fscanf, sscanf, strftime, vprintf, vfprintf and +vsprintf. + +The documentation from gcc is here: +https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html + +The documentation from Clang is here: +http://clang.llvm.org/docs/AttributeReference.html#format-gnu-format + +Signed-off-by: Hauke Mehrtens +--- + include/err.h | 26 +++++++++++++++++--------- + include/monetary.h | 12 ++++++++++-- + include/stdio.h | 29 ++++++++++++++++++++--------- + include/syslog.h | 12 ++++++++++-- + 4 files changed, 57 insertions(+), 22 deletions(-) + +--- a/include/err.h ++++ b/include/err.h +@@ -8,15 +8,23 @@ + extern "C" { + #endif + +-void warn(const char *, ...); +-void vwarn(const char *, va_list); +-void warnx(const char *, ...); +-void vwarnx(const char *, va_list); ++#if __GNUC__ >= 3 ++#define __fp(x, y) __attribute__ ((__format__ (__printf__, x, y))) ++#else ++#define __fp(x, y) ++#endif + +-_Noreturn void err(int, const char *, ...); +-_Noreturn void verr(int, const char *, va_list); +-_Noreturn void errx(int, const char *, ...); +-_Noreturn void verrx(int, const char *, va_list); ++void warn(const char *, ...) __fp(1, 2); ++void vwarn(const char *, va_list) __fp(1, 0); ++void warnx(const char *, ...) __fp(1, 2); ++void vwarnx(const char *, va_list) __fp(1, 0); ++ ++_Noreturn void err(int, const char *, ...) __fp(2, 3); ++_Noreturn void verr(int, const char *, va_list) __fp(2, 0); ++_Noreturn void errx(int, const char *, ...) __fp(2, 3); ++_Noreturn void verrx(int, const char *, va_list) __fp(2, 0); ++ ++#undef __fp + + #ifdef __cplusplus + } +--- a/include/monetary.h ++++ b/include/monetary.h +@@ -13,8 +13,16 @@ extern "C" { + + #include + +-ssize_t strfmon(char *__restrict, size_t, const char *__restrict, ...); +-ssize_t strfmon_l(char *__restrict, size_t, locale_t, const char *__restrict, ...); ++#if __GNUC__ >= 3 ++#define __fsfm(x, y) __attribute__ ((__format__ (__strfmon__, x, y))) ++#else ++#define __fsfm(x, y) ++#endif ++ ++ssize_t strfmon(char *__restrict, size_t, const char *__restrict, ...) __fsfm(3, 4); ++ssize_t strfmon_l(char *__restrict, size_t, locale_t, const char *__restrict, ...) __fsfm(4, 5); ++ ++#undef __fsfm + + #ifdef __cplusplus + } +--- a/include/stdio.h ++++ b/include/stdio.h +@@ -21,6 +21,14 @@ extern "C" { + + #include + ++#if __GNUC__ >= 3 ++#define __fp(x, y) __attribute__ ((__format__ (__printf__, x, y))) ++#define __fs(x, y) __attribute__ ((__format__ (__scanf__, x, y))) ++#else ++#define __fp(x, y) ++#define __fs(x, y) ++#endif ++ + #ifdef __cplusplus + #define NULL 0L + #else +@@ -102,19 +110,19 @@ int puts(const char *); + int printf(const char *__restrict, ...); + int fprintf(FILE *__restrict, const char *__restrict, ...); + int sprintf(char *__restrict, const char *__restrict, ...); +-int snprintf(char *__restrict, size_t, const char *__restrict, ...); ++int snprintf(char *__restrict, size_t, const char *__restrict, ...) __fp(3, 4); + + int vprintf(const char *__restrict, __isoc_va_list); + int vfprintf(FILE *__restrict, const char *__restrict, __isoc_va_list); + int vsprintf(char *__restrict, const char *__restrict, __isoc_va_list); +-int vsnprintf(char *__restrict, size_t, const char *__restrict, __isoc_va_list); ++int vsnprintf(char *__restrict, size_t, const char *__restrict, __isoc_va_list) __fp(3, 0); + + int scanf(const char *__restrict, ...); + int fscanf(FILE *__restrict, const char *__restrict, ...); + int sscanf(const char *__restrict, const char *__restrict, ...); +-int vscanf(const char *__restrict, __isoc_va_list); +-int vfscanf(FILE *__restrict, const char *__restrict, __isoc_va_list); +-int vsscanf(const char *__restrict, const char *__restrict, __isoc_va_list); ++int vscanf(const char *__restrict, __isoc_va_list) __fs(1, 0); ++int vfscanf(FILE *__restrict, const char *__restrict, __isoc_va_list) __fs(2, 0); ++int vsscanf(const char *__restrict, const char *__restrict, __isoc_va_list) __fs(2, 0); + + void perror(const char *); + +@@ -135,8 +143,8 @@ int pclose(FILE *); + int fileno(FILE *); + int fseeko(FILE *, off_t, int); + off_t ftello(FILE *); +-int dprintf(int, const char *__restrict, ...); +-int vdprintf(int, const char *__restrict, __isoc_va_list); ++int dprintf(int, const char *__restrict, ...) __fp(2, 3); ++int vdprintf(int, const char *__restrict, __isoc_va_list) __fp(2, 0); + void flockfile(FILE *); + int ftrylockfile(FILE *); + void funlockfile(FILE *); +@@ -175,8 +183,8 @@ int fileno_unlocked(FILE *); + int getw(FILE *); + int putw(int, FILE *); + char *fgetln(FILE *, size_t *); +-int asprintf(char **, const char *, ...); +-int vasprintf(char **, const char *, __isoc_va_list); ++int asprintf(char **, const char *, ...) __fp(2, 3); ++int vasprintf(char **, const char *, __isoc_va_list) __fp(2, 0); + #endif + + #ifdef _GNU_SOURCE +@@ -184,6 +192,9 @@ char *fgets_unlocked(char *, int, FILE * + int fputs_unlocked(const char *, FILE *); + #endif + ++#undef __fp ++#undef __fs ++ + #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) + #define tmpfile64 tmpfile + #define fopen64 fopen +--- a/include/syslog.h ++++ b/include/syslog.h +@@ -56,16 +56,22 @@ extern "C" { + #define LOG_NOWAIT 0x10 + #define LOG_PERROR 0x20 + ++#if __GNUC__ >= 3 ++#define __fp(x, y) __attribute__ ((__format__ (__printf__, x, y))) ++#else ++#define __fp(x, y) ++#endif ++ + void closelog (void); + void openlog (const char *, int, int); + int setlogmask (int); +-void syslog (int, const char *, ...); ++void syslog (int, const char *, ...) __fp(2, 3); + + #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) + #define _PATH_LOG "/dev/log" + #define __NEED_va_list + #include +-void vsyslog (int, const char *, va_list); ++void vsyslog (int, const char *, va_list) __fp(2, 0); + #if defined(SYSLOG_NAMES) + #define INTERNAL_NOPRI 0x10 + #define INTERNAL_MARK (LOG_NFACILITIES<<3) +@@ -93,6 +99,8 @@ typedef struct { + #endif + #endif + ++#undef __fp ++ + #ifdef __cplusplus + } + #endif