mount: "bind" with recursive propagation (rprivate/rslave/rshared) performs a recursive bind (rbind)
Les mainteneurs répondent en général sous 1 jour
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 48/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- Active
- Stack technique
- go, linux
- Domaine
- backend, operating-systems
Piste de recherche
Start in mount/mounter_linux.go and trace how parseOptions separates mount flags before the initial and propagation mount(2) calls. The issue proposes returning separate flag and propagation masks and updating MakeMount and ensureMountedAs; inspect their existing tests and add coverage for bind,rprivate, bind,rslave, and bind,rshared. Done means these options no longer copy submounts, while rbind still does.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
mount.Mount(src, dst, "none", "bind,rprivate") performs a recursive bind mount instead of a plain bind mount. The same happens with bind,rslave, bind,rshared, and bind,runbindable.
Cause
parseOptionsORs every option into a singleintmask, so"bind,rprivate"producesMS_BIND|MS_PRIVATE|MS_REC(0x45000).- In
mount()(mount/mounter_linux.go),oflags := flags &^ ptypesstrips the propagation type bits before the firstmount(2)call, but leavesMS_REC(0x4000) set. - The initial
mount(2)call runs withMS_BIND|MS_REC, which the kernel treats asrbind, copying all submounts undersrcintodstbefore the secondmount(2)call appliesrprivate.
We hit this via Moby local volumes (volume/local), which pass o= directly to mount.Mount. A local volume with type=none,device=<dir>,o=bind,rprivate exposes every submount under <dir> inside the container; with o=bind,rshared, docker volume rm also unmounts those submounts on the host because the volume became a shared recursive bind.
Details and dockerd reproduction matrix
Tested on Linux with dockerd built from moby/moby master using local volumes type=none,device=/src,o=<opts>, where /src is a shared tmpfs with a tmpfs submount at /src/sub:
o= |
/src/sub visible in container |
host /src/sub after docker volume rm |
|---|---|---|
bind, bind,private |
no | kept |
bind,rprivate, bind,rslave |
yes (expected: no) | kept |
bind,rshared |
yes (expected: no) | unmounted (expected: kept) |
rbind, rbind,r* |
yes | rbind/rbind,rshared: unmounted; rprivate/rslave: kept |
Minimal standalone Go reproducer (run as root or under unshare -Urm --propagation private):
src, _ := os.MkdirTemp("", "src")
dst, _ := os.MkdirTemp("", "dst")
_ = mount.Mount("tmpfs", src, "tmpfs", "shared")
_ = os.Mkdir(filepath.Join(src, "sub"), 0o755)
_ = mount.Mount("tmpfs", filepath.Join(src, "sub"), "tmpfs", "")
_ = mount.Mount(src, dst, "none", "bind,rprivate")
mounted, _ := mountinfo.Mounted(filepath.Join(dst, "sub"))
fmt.Println("dst/sub mounted:", mounted) // prints true (expected: false)
Proposed fix
Split propagation options out of parseOptions (flag, propFlag, data) so the initial mount(2) call receives flag and the propagation mount(2) call receives propFlag. MakeMount and ensureMountedAs are updated to match, and the exported API stays unchanged.
Callers passing bind,r<prop> that relied on submounts being copied would now get a non-recursive bind (matching mount --bind --make-r<prop>). Callers that want submounts would need rbind,r<prop>.
Does this approach look good to maintainers? Happy to open a PR with unit and root mount tests if so.
AI disclosure: Used Antigravity (Gemini) to help trace the MS_REC bitmask interaction, build the dockerd reproducer, and draft this issue; reviewed and verified by the author.
- Langage dominant
- Go
- Étoiles
- 104
- Forks
- 64
- Merge moyen
- 2 j 4 h
- PR mergées (30 j)
- 11
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de moby/sys
-
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 3/5 1-2 jours Accessibilité débutants 74/100
moby/sys#254 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 3/5 1-2 jours Accessibilité débutants 68/100
moby/sys#219 · 4 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 4/5 3-5 jours Accessibilité débutants 35/100
Les mainteneurs répondent en général sous 1 jour
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
VictoriaMetrics/VictoriaLogs#1965 ·
Les mainteneurs répondent en général sous 1 jour
-
Sign-off cards drift between formats; write down one card formatPeut-être pris @keyxmakerx l’a pris aujourd’hui. Ouvertedocumentation
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
keyxmakerx/Chronicle#2795 ·
Les mainteneurs répondent en général sous 1 jour
-
bug ElasticSearch
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
aliyun/terraform-provider-alicloud#11614 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
bug enhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
Les mainteneurs répondent en général sous 2 jours
-
[Bug]: Quick chat and quick terminal text renders blurry in WebKit (Orion), sharp in ChromiumOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
Les mainteneurs répondent en général sous 1 jour