Skip to content

fix(fs): preserve recursive delete child whiteouts#2047

Closed
chaliy wants to merge 1 commit into
mainfrom
2026-06-12-fix-overlayfs-underreporting-usage-issue
Closed

fix(fs): preserve recursive delete child whiteouts#2047
chaliy wants to merge 1 commit into
mainfrom
2026-06-12-fix-overlayfs-underreporting-usage-issue

Conversation

@chaliy

@chaliy chaliy commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Superseded by #2056 — rebased cleanly on main.

Copilot AI review requested due to automatic review settings June 12, 2026 01:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses an overlay filesystem quota-bypass edge case where rm -r could hide lower-layer children in accounting without preserving child-level whiteouts, allowing mkdir to later remove the parent whiteout and re-expose lower children while usage remained deducted.

Changes:

  • Materializes per-child whiteouts during recursive lower-directory deletion via hide_lower_children_recursive().
  • Adjusts remove() lower-layer accounting so recursive directory deletes still enumerate lower children even when an upper directory exists, and avoids certain double-deductions.
  • Adds regression test test_recursive_delete_recreate_keeps_lower_children_hidden.
Comments suppressed due to low confidence (1)

crates/bashkit/src/fs/overlay.rs:631

  • In recursive deletes, remove() calls upper.remove() before hide_lower_children_recursive(). That means hide_lower_children_recursive() can no longer tell which lower children were already hidden/charged due to upper overrides, so it may re-deduct those lower entries and under-report usage (quota bypass) for trees where some children existed in both layers.
                        if recursive {
                            self.hide_lower_children_recursive(&path).await;
                        }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +620 to 623
if let Ok(meta) = self.lower.stat(&path).await {
match meta.file_type {
FileType::File => self.hide_lower_file(meta.size),
FileType::File if !in_upper => self.hide_lower_file(meta.size),
FileType::Directory => {
Comment on lines 328 to +333
FileType::Directory => {
self.hide_lower_dir();
// Recurse into subdirectories
// THREAT[TM-DOS-038]: Materialize child whiteouts so
// recreating the parent does not reveal accounted children.
Box::pin(self.hide_lower_children_recursive(&child)).await;
self.add_whiteout(&child);
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 12, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit a45716e Commit Preview URL Jun 12 2026, 01:37 AM

@chaliy chaliy closed this Jun 12, 2026
chaliy added a commit that referenced this pull request Jun 12, 2026
Closes #2047

`rm -rf` on a directory was dropping whiteout entries for files deleted
in child directories, causing them to reappear on VFS layer merge. Child
whiteouts are now preserved during recursive deletion.

---
_Generated by [Claude
Code](https://claude.ai/code/session_015sDGUd934hxPk7Ttc2WqMx)_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants