[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Hardened toolchain
From: |
kiasoc5 |
Subject: |
Re: Hardened toolchain |
Date: |
Fri, 25 Mar 2022 20:39:10 +0100 (CET) |
I managed to build hardened-gcc and hardened-binutils with the regular
toolchain. Now I'm building them with a hardened C toolchain:
====hardened.scm====
(use-modules (gnu)
(guix)
(guix packages))
(use-package-modules gcc base commencement)
(define (make-gcc-hardened gcc)
(package
(inherit gcc)
(arguments
(substitute-keyword-arguments (package-arguments gcc)
((#:configure-flags flags)
`(append (list "--enable-default-ssp"
"--enable-default-pie")
,flags))))))
(define-public gcc-hardened
(make-gcc-hardened gcc))
(define (make-binutils-hardened binutils)
(package
(inherit binutils)
(arguments
(substitute-keyword-arguments (package-arguments binutils)
((#:configure-flags flags)
`(append (list "--enable-relro"
"--enable-pic"
"--with-pic")
,flags))))))
(define-public binutils-hardened
(make-binutils-hardened binutils))
(define-public gcc-toolchain-hardened
(make-gcc-toolchain gcc-hardened))
;; TODO: apply binutils hardening
;; TODO: recompile graph with this toolchain
(define (package-with-c-toolchain-hardened package)
(package-with-c-toolchain package `(("toolchain" ,gcc-toolchain-hardened)
("binutils" ,binutils-hardened))))
(define c-toolchain-packages
(list gcc-hardened binutils-hardened))
;; gcc-hardened fails
(map package-with-c-toolchain-hardened c-toolchain-packages)
====hardened.scm====
I can build binutils-hardened with the hardened toolchain but not gcc-hardened:
====the middle of guix build -f hardened.scm====
building /gnu/store/1nlrgg5ryl486haw0kdqnbp4wa17lhwh-gcc-10.3.0.drv...
Backtrace:
In ice-9/eval.scm:
217:50 19 (lp (#<procedure 7ffff3fff5e0 at ice-9/eval.scm:282:?> ?))
217:50 18 (lp (#<procedure 7ffff3fff580 at ice-9/eval.scm:282:?> ?))
217:50 17 (lp (#<procedure 7ffff3fff4c0 at ice-9/eval.scm:649:?> ?))
217:50 16 (lp (#<procedure 7ffff3fff300 at ice-9/eval.scm:282:?> ?))
217:50 15 (lp (#<procedure 7ffff3fff2a0 at ice-9/eval.scm:649:?> ?))
217:50 14 (lp (#<procedure 7ffff3fff140 at ice-9/eval.scm:282:?> ?))
217:50 13 (lp (#<procedure 7ffff3fff120 at ice-9/eval.scm:282:?> ?))
217:50 12 (lp (#<procedure 7ffff3fff100 at ice-9/eval.scm:282:?> ?))
217:50 11 (lp (#<procedure 7ffff2c01f40 at ice-9/eval.scm:649:?> ?))
217:50 10 (lp (#<procedure 7ffff2c01f20 at ice-9/eval.scm:282:?> ?))
217:50 9 (lp (#<procedure 7ffff2c01f00 at ice-9/eval.scm:282:?> ?))
217:50 8 (lp (#<procedure 7ffff2c01ee0 at ice-9/eval.scm:282:?> ?))
217:50 7 (lp (#<procedure 7ffff2c01e80 at ice-9/eval.scm:649:?> ?))
217:50 6 (lp (#<procedure 7ffff2c01e60 at ice-9/eval.scm:282:?> ?))
217:50 5 (lp (#<procedure 7ffff2c20ed0 at ice-9/eval.scm:196:?> ?))
217:50 4 (lp (#<procedure 7ffff2c01d20 at ice-9/eval.scm:282:?> ?))
217:33 3 (lp (#<procedure 7ffff2c01b20 at ice-9/eval.scm:649:?> ?))
159:9 2 (_ #(#(#<directory (guile-user) 7ffff3fd7c80> #f) #f))
159:9 1 (_ #(#(#<directory (guile-user) 7ffff3fd7c80> #f) #f))
In unknown file:
0 (string-append "LDFLAGS=" "-Wl,-rpath=" #f "/lib " "-W?" ?)
ERROR: In procedure string-append:
In procedure string-append: Wrong type (expecting string): #f
builder for `/gnu/store/1nlrgg5ryl486haw0kdqnbp4wa17lhwh-gcc-10.3.0.drv' failed
with exit code 1
build of /gnu/store/1nlrgg5ryl486haw0kdqnbp4wa17lhwh-gcc-10.3.0.drv failed
View build log at
'/var/log/guix/drvs/1n/lrgg5ryl486haw0kdqnbp4wa17lhwh-gcc-10.3.0.drv.gz'.
guix build: error: build of
`/gnu/store/1nlrgg5ryl486haw0kdqnbp4wa17lhwh-gcc-10.3.0.drv' failed
====the middle of guix build -f hardened.scm====
I think #f is here because (assoc-ref inputs "gcc") returns #f since the
toolchain uses gcc-hardened, not gcc. Any tips?
Thanks!
Mar 22, 2022, 20:02 by kiasoc5@tutanota.com:
> Mar 22, 2022, 19:06 by zimon.toutoune@gmail.com:
>
>> Hi,
>>
>> (Although you know :) please keep CC guix-devel.)
>>
> Will remember to CC guix-devel next time.
>
>> On Tue, 22 Mar 2022 at 18:23, kiasoc5@tutanota.com wrote:
>>
>>>> --8<---------------cut here---------------start------------->8---
>>>> (define (make-gcc-hardened gcc)
>>>> (package
>>>> (inherit gcc)
>>>> (arguments
>>>> (substitute-keyword-arguments (package-arguments gcc)
>>>> ((#:configure-flags flags
>>>> `(append (list "--enable-default-ssp" "--enable-default-pie")
>>>> ,flags)))))))
>>>>
>>>> (define-public gcc-hardened
>>>> (make-gcc-hardened gcc))
>>>> --8<---------------cut here---------------end--------------->8---
>>>>
>>
>> [...]
>>
>>>
>>> I get an error when I build with guix, if you could help find it that
>>> would be great.
>>>
>>> % ./pre-inst-env guix build -f hardened.scm
>>> /home/kiasoc5/build/guix-notes/hardening/hardened.scm:11:10: error:
>>> (substitute-keyword-arguments (package-arguments gcc) ((#:configure-flags
>>> flags (quasiquote (append (list "--enable-default-ssp"
>>> "--enable-default-pie") (unquote flags)))))): source expression failed to
>>> match any pattern
>>>
>>
>> That’s because a typo. :-)
>>
> Silly me, thanks for the catch. I'll let you know how the hardened gcc goes.
>
>> ((#:configure-flags flags
>> ^missing closing parenthesis. Well, it looks like:
>>
>> --8<---------------cut here---------------start------------->8---
>> (use-modules (gnu)
>> (guix)
>> (guix packages))
>>
>> (use-package-modules gcc)
>>
>> (define (make-gcc-hardened gcc)
>> (package
>> (inherit gcc)
>> (arguments
>> (substitute-keyword-arguments (package-arguments gcc)
>> ((#:configure-flags flags)
>> `(append (list "--enable-default-ssp"
>> "--enable-default-pie")
>> ,flags))))))
>>
>> (define-public gcc-hardened
>> (make-gcc-hardened gcc))
>>
>> gcc-hardened
>> --8<---------------cut here---------------end--------------->8---
>>
>> Then, this command
>>
>> guix build -f hardened.scm -n
>>
>> returns:
>>
>> --8<---------------cut here---------------start------------->8---
>> substitute: updating substitutes from 'https://ci.guix.gnu.org'... 100.0%
>> substitute: updating substitutes from 'https://bordeaux.guix.gnu.org'...
>> 100.0%
>> The following derivation would be built:
>> /gnu/store/3i6i3pqr5r7l1568b3hswbgych974aqw-gcc-10.3.0.drv
>> 81.4 MB would be downloaded:
>> /gnu/store/7vrx4p62bkmxzrxwqdc4il9hqyh1yngh-libstdc++-10.3.0
>> /gnu/store/i459ksarhxysqb8gxa8hq6phl13d0q4a-libstdc++-headers-10.3.0
>> /gnu/store/d3js6699lc1p0sw7p0dkafi0cn33sig6-gcc-10.3.0.tar.xz
>> --8<---------------cut here---------------end--------------->8---
>>
>> I do not have tried to effectively build this gcc-hardened. :-)
>>
>> Hope that helps.
>>
>> Cheers,
>> simon
>>
>
>
- Hardened toolchain, kiasoc5, 2022/03/21
- Hardened toolchain, zimoun, 2022/03/21
- Message not available
- Re: Hardened toolchain, zimoun, 2022/03/22
- Re: Hardened toolchain, kiasoc5, 2022/03/22
- Re: Hardened toolchain,
kiasoc5 <=
- Re: Hardened toolchain, zimoun, 2022/03/25
- Re: Hardened toolchain, kiasoc5, 2022/03/26
- Re: Hardened toolchain, kiasoc5, 2022/03/26
- Re: Hardened toolchain, zimoun, 2022/03/27
Re: Hardened toolchain, Maxime Devos, 2022/03/27