Skip to content

Commit

Permalink
linux: always remount bind mounts
Browse files Browse the repository at this point in the history
it is useful to reset flags like nodev,noexec,nosuid if they are not
specified in the bind mount itself.

Closes: containers#639

Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed Mar 30, 2021
1 parent 7cfe598 commit a4c91b7
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/libcrun/linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -658,9 +658,6 @@ do_mount (libcrun_container_t *container, const char *source, int targetfd,
return crun_make_error (err, saved_errno, "mount `%s` to `/%s`", source, target);
}

if ((flags & MS_BIND) && (flags & ~(MS_BIND | MS_RDONLY | ALL_PROPAGATIONS)))
needs_remount = true;

if (targetfd >= 0)
{
/* We need to reopen the path as the previous targetfd is underneath the new mountpoint. */
Expand Down Expand Up @@ -698,7 +695,7 @@ do_mount (libcrun_container_t *container, const char *source, int targetfd,
}
}

if (mountflags & MS_RDONLY)
if (mountflags & (MS_BIND | MS_RDONLY))
needs_remount = true;
if (data && fstype && strcmp (fstype, "proc") == 0)
{
Expand Down

0 comments on commit a4c91b7

Please sign in to comment.