Gentoo Archives: gentoo-security

From: John Chronister <chron@××××××.cz>
To: gentoo-security@l.g.o
Subject: Re: [gentoo-security] propolice on amd64
Date: Tue, 20 Jan 2004 16:21:38
Message-Id: 400D54DC.701@seznam.cz
In Reply to: Re: [gentoo-security] propolice on amd64 by Ned Ludd
1 Ned Ludd wrote:
2
3 >On Mon, 2004-01-19 at 10:21, Joseph Pingenot wrote:
4 >
5 >
6 >>From John Chronister on Monday, 19 January, 2004:
7 >>
8 >>
9 >>>how do i get stack smashing protection on amd64? i am using the latest
10 >>>experimental amd64 live cd.
11 >>>-chron
12 >>>
13 >>>
14 >
15 >
16 >
17 >>You don't. IIRC, linux sets the stack noexec on amd64, and amd64 processors
18 >> honor it. Remember the hullaballoo about Microsoft doing the same thing?
19 >>
20 >>
21 >
22 >Simply trying to take advantage of the NX bit on the 64 bit arch won't
23 >do the job alone of preventing arbitrary code execution whihc I assume
24 >is the goal here.
25 >He in fact will want to enable ssp on the amd64 as well as have a kernel
26 >that can take advantage of it. As far as I'm aware of PaX
27 >http://pax.grsecurity.net/ is the only kernel patch that will let you
28 >take advantage of the NX bit on any of the 64 bit arches.
29 >
30 >solar@amd64 solar $ cat vuln.c
31 >#include <string.h>
32 >int main(int argc, char **argv) {
33 > char buf[10];
34 > strcpy(buf, argv[1]);
35 > return 0;
36 >}
37 >solar@amd64 solar $ make vuln
38 >gcc vuln.c -o vuln
39 >solar@amd64 solar $ ./vuln 12345678901234567890123456789012345678901
40 >Segmentation fault
41 >solar@amd64 solar $ gcc vuln.c -o vuln -fstack-protector
42 >solar@amd64 solar $ ./vuln 12345678901234567890123456789012345678901
43 >vuln: stack smashing attack in function main
44 >Aborted
45 >
46 >Here is my suggestion for a secure set of CFLAGS for the amd64 after
47 >getting and applying the PaX patch for amd64 and enabling Address Space
48 >Layout Randomizations.
49 >
50 >CFLAGS="${CFLAGS} -fomit-frame-pointer -fstack-protector -fPIC -pie
51 >-fforce-addr"
52 >
53 >This will build you a position independent executable without debugging
54 >frames as well as force memory address constants to be copied into
55 >registers before any arithmetic is preformed on them them.
56 >
57 >The hardened project at gentoo is planning on releasing stages which
58 >have this same set of flags enabled after gcc-3.3.x goes stable.
59 >
60 >[snip]
61 >
62 >
63 >
64 >>Many thanks to the amd64 kernel hackers!
65 >>
66 >>-Joseph
67 >>
68 >>
69 First let me say thank you for your response. I did a build normally
70 for now. I will look into this later.
71
72 Thank You Again,
73
74 -chron
75
76
77
78 --
79 gentoo-security@g.o mailing list