From 5770cd5bee1c9ad3025435426361f0e407d43ef8 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Thu, 8 Jun 2017 20:41:35 -0700 Subject: rng-tools: Fix textrels on 32bit x86 When testing core-image-sato with hardening flags, it fails with SIGSEGV in libc.so during relocation time This is due to relocations in .text [textrel] build QA points it out clearly during qemux86 build as well AssertionError: 2 != 0 : Log: /mnt/a/oe/build/tmp/work/qemux86-bec-linux-musl/core-image-sato/1.0-r0/dmesg_output.log ----------------------- Central error: [ 19.043597] rngd[525]: segfault at 80098bb7 ip b77b14fc sp bfe9b380 error 7 in libc.so[b774c000+97000] Signed-off-by: Khem Raj Signed-off-by: Ross Burton --- .../rng-tools-5-fix-textrels-on-PIC-x86.patch | 104 +++++++++++++++++++++ meta/recipes-support/rng-tools/rng-tools_5.bb | 1 + 2 files changed, 105 insertions(+) create mode 100644 meta/recipes-support/rng-tools/rng-tools/rng-tools-5-fix-textrels-on-PIC-x86.patch (limited to 'meta/recipes-support/rng-tools') diff --git a/meta/recipes-support/rng-tools/rng-tools/rng-tools-5-fix-textrels-on-PIC-x86.patch b/meta/recipes-support/rng-tools/rng-tools/rng-tools-5-fix-textrels-on-PIC-x86.patch new file mode 100644 index 0000000000..90c9d8c515 --- /dev/null +++ b/meta/recipes-support/rng-tools/rng-tools/rng-tools-5-fix-textrels-on-PIC-x86.patch @@ -0,0 +1,104 @@ +From: Francisco Blas Izquierdo Riera (klondike) +Subject: [PATCH] Fix assemby textrels on rdrand_asm.S on PIC x86 + +This patch updates the fixes in the assembly in rdrand_asm.S in +sys-apps/rng-tools-5 so it won't generate textrels on PIC systems. +The main fixes are in the use of leal in SETPTR for such systems, the rest is +the usual PIC support stuff. + +This should fix Gentoo bug #469962 and help fix #518210 + +This patch is released under the GPLv2 or a higher version license as is the +original file as long as the author and the tester are credited. + +Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=469962 +Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=518210 +Upstream-status: Not sent yet +Signed-off-by: Francisco Blas Izquierdo Riera (klondike) +Reported-by: cilly +Reported-by: Manuel RĂ¼ger +Tested-by: Anthony Basile + +Upstream-Status: Pending + +Index: rng-tools-5/rdrand_asm.S +=================================================================== +--- rng-tools-5.orig/rdrand_asm.S ++++ rng-tools-5/rdrand_asm.S +@@ -2,6 +2,7 @@ + * Copyright (c) 2011-2014, Intel Corporation + * Authors: Fenghua Yu , + * H. Peter Anvin ++ * PIC code by: Francisco Blas Izquierdo Riera (klondike) + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, +@@ -174,7 +175,19 @@ ENTRY(x86_rdseed_or_rdrand_bytes) + jmp 4b + ENDPROC(x86_rdseed_or_rdrand_bytes) + ++#if defined(__PIC__) ++#define INIT_PIC() \ ++ pushl %ebx ; \ ++ call __x86.get_pc_thunk.bx ; \ ++ addl $_GLOBAL_OFFSET_TABLE_, %ebx ++#define END_PIC() \ ++ popl %ebx ++#define SETPTR(var,ptr) leal (var)@GOTOFF(%ebx),ptr ++#else ++#define INIT_PIC() ++#define END_PIC() + #define SETPTR(var,ptr) movl $(var),ptr ++#endif + #define PTR0 %eax + #define PTR1 %edx + #define PTR2 %ecx +@@ -190,6 +203,7 @@ ENTRY(x86_aes_mangle) + movl 8(%ebp), %eax + movl 12(%ebp), %edx + push %esi ++ INIT_PIC() + #endif + movl $512, CTR3 /* Number of rounds */ + +@@ -280,6 +294,7 @@ offset = offset + 16 + movdqa %xmm7, (7*16)(PTR1) + + #ifdef __i386__ ++ END_PIC() + pop %esi + pop %ebp + #endif +@@ -294,6 +309,7 @@ ENTRY(x86_aes_expand_key) + push %ebp + mov %esp, %ebp + movl 8(%ebp), %eax ++ INIT_PIC() + #endif + + SETPTR(aes_round_keys, PTR1) +@@ -323,6 +339,7 @@ ENTRY(x86_aes_expand_key) + call 1f + + #ifdef __i386__ ++ END_PIC() + pop %ebp + #endif + ret +@@ -343,6 +360,16 @@ ENTRY(x86_aes_expand_key) + + ENDPROC(x86_aes_expand_key) + ++#if defined(__i386__) && defined(__PIC__) ++ .section .text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat ++ .globl __x86.get_pc_thunk.bx ++ .hidden __x86.get_pc_thunk.bx ++ .type __x86.get_pc_thunk.bx, @function ++__x86.get_pc_thunk.bx: ++ movl (%esp), %ebx ++ ret ++#endif ++ + .bss + .balign 64 + aes_round_keys: diff --git a/meta/recipes-support/rng-tools/rng-tools_5.bb b/meta/recipes-support/rng-tools/rng-tools_5.bb index 9329e8ad31..e2acaba91a 100644 --- a/meta/recipes-support/rng-tools/rng-tools_5.bb +++ b/meta/recipes-support/rng-tools/rng-tools_5.bb @@ -7,6 +7,7 @@ SRC_URI = "${SOURCEFORGE_MIRROR}/gkernel/${BP}.tar.gz \ file://0002-Add-argument-to-control-the-libargp-dependency.patch \ file://underquote.patch \ file://uclibc-libuargp-configure.patch \ + file://rng-tools-5-fix-textrels-on-PIC-x86.patch \ file://init \ file://default" -- cgit 1.2.3-korg