From 1a9c6f557bd163f959f99661bd95e193b4505291 Mon Sep 17 00:00:00 2001 From: Brian Goff Date: Wed, 24 Mar 2021 21:36:47 +0000 Subject: [PATCH 1/3] Revendor zfs to to fix integer overflow This currently breaks armhf builds. Signed-off-by: Brian Goff --- go.mod | 2 +- go.sum | 4 ++-- vendor/github.com/containerd/zfs/zfs.go | 7 +++++-- vendor/modules.txt | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 67b73947d..72c2c45b4 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/containerd/nri v0.0.0-20210316161719-dbaa18c31c14 github.com/containerd/ttrpc v1.0.2 github.com/containerd/typeurl v1.0.1 - github.com/containerd/zfs v0.0.0-20210322090317-0e92c2247fb7 + github.com/containerd/zfs v0.0.0-20210324211415-d5c4544f0433 github.com/containernetworking/plugins v0.8.6 github.com/coreos/go-systemd/v22 v22.1.0 github.com/davecgh/go-spew v1.1.1 diff --git a/go.sum b/go.sum index 6cf74c769..d19d52496 100644 --- a/go.sum +++ b/go.sum @@ -158,8 +158,8 @@ github.com/containerd/typeurl v1.0.1 h1:PvuK4E3D5S5q6IqsPDCy928FhP0LUIGcmZ/Yhgp5 github.com/containerd/typeurl v1.0.1/go.mod h1:TB1hUtrpaiO88KEK56ijojHS1+NeF0izUACaJW2mdXg= github.com/containerd/zfs v0.0.0-20200918131355-0a33824f23a2/go.mod h1:8IgZOBdv8fAgXddBT4dBXJPtxyRsejFIpXoklgxgEjw= github.com/containerd/zfs v0.0.0-20210301145711-11e8f1707f62/go.mod h1:A9zfAbMlQwE+/is6hi0Xw8ktpL+6glmqZYtevJgaB8Y= -github.com/containerd/zfs v0.0.0-20210322090317-0e92c2247fb7 h1:8vskJ2uVsiu9pjODDUnyj6gKZ6mNPMlqPgfqV6gnuRc= -github.com/containerd/zfs v0.0.0-20210322090317-0e92c2247fb7/go.mod h1:m+m51S1DvAP6r3FcmYCp54bQ34pyOwTieQDNRIRHsFY= +github.com/containerd/zfs v0.0.0-20210324211415-d5c4544f0433 h1:oFJf1mMvgJAt2QwgEsXLMQK/qRTY8JXwsCV7No1uCb8= +github.com/containerd/zfs v0.0.0-20210324211415-d5c4544f0433/go.mod h1:m+m51S1DvAP6r3FcmYCp54bQ34pyOwTieQDNRIRHsFY= github.com/containernetworking/cni v0.7.1/go.mod h1:LGwApLUm2FpoOfxTDEeq8T9ipbpZ61X79hmU3w8FmsY= github.com/containernetworking/cni v0.8.0 h1:BT9lpgGoH4jw3lFC7Odz2prU5ruiYKcgAjMCbgybcKI= github.com/containernetworking/cni v0.8.0/go.mod h1:LGwApLUm2FpoOfxTDEeq8T9ipbpZ61X79hmU3w8FmsY= diff --git a/vendor/github.com/containerd/zfs/zfs.go b/vendor/github.com/containerd/zfs/zfs.go index f7ea1f628..23ff2515f 100644 --- a/vendor/github.com/containerd/zfs/zfs.go +++ b/vendor/github.com/containerd/zfs/zfs.go @@ -36,6 +36,9 @@ const ( // active := filepath.Join(dataset.Name, id) // committed := active + "@" + snapshotSuffix snapshotSuffix = "snapshot" + + // Using this typed MaxInt64 to prevent integer overlow on 32bit + maxSnapshotSize int64 = math.MaxInt64 ) type snapshotter struct { @@ -140,8 +143,8 @@ func (z *snapshotter) usage(ctx context.Context, key string) (snapshots.Usage, e return snapshots.Usage{}, err } - if sDataset.Used > math.MaxInt64 { - return snapshots.Usage{}, errors.Errorf("Dataset size exceeds maximum snapshot size of %v bytes", math.MaxInt64) + if int64(sDataset.Used) > maxSnapshotSize { + return snapshots.Usage{}, errors.Errorf("Dataset size exceeds maximum snapshot size of %d bytes", maxSnapshotSize) } usage = snapshots.Usage{ diff --git a/vendor/modules.txt b/vendor/modules.txt index f780932de..d6e5aa383 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -105,7 +105,7 @@ github.com/containerd/ttrpc/plugin # github.com/containerd/typeurl v1.0.1 ## explicit github.com/containerd/typeurl -# github.com/containerd/zfs v0.0.0-20210322090317-0e92c2247fb7 +# github.com/containerd/zfs v0.0.0-20210324211415-d5c4544f0433 ## explicit github.com/containerd/zfs github.com/containerd/zfs/plugin From 10a498c7c8a3b9672aa733c2db83491191ad8b22 Mon Sep 17 00:00:00 2001 From: Brian Goff Date: Wed, 24 Mar 2021 22:55:56 +0000 Subject: [PATCH 2/3] Update go-winio to fix compile error on armv7 Signed-off-by: Brian Goff --- go.mod | 2 +- go.sum | 3 +- .../Microsoft/go-winio/pkg/etw/newprovider.go | 40 ------------------- .../pkg/etw/newprovider_unsupported.go | 6 +-- .../Microsoft/go-winio/pkg/etw/provider.go | 40 +++++++++++++++++++ vendor/modules.txt | 2 +- 6 files changed, 45 insertions(+), 48 deletions(-) diff --git a/go.mod b/go.mod index 72c2c45b4..ade7b18d6 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.16 require ( github.com/BurntSushi/toml v0.3.1 - github.com/Microsoft/go-winio v0.4.17-0.20210211115548-6eac466e5fa3 + github.com/Microsoft/go-winio v0.4.17-0.20210324224401-5516f17a5958 github.com/Microsoft/hcsshim v0.8.15 github.com/containerd/aufs v0.0.0-20210316121734-20793ff83c97 github.com/containerd/btrfs v0.0.0-20210316141732-918d888fb676 diff --git a/go.sum b/go.sum index d19d52496..c8756900e 100644 --- a/go.sum +++ b/go.sum @@ -41,8 +41,9 @@ github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jB github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5/go.mod h1:tTuCMEN+UleMWgg9dVx4Hu52b1bJo+59jBh3ajtinzw= github.com/Microsoft/go-winio v0.4.16-0.20201130162521-d1ffc52c7331/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0= github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0= -github.com/Microsoft/go-winio v0.4.17-0.20210211115548-6eac466e5fa3 h1:mw6pDQqv38/WGF1cO/jF5t/jyAJ2yi7CmtFLLO5tGFI= github.com/Microsoft/go-winio v0.4.17-0.20210211115548-6eac466e5fa3/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= +github.com/Microsoft/go-winio v0.4.17-0.20210324224401-5516f17a5958 h1:koVgEW/cX7NavmMAkL6LgoMZJ9gJnxuWMwwfw5A2s34= +github.com/Microsoft/go-winio v0.4.17-0.20210324224401-5516f17a5958/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= github.com/Microsoft/hcsshim v0.8.6/go.mod h1:Op3hHsoHPAvb6lceZHDtd9OkTew38wNoXnJs8iY7rUg= github.com/Microsoft/hcsshim v0.8.7-0.20190325164909-8abdbb8205e4/go.mod h1:Op3hHsoHPAvb6lceZHDtd9OkTew38wNoXnJs8iY7rUg= github.com/Microsoft/hcsshim v0.8.7/go.mod h1:OHd7sQqRFrYd3RmSgbgji+ctCwkbq2wbEYNSzOYtcBQ= diff --git a/vendor/github.com/Microsoft/go-winio/pkg/etw/newprovider.go b/vendor/github.com/Microsoft/go-winio/pkg/etw/newprovider.go index 237fc7a54..581ef595a 100644 --- a/vendor/github.com/Microsoft/go-winio/pkg/etw/newprovider.go +++ b/vendor/github.com/Microsoft/go-winio/pkg/etw/newprovider.go @@ -12,46 +12,6 @@ import ( "golang.org/x/sys/windows" ) -type providerOpts struct { - callback EnableCallback - id guid.GUID - group guid.GUID -} - -// ProviderOpt allows the caller to specify provider options to -// NewProviderWithOptions -type ProviderOpt func(*providerOpts) - -// WithCallback is used to provide a callback option to NewProviderWithOptions -func WithCallback(callback EnableCallback) ProviderOpt { - return func(opts *providerOpts) { - opts.callback = callback - } -} - -// WithID is used to provide a provider ID option to NewProviderWithOptions -func WithID(id guid.GUID) ProviderOpt { - return func(opts *providerOpts) { - opts.id = id - } -} - -// WithGroup is used to provide a provider group option to -// NewProviderWithOptions -func WithGroup(group guid.GUID) ProviderOpt { - return func(opts *providerOpts) { - opts.group = group - } -} - -// NewProviderWithID creates and registers a new ETW provider, allowing the -// provider ID to be manually specified. This is most useful when there is an -// existing provider ID that must be used to conform to existing diagnostic -// infrastructure. -func NewProviderWithID(name string, id guid.GUID, callback EnableCallback) (provider *Provider, err error) { - return NewProviderWithOptions(name, WithID(id), WithCallback(callback)) -} - // NewProviderWithOptions creates and registers a new ETW provider, allowing // the provider ID and Group to be manually specified. This is most useful when // there is an existing provider ID that must be used to conform to existing diff --git a/vendor/github.com/Microsoft/go-winio/pkg/etw/newprovider_unsupported.go b/vendor/github.com/Microsoft/go-winio/pkg/etw/newprovider_unsupported.go index d6b824afb..5a05c1342 100644 --- a/vendor/github.com/Microsoft/go-winio/pkg/etw/newprovider_unsupported.go +++ b/vendor/github.com/Microsoft/go-winio/pkg/etw/newprovider_unsupported.go @@ -3,11 +3,7 @@ package etw -import ( - "github.com/Microsoft/go-winio/pkg/guid" -) - // NewProviderWithID returns a nil provider on unsupported platforms. -func NewProviderWithID(name string, id guid.GUID, callback EnableCallback) (provider *Provider, err error) { +func NewProviderWithOptions(name string, options ...ProviderOpt) (provider *Provider, err error) { return nil, nil } diff --git a/vendor/github.com/Microsoft/go-winio/pkg/etw/provider.go b/vendor/github.com/Microsoft/go-winio/pkg/etw/provider.go index 51baeee3c..e912b51bd 100644 --- a/vendor/github.com/Microsoft/go-winio/pkg/etw/provider.go +++ b/vendor/github.com/Microsoft/go-winio/pkg/etw/provider.go @@ -119,6 +119,46 @@ func providerIDFromName(name string) guid.GUID { return guid.FromWindowsArray(a) } +type providerOpts struct { + callback EnableCallback + id guid.GUID + group guid.GUID +} + +// ProviderOpt allows the caller to specify provider options to +// NewProviderWithOptions +type ProviderOpt func(*providerOpts) + +// WithCallback is used to provide a callback option to NewProviderWithOptions +func WithCallback(callback EnableCallback) ProviderOpt { + return func(opts *providerOpts) { + opts.callback = callback + } +} + +// WithID is used to provide a provider ID option to NewProviderWithOptions +func WithID(id guid.GUID) ProviderOpt { + return func(opts *providerOpts) { + opts.id = id + } +} + +// WithGroup is used to provide a provider group option to +// NewProviderWithOptions +func WithGroup(group guid.GUID) ProviderOpt { + return func(opts *providerOpts) { + opts.group = group + } +} + +// NewProviderWithID creates and registers a new ETW provider, allowing the +// provider ID to be manually specified. This is most useful when there is an +// existing provider ID that must be used to conform to existing diagnostic +// infrastructure. +func NewProviderWithID(name string, id guid.GUID, callback EnableCallback) (provider *Provider, err error) { + return NewProviderWithOptions(name, WithID(id), WithCallback(callback)) +} + // NewProvider creates and registers a new ETW provider. The provider ID is // generated based on the provider name. func NewProvider(name string, callback EnableCallback) (provider *Provider, err error) { diff --git a/vendor/modules.txt b/vendor/modules.txt index d6e5aa383..7fe583bf6 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,7 +1,7 @@ # github.com/BurntSushi/toml v0.3.1 ## explicit github.com/BurntSushi/toml -# github.com/Microsoft/go-winio v0.4.17-0.20210211115548-6eac466e5fa3 +# github.com/Microsoft/go-winio v0.4.17-0.20210324224401-5516f17a5958 ## explicit github.com/Microsoft/go-winio github.com/Microsoft/go-winio/backuptar From 311e326a1cb264b65932c7e23d304826e26abc0b Mon Sep 17 00:00:00 2001 From: Brian Goff Date: Wed, 24 Mar 2021 20:49:58 +0000 Subject: [PATCH 3/3] Add CI job to cross compile all the things This makes sure we can compile on all the platforms and prevent things like integer overflows. Signed-off-by: Brian Goff --- .github/workflows/ci.yml | 89 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 82 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7ae06a0d5..953908d67 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -123,6 +123,88 @@ jobs: - run: make man working-directory: src/github.com/containerd/containerd + # Make sure binaries compile with other platforms + crossbuild: + name: Crossbuild Binaries + needs: [project, linters, protos, man] + runs-on: ubuntu-18.04 + timeout-minutes: 10 + strategy: + fail-fast: false + matrix: + include: + - goos: linux + goarch: arm64 + - goos: linux + goarch: arm + goarm: "7" + - goos: linux + goarch: arm + goarm: "5" + - goos: freebsd + goarch: amd64 + - goos: freebsd + goarch: arm64 + - goos: windows + goarch: arm + goarm: "7" + + steps: + - uses: actions/setup-go@v2 + with: + go-version: '1.16.2' + - name: Set env + shell: bash + run: | + echo "GOPATH=${{ github.workspace }}" >> $GITHUB_ENV + echo "${{ github.workspace }}/bin" >> $GITHUB_PATH + - uses: actions/checkout@v2 + with: + path: src/github.com/containerd/containerd + - run: | + set -e -x + + packages="" + platform="${{matrix.goos}}/${{matrix.goarch}}" + if [ -n "${{matrix.goarm}}" ]; then + platform+="/v${{matrix.goarm}}" + fi + + case "${platform}" in + linux/arm/v5) + packages+=" crossbuild-essential-armel" + echo "CGO_ENABLED=1" >> $GITHUB_ENV + echo "CC=arm-linux-gnueabi-gcc" >> $GITHUB_ENV + ;; + linux/arm/v7) + packages+=" crossbuild-essential-armhf" + echo "CGO_ENABLED=1" >> $GITHUB_ENV + echo "CC=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV + ;; + linux/arm64) + packages+=" crossbuild-essential-arm64" + echo "CGO_ENABLED=1" >> $GITHUB_ENV + echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV + ;; + windows/arm/v7) + echo "CGO_ENABLED=0" >> $GITHUB_ENV + ;; + esac + + if [ -n "${packages}" ]; then + sudo apt-get update && sudo apt-get install -y ${packages} + fi + name: install deps + - name: Build + working-directory: src/github.com/containerd/containerd + env: + GOOS: ${{matrix.goos}} + GOARCH: ${{matrix.goarch}} + GOARM: ${{matrix.goarm}} + run: | + make build + make binaries + # # Build containerd binaries # @@ -157,13 +239,6 @@ jobs: make binaries working-directory: src/github.com/containerd/containerd - - name: Cross-compile - if: startsWith(matrix.os, 'ubuntu') - run : | - GOOS=freebsd make build - GOOS=freebsd make binaries - working-directory: src/github.com/containerd/containerd - # # Integration and CRI tests #