@@ -68,7 +68,7 @@ static const char * abstract[] = {
68
68
0 };
69
69
70
70
static const char usage [] =
71
- "Usage: shc [-e date] [-m addr] [-i iopt] [-x cmd] [-l lopt] [-o outfile] [-rvDSUHCABh ] -f script" ;
71
+ "Usage: shc [-e date] [-m addr] [-i iopt] [-x cmd] [-l lopt] [-o outfile] [-rvDSUHCAB2h ] -f script" ;
72
72
73
73
static const char * help [] = {
74
74
"" ,
@@ -89,6 +89,7 @@ static const char * help[] = {
89
89
" -C Display license and exit" ,
90
90
" -A Display abstract and exit" ,
91
91
" -B Compile for busybox" ,
92
+ " -2 Use the system call mmap2" ,
92
93
" -h Display help and exit" ,
93
94
"" ,
94
95
" Environment variables used:" ,
@@ -142,6 +143,9 @@ static int TRACEABLE_flag = 1;
142
143
static const char HARDENING_line [] =
143
144
"#define HARDENING %d /* Define as 1 to disable ptrace/dump the executable */\n" ;
144
145
static int HARDENING_flag = 0 ;
146
+ static const char MMAP2_line [] =
147
+ "#define MMAP2 %d /* Define as 1 to use syscall mmap2 */\n" ;
148
+ static int MMAP2_flag = 0 ;
145
149
static const char BUSYBOXON_line [] =
146
150
"#define BUSYBOXON %d /* Define as 1 to enable work with busybox */\n" ;
147
151
static int BUSYBOXON_flag = 0 ;
@@ -338,7 +342,11 @@ static const char * RTC[] = {
338
342
" /* list of allowed syscalls */" ,
339
343
" Allow(exit_group), /* exits a process */" ,
340
344
" Allow(brk), /* for malloc(), inside libc */" ,
345
+ "#if MMAP2" ,
346
+ " Allow(mmap2), /* also for malloc() */" ,
347
+ "#else" ,
341
348
" Allow(mmap), /* also for malloc() */" ,
349
+ "#endif" ,
342
350
" Allow(munmap), /* for free(), inside libc */" ,
343
351
"" ,
344
352
" /* and if we don't match above, die */" ,
@@ -751,7 +759,7 @@ static const char * RTC[] = {
751
759
static int parse_an_arg (int argc , char * argv [])
752
760
{
753
761
extern char * optarg ;
754
- const char * opts = "e:m:f:i:x:l:o:rvDSUHCABh " ;
762
+ const char * opts = "e:m:f:i:x:l:o:rvDSUHCAB2h " ;
755
763
struct tm tmp [1 ];
756
764
time_t expdate ;
757
765
int cnt , l ;
@@ -853,6 +861,9 @@ static int parse_an_arg(int argc, char * argv[])
853
861
case 'B' :
854
862
BUSYBOXON_flag = 1 ;
855
863
break ;
864
+ case '2' :
865
+ MMAP2_flag = 1 ;
866
+ break ;
856
867
case ':' :
857
868
fprintf (stderr , "%s parse: Missing parameter\n" , my_name );
858
869
return -1 ;
@@ -1277,6 +1288,7 @@ int write_C(char * file, char * argv[])
1277
1288
fprintf (o , TRACEABLE_line , TRACEABLE_flag );
1278
1289
fprintf (o , HARDENING_line , HARDENING_flag );
1279
1290
fprintf (o , BUSYBOXON_line , BUSYBOXON_flag );
1291
+ fprintf (o , MMAP2_line , MMAP2_flag );
1280
1292
for (indx = 0 ; RTC [indx ]; indx ++ )
1281
1293
fprintf (o , "%s\n" , RTC [indx ]);
1282
1294
fflush (o );
0 commit comments