daemon: fix getSourceMount to handle multiple mounts at same path by majiayu000 · Pull Request #51787 · moby/moby

@majiayu000

When a mountpoint is mounted multiple times with different propagation
settings (e.g., first as slave then as shared), getSourceMount would
return the first entry instead of the last one. This caused issues
where Docker would incorrectly report "path is not a shared mount"
even when the most recent mount has shared propagation.

Fix by using >= instead of > when comparing mount path lengths, which
ensures that later entries (with the same path length) are preferred.
This matches the expected behavior where /proc/self/mountinfo lists
mounts in order, and the last entry for a given path represents the
current mount state.

Fixes moby#43714

Signed-off-by: majiayu000 <1835304752@qq.com>

thaJeztah

TusharSariya added a commit to TusharSariya/moby that referenced this pull request

Mar 3, 2026
When a path has multiple bind mount entries in /proc/self/mountinfo with
different propagation settings, getSourceMount returned the first (stale)
entry instead of the last (current) one. Change > to >= so the most
recent entry is selected.

Fixes moby#43714
Supersedes moby#51787

Signed-off-by: tushar sariya <tushar.97@hotmail.com>

TusharSariya added a commit to TusharSariya/moby that referenced this pull request

Mar 3, 2026
When a path has multiple bind mount entries in /proc/self/mountinfo with
different propagation settings, getSourceMount returned the first (stale)
entry instead of the last (current) one. Change > to >= so the most
recent entry is selected.

Fixes moby#43714
Supersedes moby#51787

Signed-off-by: tushar sariya <tushar.97@hotmail.com>

TusharSariya added a commit to TusharSariya/moby that referenced this pull request

Mar 4, 2026
When a path has multiple bind mount entries in /proc/self/mountinfo with
different propagation settings, getSourceMount returned the first (stale)
entry instead of the last (current) one. Change > to >= so the most
recent entry is selected.

Fixes moby#43714
Supersedes moby#51787

Signed-off-by: tushar sariya <tushar.97@hotmail.com>