Skip to content

Handle unaligned uploadStart#1031

Merged
AlCutter merged 3 commits into
transparency-dev:mainfrom
AlCutter:mtc_unaligned_uploadstart
Jul 3, 2026
Merged

Handle unaligned uploadStart#1031
AlCutter merged 3 commits into
transparency-dev:mainfrom
AlCutter:mtc_unaligned_uploadstart

Conversation

@AlCutter

@AlCutter AlCutter commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

This PR adds support for mirror uploads which don't start on an entrybundle boundary.

Towards #945

@AlCutter
AlCutter force-pushed the mtc_unaligned_uploadstart branch 3 times, most recently from 465e197 to fccee32 Compare July 2, 2026 15:44
@AlCutter
AlCutter requested a review from roger2hk July 2, 2026 15:49
@AlCutter
AlCutter marked this pull request as ready for review July 2, 2026 15:49
@AlCutter
AlCutter requested a review from a team as a code owner July 2, 2026 15:49
Comment thread storage/posix/files.go Outdated
}
// ...and then write it out.

// Now write the bundle out out.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess you only want one out.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Weeeell, we do really really want to be writing it out. Like, out out. :)

Comment thread mirror_lifecycle.go Outdated
}

// bundleIterator returns an interator which yields MirrorPackages after verifying their subtree consistency with the provided pending checkpoint.
// bundleIterator returns an interator which yields entry bundles after verifying their subtree consistency with the provided pending checkpoint.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// bundleIterator returns an interator which yields entry bundles after verifying their subtree consistency with the provided pending checkpoint.
// bundleIterator returns an iterator which yields entry bundles after verifying their subtree consistency with the provided pending checkpoint.

Comment thread mirror_lifecycle.go
yield(nil, fmt.Errorf("failed to unmarshal bundle containing uploadStart (%d): %v", start, err))
return
}
padEntries = b.Entries[:p]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can the client side trigger the mirror server runtime panic (i.e. slice bounds out of range) by providing entries length less than p?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I don't think so, not unless there's been something gone quite wrong before - we read a partial bundle which matches the offset of uploadStart into that bundle. If there aren't enough entries to trim to p from that bundle, then the log is probably corrupt. OTOH, with garbage collection, we could (at least theoretically) end up being returned a full tile with more than p entries so need to trim it down.

I've added a defensive check to avoid the panic in this situation, though, as unlikely as it is, it would mean that one corrupt mirror tree would potentially make all the others served by the same process unavailable too.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Gotcha, the partial bundle comes from the mirror's log storage. It's all good if the client couldn't trigger panic in the mirror server.

@AlCutter
AlCutter force-pushed the mtc_unaligned_uploadstart branch from 7a5d461 to 196df01 Compare July 3, 2026 11:22
Comment thread mirror_lifecycle.go
yield(nil, fmt.Errorf("failed to unmarshal bundle containing uploadStart (%d): %v", start, err))
return
}
padEntries = b.Entries[:p]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Gotcha, the partial bundle comes from the mirror's log storage. It's all good if the client couldn't trigger panic in the mirror server.

@AlCutter
AlCutter merged commit c386ced into transparency-dev:main Jul 3, 2026
20 checks passed
@AlCutter
AlCutter deleted the mtc_unaligned_uploadstart branch July 3, 2026 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants