@@ -85,6 +85,7 @@ int opt_userns_block_fd = -1;
8585int opt_info_fd = -1 ;
8686int opt_json_status_fd = -1 ;
8787int opt_seccomp_fd = -1 ;
88+ int opt_propagation = 0 ;
8889const char * opt_sandbox_hostname = NULL ;
8990char * opt_args_data = NULL ; /* owned */
9091int opt_userns_fd = -1 ;
@@ -331,6 +332,7 @@ usage (int ecode, FILE *out)
331332 " --symlink SRC DEST Create symlink at DEST with target SRC\n"
332333 " --seccomp FD Load and use seccomp rules from FD (not repeatable)\n"
333334 " --add-seccomp-fd FD Load and use seccomp rules from FD (repeatable)\n"
335+ " --private Set mount propagation to private\n"
334336 " --block-fd FD Block on FD until some data to read is available\n"
335337 " --userns-block-fd FD Block on FD until the user namespace is ready\n"
336338 " --info-fd FD Write information about the running container to FD\n"
@@ -1070,7 +1072,7 @@ privileged_op (int privileged_op_socket,
10701072 break ;
10711073
10721074 case PRIV_SEP_OP_REMOUNT_RO_NO_RECURSIVE :
1073- bind_result = bind_mount (proc_fd , NULL , arg2 , BIND_READONLY );
1075+ bind_result = bind_mount (proc_fd , opt_propagation , NULL , arg2 , BIND_READONLY );
10741076
10751077 if (bind_result != BIND_MOUNT_SUCCESS )
10761078 die_with_bind_result (bind_result , errno ,
@@ -1081,7 +1083,7 @@ privileged_op (int privileged_op_socket,
10811083 case PRIV_SEP_OP_BIND_MOUNT :
10821084 /* We always bind directories recursively, otherwise this would let us
10831085 access files that are otherwise covered on the host */
1084- bind_result = bind_mount (proc_fd , arg1 , arg2 , BIND_RECURSIVE | flags );
1086+ bind_result = bind_mount (proc_fd , opt_propagation , arg1 , arg2 , BIND_RECURSIVE | flags );
10851087
10861088 if (bind_result != BIND_MOUNT_SUCCESS )
10871089 die_with_bind_result (bind_result , errno ,
@@ -2149,6 +2151,8 @@ parse_args_recurse (int *argcp,
21492151 argv += 1 ;
21502152 argc -= 1 ;
21512153 }
2154+ else if (strcmp (arg , "--private" ) == 0 )
2155+ opt_propagation = 1 ;
21522156 else if (strcmp (arg , "--add-seccomp-fd" ) == 0 )
21532157 {
21542158 int the_fd ;
@@ -2956,7 +2960,12 @@ main (int argc,
29562960 /* Mark everything as slave, so that we still
29572961 * receive mounts from the real root, but don't
29582962 * propagate mounts to the real root. */
2959- if (mount (NULL , "/" , NULL , MS_SILENT | MS_SLAVE | MS_REC , NULL ) < 0 )
2963+ int current_propagation ;
2964+ if (opt_propagation == 0 )
2965+ current_propagation = MS_SLAVE ;
2966+ else
2967+ current_propagation = MS_PRIVATE ;
2968+ if (mount (NULL , "/" , NULL , MS_SILENT | current_propagation | MS_REC , NULL ) < 0 )
29602969 die_with_error ("Failed to make / slave" );
29612970
29622971 /* Create a tmpfs which we will use as / in the namespace */
0 commit comments