{"action":"created","issue":{"url":"https://api.github.com/repos/projectatomic/bubblewrap/issues/118","repository_url":"https://api.github.com/repos/projectatomic/bubblewrap","labels_url":"https://api.github.com/repos/projectatomic/bubblewrap/issues/118/labels{/name}","comments_url":"https://api.github.com/repos/projectatomic/bubblewrap/issues/118/comments","events_url":"https://api.github.com/repos/projectatomic/bubblewrap/issues/118/events","html_url":"https://github.com/projectatomic/bubblewrap/pull/118","id":188606954,"number":118,"title":"bind-mounts: Fix handling of covered mountpoints","user":{"login":"alexlarsson","id":990736,"avatar_url":"https://avatars.githubusercontent.com/u/990736?v=3","gravatar_id":"","url":"https://api.github.com/users/alexlarsson","html_url":"https://github.com/alexlarsson","followers_url":"https://api.github.com/users/alexlarsson/followers","following_url":"https://api.github.com/users/alexlarsson/following{/other_user}","gists_url":"https://api.github.com/users/alexlarsson/gists{/gist_id}","starred_url":"https://api.github.com/users/alexlarsson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexlarsson/subscriptions","organizations_url":"https://api.github.com/users/alexlarsson/orgs","repos_url":"https://api.github.com/users/alexlarsson/repos","events_url":"https://api.github.com/users/alexlarsson/events{/privacy}","received_events_url":"https://api.github.com/users/alexlarsson/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-11-10T20:13:14Z","updated_at":"2016-11-11T08:18:38Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/projectatomic/bubblewrap/pulls/118","html_url":"https://github.com/projectatomic/bubblewrap/pull/118","diff_url":"https://github.com/projectatomic/bubblewrap/pull/118.diff","patch_url":"https://github.com/projectatomic/bubblewrap/pull/118.patch"},"body":"Its not uncommon for mountpoints to cover other mountpoints, for instance\r\nif /a/b is mounted first, then /a/b or /a can be mounted again effectively\r\nmaking the old /a/b unreachable. This happens sometimes on the host\r\nsystem, but it happens also often in the context of bubblewrap\r\nwhere you migth do something like:\r\n    \r\n      bwrap --bind / / --bind /my/foo /foo\r\n    \r\nIn this case, we're covering whatever is on /foo on the host with\r\ndifferent content, and if /foo had submount under it these will be\r\ncovered.\r\n    \r\nThere is a problem with bind mounts and covered mountpoints though.\r\nBubblewrap always does recursive bind-mounts (because a non-recursive\r\nbind-mount could expose content that was otherwise covered), and the\r\nlinux recursive bind mount doesn't let you modify flags (such as\r\nadding readonly). So we have to first bind-mount, and then change the\r\nflags for the destination and all the submounts under it.\r\n    \r\nThe existing naive implementation of submount enumeration in\r\nbubblewrap also returns the covered mount points, and when we try\r\nto change the flags on these we run into issues, because mount()\r\ncan't find the pathnames.\r\n    \r\nThis implementation does a more thorough parsing of the mountinfo\r\nfile, looking at the \"mount id\" and \"parent mount id\" to reconstruct\r\nexactly which mountpoints that are accessible.\r\n    \r\nThis fixes https://github.com/projectatomic/bubblewrap/issues/14\r\n"},"comment":{"url":"https://api.github.com/repos/projectatomic/bubblewrap/issues/comments/259904856","html_url":"https://github.com/projectatomic/bubblewrap/pull/118#issuecomment-259904856","issue_url":"https://api.github.com/repos/projectatomic/bubblewrap/issues/118","id":259904856,"user":{"login":"alexlarsson","id":990736,"avatar_url":"https://avatars.githubusercontent.com/u/990736?v=3","gravatar_id":"","url":"https://api.github.com/users/alexlarsson","html_url":"https://github.com/alexlarsson","followers_url":"https://api.github.com/users/alexlarsson/followers","following_url":"https://api.github.com/users/alexlarsson/following{/other_user}","gists_url":"https://api.github.com/users/alexlarsson/gists{/gist_id}","starred_url":"https://api.github.com/users/alexlarsson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexlarsson/subscriptions","organizations_url":"https://api.github.com/users/alexlarsson/orgs","repos_url":"https://api.github.com/users/alexlarsson/repos","events_url":"https://api.github.com/users/alexlarsson/events{/privacy}","received_events_url":"https://api.github.com/users/alexlarsson/received_events","type":"User","site_admin":false},"created_at":"2016-11-11T08:18:38Z","updated_at":"2016-11-11T08:18:38Z","body":"@cgwalters no, unprivileged user namespaces *only* allow recursive bind mounts. If i remove the recursive bit i get:\r\n```\r\n$ bwrap --bind / / true\r\nCan't bind mount /oldroot/ on /newroot/: Invalid argument\r\n```\r\nAs for path_is_mount_point(). First, it's using name_to_handle_at() which is root-only, so without that we can't use it. Secondly its falling back to mnt_id being in fdinfo which is a recent thing, so might not be available, and its not *quite* what we want without a bunch of extra work anyway. And the final fallback fstat().st_dev+ino is completely useless as it breaks in various ways like bind mounts, etc, and it doesn't give us a mount id anyway, so we can't look up the current flags for the mountpoint.\r\n"}}
{"actor":{"display_login":"alexlarsson"}}