-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Component
cp
Description
When copying directories recursively, uutils treats character and block device nodes as stream sources and reads bytes from them into regular files at the destination. This breaks device semantics: /dev/null becomes an empty regular file.
GNU cp preserves device nodes as device nodes during recursive copy by default. The --copy-contents flag explicitly enables stream-reading behavior. uutils currently lacks device node recreation (via mknod) and always treats devices as streams because is_stream() returns true for char/block devices.
This breaks recursive copies of system trees like chroot environments, initramfs staging, or container filesystems where device nodes must retain their type and major/minor numbers.
Test / Reproduction Steps
src="$(mktemp -d)"
dst="$(mktemp -d)"
sudo mknod "${src}/null" c 1 3
cp -R "${src}" "${dst}"
ls -l "${src}/null" "${dst}/null"Impact
Recursive copies of filesystem trees containing device nodes produce incorrect results, breaking consumers that expect device semantics. Unbounded devices cause disk consumption and runtime denial-of-service.