Skip to content

chmod, chown: -R --preserve-root judges the operand by a separate path lookup #14990

Description

@abendrothj

With -R -H or -L, chmod/chown/chgrp check --preserve-root on one lookup of the operand, then change it and descend through another. If the operand is replaced in between, for example by a symlink to /, the check sees the old directory and the recursion runs on /. Separately, chmod -R -P re-resolves the operand to change its mode, so a symlink put at that name in between is followed.

To reproduce, run chmod -R -H -v --preserve-root u+r d repeatedly while another process keeps swapping d with a symlink to / (renameat2 with RENAME_EXCHANGE). Some runs list files under /.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions