reopen 655164
thanks

Dear Maintainer,

The LDFLAGS hardening flags are still missing for libbz2.so
because $(LDFLAGS) is not used in Makefile. For more hardening
information please have a look at [1], [2] and [3].

The attached patch is an updated version of bzip2-harden.patch
which fixes the issue.

To check if all flags were correctly enabled you can use
`hardening-check` from the hardening-includes package and check
the build log with `blhc` (hardening-check doesn't catch
everything):

    $ hardening-check /lib/x86_64-linux-gnu/libbz2.so.1.0.4 
/usr/lib32/libbz2.so.1.0.4 /bin/bzip2 ...
    /lib/x86_64-linux-gnu/libbz2.so.1.0.4:
     Position Independent Executable: no, regular shared library (ignored)
     Stack protected: yes
     Fortify Source functions: yes (some protected functions found)
     Read-only relocations: yes
     Immediate binding: no not found!
    /usr/lib32/libbz2.so.1.0.4:
     Position Independent Executable: no, regular shared library (ignored)
     Stack protected: yes
     Fortify Source functions: yes (some protected functions found)
     Read-only relocations: yes
     Immediate binding: no not found!
    /bin/bzip2:
     Position Independent Executable: no, normal executable!
     Stack protected: yes
     Fortify Source functions: yes (some protected functions found)
     Read-only relocations: yes
     Immediate binding: no not found!
    ...

(Position Independent Executable and Immediate binding is not
enabled by default.)

Use find -type f \( -executable -o -name \*.so\* \) -exec
hardening-check {} + on the build result to check all files.

Regards,
Simon

[1]: https://wiki.debian.org/ReleaseGoals/SecurityHardeningBuildFlags
[2]: https://wiki.debian.org/HardeningWalkthrough
[3]: https://wiki.debian.org/Hardening
-- 
+ privacy is necessary
+ using gnupg http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9
Index: bzip2-1.0.6/Makefile
===================================================================
--- bzip2-1.0.6.orig/Makefile	2012-07-01 15:05:07.000000000 +0200
+++ bzip2-1.0.6/Makefile	2012-07-01 15:08:45.586377822 +0200
@@ -20,10 +20,10 @@
 CC=gcc
 AR=ar
 RANLIB=ranlib
-LDFLAGS=
+LDFLAGS= `dpkg-buildflags --get LDFLAGS`
 
 BIGFILES=-D_FILE_OFFSET_BITS=64
-CFLAGS=-Wall -Winline -O2 -g $(BIGFILES) $(DEBCFLAGS)
+CFLAGS=-Wall -Winline $(BIGFILES) $(DEBCFLAGS)
 
 # Where you want it installed when you do 'make install'
 PREFIX=/usr/local
@@ -61,7 +61,7 @@
 	ln -sf $^ $@
 
 libbz2.so.$(sominor): $(OBJS:%.o=%.sho)
-	$(CC) -o libbz2.so.$(sominor) -shared \
+	$(CC) $(LDFLAGS) -o libbz2.so.$(sominor) -shared \
 	  -Wl,-soname,libbz2.so.$(somajor) $^ -lc
 
 %.sho: %.c

Attachment: signature.asc
Description: Digital signature

Reply via email to