Skip to content

vendor: github.com/containerd/containerd/v2 v2.4.2 - #7278

Merged
tonistiigi merged 1 commit into
moby:masterfrom
thaJeztah:vendor_containerd_2.4.2
Oct 23, 2026
Merged

tonistiigi merged 1 commit into
moby:masterfrom
thaJeztah:vendor_containerd_2.4.2

Conversation

@thaJeztah

Copy link
Copy Markdown
Member

@github-actions github-actions Bot added the area/dependencies Pull requests that update a dependency file label Oct 13, 2026
@thaJeztah

Copy link
Copy Markdown
Member Author

Failure could be related; is it returning a special -1 sentinel value now?

=== Failed
=== FAIL: util/contentutil TestReadWrite (0.00s)
    buffer_test.go:24: 
        	Error Trace:	/src/util/contentutil/buffer_test.go:24
        	Error:      	Received unexpected error:
        	            	invalid content size -1: invalid argument
        	Test:       	TestReadWrite

=== FAIL: util/contentutil TestCopy (0.00s)
    copy_test.go:29: 
        	Error Trace:	/src/util/contentutil/copy_test.go:29
        	Error:      	Received unexpected error:
        	            	invalid content size -1: invalid argument
        	Test:       	TestCopy

=== FAIL: util/contentutil TestLabels (0.00s)
    buffer_test.go:82: 
        	Error Trace:	/src/util/contentutil/buffer_test.go:82
        	Error:      	Received unexpected error:
        	            	invalid content size -1: invalid argument
        	Test:       	TestLabels

=== FAIL: util/contentutil TestReaderAt (0.00s)
    buffer_test.go:54: 
        	Error Trace:	/src/util/contentutil/buffer_test.go:54
        	Error:      	Received unexpected error:
        	            	invalid content size -1: invalid argument
        	Test:       	TestReaderAt

=== FAIL: util/contentutil TestMultiProvider (0.00s)
    multiprovider_test.go:23: 
        	Error Trace:	/src/util/contentutil/multiprovider_test.go:23
        	Error:      	Received unexpected error:
        	            	invalid content size -1: invalid argument
        	Test:       	TestMultiProvider

=== FAIL: util/contentutil TestFetcher (0.00s)
    fetcher_test.go:23: 
        	Error Trace:	/src/util/contentutil/fetcher_test.go:23
        	Error:      	Received unexpected error:
        	            	invalid content size -1: invalid argument
        	Test:       	TestFetcher

DONE 2094 tests, 10 skipped, 6 failures in 189.491s

@thaJeztah

Copy link
Copy Markdown
Member Author

Failures were on Nydus and Stargz - pretty possible those are not tested in containerd upstream, so could be genuine.

(restarted CI to see if it was a flake)

Comment on lines 192 to +195
func Copy(ctx context.Context, cw Writer, or io.Reader, size int64, expected digest.Digest, opts ...Opt) error {
r := or
if size < 0 {
return fmt.Errorf("invalid content size %d: %w", size, errdefs.ErrInvalidArgument)
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Looks this error

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@samuelkarp Is there a reason the size is mandatory now? This is just a helper function between Reader and Writer. If you want to verify that nobody puts -1 inside Descriptor.Size in a JSON manifest, then I think that should happen at the level that deals with JSON manifests, not in this copy helper.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

interestingly; compose also failed on this patch (containerd/containerd@7f0c0b8); docker/compose#14339 (comment)

But looks like compose had a local mitigation for size-mismatch; https://github.com/docker/compose/blob/171f9d0767f7e0c43a3d2fa2949cde9ae3d679d8/internal/oci/resolver.go#L112-L120

	// bound the read by the declared size so a rogue registry can't cause
	// unbounded allocation; the extra byte detects oversized responses.
	content, err := io.ReadAll(io.LimitReader(fetch, descriptor.Size+1))
	if err != nil {
		return nil, fmt.Errorf("reading blob %s: %w", descriptor.Digest, err)
	}
	if int64(len(content)) != descriptor.Size {
		return nil, fmt.Errorf("blob %s size mismatch: expected %d bytes, got %d", descriptor.Digest, descriptor.Size, len(content))
	}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it's pretty reasonable for a copy helper that takes size as input to validate the size.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So we should write our own helpers just to avoid this? If you want to add extra functionality into copy helper then it should be called CopyAndValidateSize(). Additionally, the next parameter in this function is expected, but it is NOT required and ignores empty value same way as size did before.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@tonistiigi @samuelkarp wondering if something in between would work; explicitly make -1 a sentinel value, and reject other negative values.

For the advisory that was fixed; I ... somewhat assume that had validation as well before this utility is even hit (which would mean that -1 would be rejected earlier if it's coming from a remote response?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The advisories that were fixed were all exploitable. We generally try not to issue spurious advisories.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The advisories that were fixed were all exploitable. We generally try not to issue spurious advisories.

Oh, sorry, didn't mean to imply it wasn't a real issue, just was curious if there's checks before this utility is called (because the utility itself documents "unknown sizes" as supported, but validation of the manifest-size may be before that).

@tonistiigi @samuelkarp I opened a PR to address the change in behavior;

@thaJeztah

Copy link
Copy Markdown
Member Author

Hm.. it's not all of them this time; could it be some race? I can try once more.

@thaJeztah

Copy link
Copy Markdown
Member Author

Pushed a temporary commit with the tip of v2.4 branch, without the changes from #7285 in Buildkit itself.

@thaJeztah
thaJeztah force-pushed the vendor_containerd_2.4.2 branch from 26bdb13 to d99b905 Compare October 21, 2026 14:43
@thaJeztah

Copy link
Copy Markdown
Member Author

Pushed a temporary commit with the tip of v2.4 branch, without the changes from #7285 in Buildkit itself.

OK; looks happy with the upstream fixes; I'll drop them for now, and rebased to get the changes from #7285 in master.

@thaJeztah
thaJeztah force-pushed the vendor_containerd_2.4.2 branch from d99b905 to d9a55f2 Compare October 22, 2026 08:02
@thaJeztah
thaJeztah marked this pull request as ready for review October 22, 2026 08:02
@tonistiigi
tonistiigi merged commit 6b5b47b into moby:master Oct 23, 2026
212 checks passed
@thaJeztah
thaJeztah deleted the vendor_containerd_2.4.2 branch October 23, 2026 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants