Skip to content

'hard_link = true' deletes special files like '/dev/null' and replaces them with regular files #564

@trofi

Description

@trofi

It's an upstream variant of bug https://bugs.gentoo.org/712080 observed and debugged by Dan Goodliffe on ccache-3.7.7

There user runs kernel build as root in a container (or on real machine) and observes /dev/null to be replaced by regular file.

Trigger command:

CCACHE_HARDLINK=1 /usr/lib/ccache/bin/cc -Werror -Wmaybe-uninitialized -S -x c /dev/null -o /dev/null

Kernel's build ssystem probably just probes flag support and redirects unused output to /dev/null.

On my system strace confirms rename attempt. It fails to damage my system only because /dev/null is a mountpoint for me:

# ls -l /dev/null; id; CCACHE_HARDLINK=1 strace -y -f /usr/lib/ccache/bin/cc  -Werror -Wmaybe-uninitialized -S -x c /dev/null -o /dev/null |& egrep 'rename.*null' ; ls -l /dev/null
crw-rw-rw- 1 root root 1, 3 Mar 16 22:17 /dev/null
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(floppy),20(dialout),26(tape),27(video)
rename("/root/.ccache/tmp/null.stdout.sf.17002.qbbtTO", "/root/.ccache/tmp/null.stdout.sf.17002.qbbtTO.i") = 0
rename("/dev/null", "/dev/null.rm.sf.17002.XXXXXX") = -1 EBUSY (Device or resource busy)
crw-rw-rw- 1 root root 1, 3 Mar 16 22:17 /dev/null

In upstream bug user observed successful rename():

rename("/dev/null", "/dev/null.rm.akira.261700.XXXXXX") = 0
unlink("/dev/null.rm.akira.261700.XXXXXX") = 0
...

Would it be reasonable for ccache not to try moving special files around even in CCACHE_HARDLINK=1 mode (or maybe handle /dev/null in a special way that does not require writes into target). Or should this behaviour be declared Intended Behaviour?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugDoes not work as intended/documented

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions