Skip to contentSkip to conversation

tftp-hpa: Fix PIE build with clang

PATCH New Khem Raj 1 participant 2 messages Aug 29, 2017

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/2 tftp-hpa: Fix PIE build with clang

clang finds a name clash with libc and linker errors out like below

tftpd.o: relocation R_ARM_REL32 against external or undefined symbol `__progname@@GLIBC_2.4' can not be used when making a PIE executable; recompile with -fPIC

---
 .../0001-__progname-is-provided-by-libc.patch      | 62 ++++++++++++++++++++++
 .../recipes-daemons/tftp-hpa/tftp-hpa_5.2.bb       |  1 +
 2 files changed, 63 insertions(+)
 create mode 100644 meta-networking/recipes-daemons/tftp-hpa/files/0001-__progname-is-provided-by-libc.patch
meta-networking/recipes-daemons/tftp-hpa/files/0001-__progname-is-provided-by-libc.patch new file +62 -0
new file mode 100644
index 000000000..cead977e2
@@ -0,0 +1,62 @@
+From 941038fc05be21202cab7a7a9434097fb55ecbe0 Mon Sep 17 00:00:00 2001
+From: Thorsten Glaser <[email protected]>
+Date: Thu, 31 Jul 2014 16:29:41 +0930
+Subject: [PATCH] __progname[] is provided by libc
+
+Rename local variable to tftpd_progname to avoid a clash with glibc
+global symbols and work around Debian bug #519006 (Closes: #564052).
+
+[ hpa: specifically, double-underscore symbols in C are reserved for
+  the implementation, i.e. compiler/libc. ]
+
+Signed-off-by: Ron Lee <[email protected]>
+Signed-off-by: H. Peter Anvin <[email protected]>
+---
+ tftpd/tftpd.c | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/tftpd/tftpd.c b/tftpd/tftpd.c
+index e247b97..5fec7bf 100644
+--- a/tftpd/tftpd.c
++++ b/tftpd/tftpd.c
+@@ -76,7 +76,7 @@ static int ai_fam = AF_INET;
+ #define TRIES   6               /* Number of attempts to send each packet */
+ #define TIMEOUT_LIMIT ((1 << TRIES)-1)
+ 
+-const char *__progname;
++const char *tftpd_progname;
+ static int peer;
+ static unsigned long timeout  = TIMEOUT;        /* Current timeout value */
+ static unsigned long rexmtval = TIMEOUT;       /* Basic timeout value */
+@@ -395,9 +395,9 @@ int main(int argc, char **argv)
+     /* basename() is way too much of a pain from a portability standpoint */
+ 
+     p = strrchr(argv[0], '/');
+-    __progname = (p && p[1]) ? p + 1 : argv[0];
++    tftpd_progname = (p && p[1]) ? p + 1 : argv[0];
+ 
+-    openlog(__progname, LOG_PID | LOG_NDELAY, LOG_DAEMON);
++    openlog(tftpd_progname, LOG_PID | LOG_NDELAY, LOG_DAEMON);
+ 
+     srand(time(NULL) ^ getpid());
+ 
+@@ -946,14 +946,14 @@ int main(int argc, char **argv)
+        syslog daemon gets restarted by the time we get here. */
+     if (secure && standalone) {
+         closelog();
+-        openlog(__progname, LOG_PID | LOG_NDELAY, LOG_DAEMON);
++        openlog(tftpd_progname, LOG_PID | LOG_NDELAY, LOG_DAEMON);
+     }
+ 
+ #ifdef HAVE_TCPWRAPPERS
+     /* Verify if this was a legal request for us.  This has to be
+        done before the chroot, while /etc is still accessible. */
+     request_init(&wrap_request,
+-                 RQ_DAEMON, __progname,
++                 RQ_DAEMON, tftpd_progname,
+                  RQ_FILE, fd,
+                  RQ_CLIENT_SIN, &from, RQ_SERVER_SIN, &myaddr, 0);
+     sock_methods(&wrap_request);
+-- 
+2.14.1
+
meta-networking/recipes-daemons/tftp-hpa/tftp-hpa_5.2.bb +1 -0
index 0a418b97f..fe8a32e7d 100644
@@ -26,6 +26,7 @@ SRC_URI = "http://kernel.org/pub/software/network/tftp/tftp-hpa/tftp-hpa-${PV}.t
            file://add-error-check-for-disk-filled-up.patch \
            file://tftp-hpa-bug-fix-on-separated-CR-and-LF.patch \
            file://fix-writing-emtpy-file.patch \
+           file://0001-__progname-is-provided-by-libc.patch \
            file://tftpd-hpa.socket \
            file://tftpd-hpa.service \
 "
Signature · 1 line
2.14.1
author
#1 lore raw

PATCH v2 2/2 iscsitarget: Fix kernel with new 4.12+ kernel

Fix patch to be able to work kernel < 4.12.0

---
changes from:
v1 -> v2:
- Fix build with kernel < 4.12.0

 ...vent-netlink_ack-now-requires-4-arguments.patch | 40 ++++++++++++++++++++++
 .../iscsitarget/iscsitarget_1.4.20.3+svn502.bb     |  4 ++-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 meta-networking/recipes-extended/iscsitarget/files/0001-kernel-event-netlink_ack-now-requires-4-arguments.patch
meta-networking/recipes-extended/iscsitarget/files/0001-kernel-event-netlink_ack-now-requires-4-arguments.patch new file +40 -0
new file mode 100644
index 000000000..4426d3552
@@ -0,0 +1,40 @@
+From cbc5f8151017f45231b75a826f18354a81c287c4 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Sat, 26 Aug 2017 07:52:59 -0700
+Subject: [PATCH] kernel/event: netlink_ack() now requires 4 arguments
+
+see https://patchwork.kernel.org/patch/9670181/
+
+event.c:32:4: error: too few arguments to function 'netlink_ack'
+|     netlink_ack(skb, nlh, 0);
+|     ^~~~~~~~~~~
+
+Signed-off-by: Khem Raj <[email protected]>
+---
+ kernel/event.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+Index: iscsitarget-1.4.20.3+svn502/kernel/event.c
+===================================================================
+--- iscsitarget-1.4.20.3+svn502.orig/kernel/event.c
++++ iscsitarget-1.4.20.3+svn502/kernel/event.c
+@@ -6,6 +6,7 @@
+  * Some functions are based on audit code.
+  */
+ 
++#include <linux/version.h>
+ #include <linux/module.h>
+ #include <net/tcp.h>
+ #include "iet_u.h"
+@@ -29,7 +30,11 @@ static void event_recv_skb(struct sk_buf
+ 		ietd_pid = NETLINK_CB(skb).portid;
+ 		WARN_ON(ietd_pid == 0);
+ 		if (nlh->nlmsg_flags & NLM_F_ACK)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
++			netlink_ack(skb, nlh, 0, NULL);
++#else
+ 			netlink_ack(skb, nlh, 0);
++#endif
+ 		skb_pull(skb, rlen);
+ 	}
+ }
meta-networking/recipes-extended/iscsitarget/iscsitarget_1.4.20.3+svn502.bb +3 -1
index 5c1e38e17..659366107 100644
@@ -14,7 +14,9 @@ SRC_URI = "http://ftp.heanet.ie/mirrors/ubuntu/pool/universe/i/${BPN}/${BPN}_${P
            file://access-sk_v6_daddr-iff-IPV6-defined.patch \
            file://build_with_updated_bio_struct_of_linux_v4.3_and_above.patch \
            file://build_with_updated_interfaces_of_linux_v4.8_and_above.patch \
-           file://fix-call-trace-of-ahash-API-calling.patch"
+           file://fix-call-trace-of-ahash-API-calling.patch \
+           file://0001-kernel-event-netlink_ack-now-requires-4-arguments.patch \
+           "
 
 SRC_URI[md5sum] = "ef9bc823bbabd3c772208c00d5f2d089"
 SRC_URI[sha256sum] = "d3196ccb78a43266dce28587bfe30d8ab4db7566d7bce96057dfbb84100babb5"
Signature · 1 line
2.14.1