@@ -386,7 +386,8 @@ struct rlimit_setting {
386
386
void
387
387
fd_sandbox_private_set_rlimits ( ulong rlimit_file_cnt ,
388
388
ulong rlimit_address_space ,
389
- ulong rlimit_data ) {
389
+ ulong rlimit_data ,
390
+ int dumpable ) {
390
391
struct rlimit_setting rlimits [] = {
391
392
{ .resource = RLIMIT_NOFILE , .limit = rlimit_file_cnt },
392
393
/* The man page for setrlimit(2) states about RLIMIT_NICE:
@@ -425,6 +426,7 @@ fd_sandbox_private_set_rlimits( ulong rlimit_file_cnt,
425
426
};
426
427
427
428
for ( ulong i = 0UL ; i < sizeof (rlimits )/sizeof (rlimits [ 0 ]); i ++ ) {
429
+ if ( dumpable && rlimits [i ].resource == RLIMIT_CORE ) continue ;
428
430
struct rlimit limit = { .rlim_cur = rlimits [ i ].limit , .rlim_max = rlimits [ i ].limit };
429
431
if ( -1 == setrlimit ( rlimits [ i ].resource , & limit ) ) FD_LOG_ERR (( "setrlimit(%u) failed (%i-%s)" , rlimits [ i ].resource , errno , fd_io_strerror ( errno ) ));
430
432
}
@@ -664,7 +666,7 @@ fd_sandbox_private_enter_no_seccomp( uint desired_uid,
664
666
fd_sandbox_private_landlock_restrict_self ( allow_connect );
665
667
666
668
/* And trim all the resource limits down to zero. */
667
- fd_sandbox_private_set_rlimits ( rlimit_file_cnt , rlimit_address_space , rlimit_data );
669
+ fd_sandbox_private_set_rlimits ( rlimit_file_cnt , rlimit_address_space , rlimit_data , dumpable );
668
670
669
671
/* And drop all the capabilities we have in the new user namespace. */
670
672
fd_sandbox_private_drop_caps ( cap_last_cap );
0 commit comments