Skip to content

dd: Silent Truncate Error Suppression #9745

Closed

Description

@sylvestre

Component

dd

Description

If the output device is full, read-only, or otherwise unable to be truncated, dd reports success (exit 0) while leaving stale data in the output file.

Impact

Silent data corruption. Backup scripts relying on dd may believe a copy succeeded when it actually contains old/garbage data, leading to undetected data loss during recovery.

Activity

  1. dshemetov commented on Dec 20, 2025

    @dshemetov
    Contributor

    Looking into this one

  2. dshemetov commented on Dec 20, 2025

    @dshemetov
    Contributor

    Output device full appears to be returning exit 1 on Unix correctly

    # /dev/full always returns ENOSPC.
    dd if=/dev/zero of=/dev/full bs=1K count=1; echo "Exit code: $?"
    
    alias dd='./target/debug/coreutils dd'
    dd if=/dev/zero of=/dev/full bs=1K count=1; echo "Exit code: $?"
    unalias dd
    
    # Both return 
    dd: error writing '/dev/full': No space left on device
    1+0 records in
    0+0 records out
    0 bytes copied, 8.1649e-05 s, 0.0 kB/s
    Exit code: 1
  3. dshemetov commented on Dec 20, 2025

    @dshemetov
    Contributor

    Can't repro the read-only condition problem either (on Unix)

    # Read-only file test.
    mkdir -p test-dd && touch test-dd/readonly.out && chmod 444 test-dd/readonly.out && dd if=/dev/zero of=test-dd/readonly.out bs=1K count=1 2>&1; echo "Exit code: $?"; chmod 644 test-dd/readonly.out && rm -f test-dd/readonly.out
    alias dd='./target/debug/coreutils dd'
    mkdir -p test-dd && touch test-dd/readonly.out && chmod 444 test-dd/readonly.out && dd if=/dev/zero of=test-dd/readonly.out bs=1K count=1 2>&1; echo "Exit code: $?"; chmod 644 test-dd/readonly.out && rm -f test-dd/readonly.out
    unalias dd
    
    # Both return
    dd: failed to open 'test-dd/readonly.out': Permission denied
    Exit code: 1
  4. ChrisDryden commented on Jan 28, 2026

    @ChrisDryden
    Collaborator

    I see that it mentions that its tagged "reported-canonical" but there's no link. I've tried searching for one that matches this description. I also tried a few different scenarios and file systems and I was unable to find a condition where the uutils implementation differs from the gnu version when it comes to silent truncation.

  5. pajod commented on Jul 13, 2026

    @pajod

    Appears to be resolved in #12667 @ 0f538b9 (as of this writing, not in a tagged release).

  6. sylvestre commented on Sep 8, 2026

    @sylvestre
    SponsorContributorAuthor

    indeed, thanks

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