Commit Graph

11307 Commits

Author SHA1 Message Date
Sebastiaan van Stijn
0eaace3066
golangci-lint: sort linters in config file
THis makes it easier to find which linters are enabled when going through
the list.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-12 14:40:11 +02:00
Sebastiaan van Stijn
3ebeb6d79b
linting: address gosec G112/G114
GOGC=75 golangci-lint run
    services/server/server.go:320:27: G114: Use of net/http serve function that has no support for setting timeouts (gosec)
        return trapClosedConnErr(http.Serve(l, m))
                                 ^
    services/server/server.go:340:27: G114: Use of net/http serve function that has no support for setting timeouts (gosec)
        return trapClosedConnErr(http.Serve(l, m))
                                 ^
    cmd/containerd-stress/main.go:238:13: G114: Use of net/http serve function that has no support for setting timeouts (gosec)
            if err := http.ListenAndServe(c.Metrics, metrics.Handler()); err != nil {
                      ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-12 14:40:11 +02:00
Ed Bartosh
347397cf2f update go.mod and go.sum
Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
2022-10-12 14:00:59 +03:00
Ed Bartosh
643dc16565 improve CDI logging
Added logging of found CDI devices.
Fixed test failures caused by the change.

Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
2022-10-12 13:45:20 +03:00
Ed Bartosh
8ed910c46a CDI: configure registry on start
Currently CDI registry is reconfigured on every
WithCDI call, which is a relatively heavy operation.

This happens because cdi.GetRegistry(cdi.WithSpecDirs(cdiSpecDirs...))
unconditionally reconfigures the registry (clears fs notify watch,
sets up new watch, rescans directories).

Moving configuration to the criService.initPlatform should result
in performing registry configuration only once on the service start.

Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
2022-10-12 13:45:20 +03:00
Ed Bartosh
eec7a76ecd move WithCDI to pkg/cri/opts
As WithCDI is CRI-only API it makes sense to move it
out of oci module.

This move can also fix possible issues with this API when
CRI plugin is disabled.

Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
2022-10-12 13:45:20 +03:00
Sebastiaan van Stijn
634bf0dd31
cmd/containerd: use golang.org/x/sys Service.SetRecoveryActions()
This is the equivalent of the local implementation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-12 09:43:10 +02:00
Kevin Parsons
e6b5311508
Merge pull request #7483 from jterry75/jterry75/update_image_config_argsescaped
Updates oci image config to support upstream ArgsEscaped
2022-10-11 16:32:31 -07:00
Zhuchen Wang
17a9324035
Update the default seccomp to block socket calls to AF_VSOCK
Signed-off-by: Zhuchen Wang <zcwang@google.com>
2022-10-11 15:30:39 -07:00
Justin Terry
d4b9dade13 Updates oci image config to support upstream ArgsEscaped
ArgsEscaped has now been merged into upstream OCI image spec.
This change removes the workaround we were doing in containerd
to deserialize the extra json outside of the spec and instead
just uses the formal spec types.

Signed-off-by: Justin Terry <jlterry@amazon.com>
2022-10-11 13:29:56 -07:00
Phil Estes
32aa33a9f4
Merge pull request #7497 from thaJeztah/replace_IsAnInteractiveSession
cmd/containerd: replace deprecated windows.IsAnInteractiveSession()
2022-10-11 13:17:48 -07:00
Phil Estes
9b0ab84449
Merge pull request #7481 from qiutongs/netns-fix
Update container with sandbox metadata after NetNS is created
2022-10-10 15:48:54 -07:00
Phil Estes
cef99bea26
Merge pull request #7478 from AkihiroSuda/archive-whiteout-source-date-epoch
archive: add WithSourceDateEpoch() for whiteouts
2022-10-10 15:45:25 -07:00
Maksym Pavlenko
e61539ae84
Merge pull request #7492 from kzys/task-resize
TestTaskResize must use a terminal
2022-10-10 15:30:25 -07:00
Fu Wei
7f33a20da2
Merge pull request #7494 from AkihiroSuda/diff-apply-fix-read-count 2022-10-10 20:53:51 +08:00
Samuel Karp
5530a00f39
Merge pull request #7425 from Jenkins-J/ctr-dev-import 2022-10-10 00:56:01 -07:00
rongfu.leng
047e684bbb fix install cni script
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
2022-10-10 10:29:20 +08:00
Qiutong Song
b41d6f40bb Update container with sandbox metadata after NetNS is created
Signed-off-by: Qiutong Song <songqt01@gmail.com>
2022-10-09 01:14:08 +00:00
Sebastiaan van Stijn
8fc68db0c0
cmd/containerd: replace deprecated windows.IsAnInteractiveSession()
The `IsAnInteractiveSession` was deprecated, and `IsWindowsService` is marked
as the recommended replacement.

For details, see 280f808b4a

> CL 244958 includes isWindowsService function that determines if a
> process is running as a service. The code of the function is based on
> public .Net implementation.
>
> IsAnInteractiveSession function implements similar functionality, but
> is based on an old Stackoverflow post., which is not as authoritative
> as code written by Microsoft for their official product.
>
> This change copies CL 244958 isWindowsService function into svc package
> and makes it public. The intention is that future users will prefer
> IsWindowsService to IsAnInteractiveSession.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-08 15:05:59 +02:00
rongfu.leng
63a7d8a7ff fix pusher concurrent close channel
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
2022-10-08 11:27:54 +08:00
Kazuyoshi Kato
260af5e1d2 TestTaskResize must use a terminal
The test was essentially no-op since it didn't use a terminal.

Fixes #6249.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2022-10-08 01:39:27 +00:00
Akihiro Suda
39158629f7
diff/apply.readCounter: check negative size
`rc.r.Read()` may return a negative `int` on an error
when the reader is set to a custom content store implementation

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2022-10-08 10:19:14 +09:00
Akihiro Suda
70fbedc217
archive: add WithSourceDateEpoch() for whiteouts
This makes diff archives to be reproducible.

The value is expected to be passed from CLI applications via the $SOUCE_DATE_EPOCH env var.

See https://reproducible-builds.org/docs/source-date-epoch/
for the $SOURCE_DATE_EPOCH specification.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2022-10-08 08:45:03 +09:00
Kazuyoshi Kato
4a0ddfa974
Merge pull request #7491 from thaJeztah/chtimes_redundancy
archive: windows: chtimes(): remove redundant conversion
2022-10-07 16:10:54 -07:00
Sebastiaan van Stijn
0aefb52807
archive: windows: chtimes(): remove redundant conversion
It looks like this function was converting the time (`windows.NsecToTimespec()`),
only to convert it back (`windows.TimespecToNsec()`). This became clear when
moving the lines together:

```go
ctimespec := windows.NsecToTimespec(ctime.UnixNano())
c := windows.NsecToFiletime(windows.TimespecToNsec(ctimespec))
```

And looking at the Golang code, it looks like they're indeed the exact reverse:

```go
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }

func NsecToTimespec(nsec int64) (ts Timespec) {
    ts.Sec = nsec / 1e9
    ts.Nsec = nsec % 1e9
    return
}
```

While modifying this code, also renaming the `e` variable to a more common `err`.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-07 19:38:56 +02:00
Fu Wei
6fcfcf3a89
Merge pull request #7488 from samuelkarp/archive-dgst-validate
archive: validate digests before use
2022-10-07 15:22:14 +08:00
Samuel Karp
f9c9121e53
archive: validate digests before use
digest.Algorithm() and digest.Encoded() may panic for invalid digests.
Validate prior to calling those methods.

Signed-off-by: Samuel Karp <samuelkarp@google.com>
2022-10-06 19:37:31 -07:00
Phil Estes
74ab54c06d
Merge pull request #7482 from thaJeztah/bump_selinux
vendor: github.com/opencontainers/selinux v1.10.2
2022-10-05 20:31:30 -04:00
Derek McGowan
8162e044b7
Add long term stable release branches
Signed-off-by: Derek McGowan <derek@mcg.dev>
2022-10-05 15:00:23 -07:00
Sebastiaan van Stijn
e2d8f3859a
vendor: github.com/opencontainers/selinux v1.10.2
full diff: https://github.com/opencontainers/selinux/compare/v1.10.1...v1.10.2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-05 22:33:35 +02:00
Fu Wei
31f9d13f0c
Merge pull request #7477 from AdamKorcz/fuzz1
fuzzing: create structured tar bytes in archive fuzzer
2022-10-05 10:42:20 +08:00
Samuel Karp
62cc21959c
Merge pull request #7474 from thaJeztah/bump_go_1.19.2 2022-10-04 17:42:17 -07:00
AdamKorcz
011fca6ed8 fuzzing: create structured tar bytes in archive fuzzer
Signed-off-by: AdamKorcz <adam@adalogics.com>
2022-10-04 21:26:25 +01:00
Sebastiaan van Stijn
54f2b51215
Update to go 1.19.2 to address CVE-2022-2879, CVE-2022-2880, CVE-2022-41715
From the mailing list:

We have just released Go versions 1.19.2 and 1.18.7, minor point releases.

These minor releases include 3 security fixes following the security policy:

- archive/tar: unbounded memory consumption when reading headers

  Reader.Read did not set a limit on the maximum size of file headers.
  A maliciously crafted archive could cause Read to allocate unbounded
  amounts of memory, potentially causing resource exhaustion or panics.
  Reader.Read now limits the maximum size of header blocks to 1 MiB.

  Thanks to Adam Korczynski (ADA Logics) and OSS-Fuzz for reporting this issue.

  This is CVE-2022-2879 and Go issue https://go.dev/issue/54853.

- net/http/httputil: ReverseProxy should not forward unparseable query parameters

  Requests forwarded by ReverseProxy included the raw query parameters from the
  inbound request, including unparseable parameters rejected by net/http. This
  could permit query parameter smuggling when a Go proxy forwards a parameter
  with an unparseable value.

  ReverseProxy will now sanitize the query parameters in the forwarded query
  when the outbound request's Form field is set after the ReverseProxy.Director
  function returns, indicating that the proxy has parsed the query parameters.
  Proxies which do not parse query parameters continue to forward the original
  query parameters unchanged.

  Thanks to Gal Goldstein (Security Researcher, Oxeye) and
  Daniel Abeles (Head of Research, Oxeye) for reporting this issue.

  This is CVE-2022-2880 and Go issue https://go.dev/issue/54663.

- regexp/syntax: limit memory used by parsing regexps

  The parsed regexp representation is linear in the size of the input,
  but in some cases the constant factor can be as high as 40,000,
  making relatively small regexps consume much larger amounts of memory.

  Each regexp being parsed is now limited to a 256 MB memory footprint.
  Regular expressions whose representation would use more space than that
  are now rejected. Normal use of regular expressions is unaffected.

  Thanks to Adam Korczynski (ADA Logics) and OSS-Fuzz for reporting this issue.

  This is CVE-2022-41715 and Go issue https://go.dev/issue/55949.

View the release notes for more information: https://go.dev/doc/devel/release#go1.19.2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-04 20:58:06 +02:00
Maksym Pavlenko
bb45abaa2c
Merge pull request #7463 from KyleFrisbie/patch-1
use raw link to containerd.service config
2022-10-04 09:21:58 -07:00
Maksym Pavlenko
8abee9c8bb
Merge pull request #7466 from GabyCT/topic/fixkataurl
cri doc: Update kata containers reference
2022-10-03 11:58:52 -07:00
Gabriela Cervantes
f330ffd832 cri doc: Update kata containers reference
This PR updates the url for the kata containers reference about
how to use kata containers and containerd for untrusted workloads.

Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com>
2022-10-03 16:16:34 +00:00
Kyle L Frisbie
0119d43a41
use raw link to containerd.servic config
Referencing the raw link to the containerd.service may enhance the developer experience by enabling those following the docs to use the raw link directly to `wget` or `curl` the file without additional navigation.

Signed-off-by: Kyle L Frisbie <KyleFrisbie@users.noreply.github.com>
2022-10-02 14:36:59 -06:00
wanglei01
a59ecc50e3 CRI: implement Controller.Delete for SandboxAPI
Signed-off-by: WangLei <wllenyj@linux.alibaba.com>
2022-09-30 16:55:54 +08:00
Derek McGowan
1cc38f8df7
Merge pull request #5904 from qiutongs/ip-leakage-fix 2022-09-29 18:14:35 -07:00
Maksym Pavlenko
d71fbcf350
Merge pull request #7446 from dcantah/net-errclosed
Swap to net.ErrClosed checks for services
2022-09-29 10:55:55 -07:00
James Jenkins
9d18b57469 Modify WithDiscardUnpackedLayers
Modify the WithDiscardUnpackedLayers function such that it does not
require any parameters.

Signed-off-by: James Jenkins <James.Jenkins@ibm.com>
2022-09-29 10:24:45 -04:00
Daniel Canter
4333e6a6d6 Swap to net.ErrClosed checks for services
In Go 1.16 `net.ErrClosed` was exported, removing the need to check the
exact text of "use of closed network connection". The stdlib's net listeners
are all setup for this to be a reality, but on Windows containerd uses the
the go-winio projects named pipe implementation as the listener for services.
Before version 0.6.0 this project returned a different error named
`ErrPipeListenerClosed` for using a closed pipe, where this error was just
an `errors.New` with the same text as `net.ErrClosed`, so checking against
`net.ErrClosed` wasn't possible.

Starting in 0.6.0 go-winio has that error assigned to `net.ErrClosed` directly
so this *should* be alright to finally change.

Signed-off-by: Daniel Canter <dcanter@microsoft.com>
2022-09-28 18:20:12 -07:00
Phil Estes
7374e0a330
Merge pull request #7443 from dcantah/bump-winio-0.6
go.mod: Bump go-winio to v0.6.0
2022-09-28 23:02:49 +01:00
Samuel Karp
b7a8a54141
Merge pull request #6995 from akhilerm/retry-on-reset 2022-09-28 10:36:55 -07:00
Daniel Canter
acb2964d65 go.mod: Bump go-winio to v0.6.0
Some minor improvements, but biggest for here is ErrPipeListenerClosed
is no longer an errors.New where the string matches the text of the now
exported net.ErrClosed in the stdlib, but is just assigned to net.ErrClosed
directly. This should allow us to get rid of the string check for "use of closed
network connection" here now..

Signed-off-by: Daniel Canter <dcanter@microsoft.com>
2022-09-28 10:30:38 -07:00
Qiutong Song
4196fad027 Add integration tests with failpoint
Signed-off-by: Qiutong Song <songqt01@gmail.com>
2022-09-27 14:45:18 +00:00
Qiutong Song
4f4aad057d Persist container and sandbox if resource cleanup fails, like teardownPodNetwork
Signed-off-by: Qiutong Song <songqt01@gmail.com>
2022-09-27 14:38:41 +00:00
Samuel Karp
34d078e99f
Merge pull request #7192 from cpuguy83/test_summary 2022-09-26 15:28:33 -07:00
Maksym Pavlenko
5018b6aa01
Merge pull request #7430 from my-git9/benchmark-test
Fix missing close
2022-09-26 10:34:55 -07:00