Commit Graph

384 Commits

Author SHA1 Message Date
Fabiano Fidêncio
d4391d784d Merge pull request #1334 from clnperez/ppc64le-protoc
agent: README update to install protoc for ppc64le
2021-02-06 01:08:42 +01:00
Christy Norman
11680efe4e agent: README update to install protoc for ppc64le
Add a bit to the agent README about installing protoc manually for Power (ppc64le)

Fixes: #1068

Signed-off-by: Christy Norman <christy@linux.vnet.ibm.com>
2021-02-04 17:03:31 +00:00
Tim Zhang
f16ab49b5b agent: fix non_camel_case_types lint and stop hiding the warning
Fixes: #1359

Signed-off-by: Tim Zhang <tim@hyper.sh>
2021-02-04 21:36:21 +08:00
Tim Zhang
8ffe4d6748 agent: fix unused_parens lint and stop hiding the warning
Fixes: #1359

Signed-off-by: Tim Zhang <tim@hyper.sh>
2021-02-04 21:24:04 +08:00
Tim Zhang
f70ca69d0d agent: remove #![allow(unused_unsafe)]
Fixes: #1359

Signed-off-by: Tim Zhang <tim@hyper.sh>
2021-02-04 21:21:48 +08:00
Tim Zhang
e28bf7a59d agent: fix dead_code lint
Fixes: #1359

Signed-off-by: Tim Zhang <tim@hyper.sh>
2021-02-04 21:18:45 +08:00
Tim Zhang
05da23acb7 agent: fix non_snake_case lint and remove ![allow(non_snake_case)]
Fixes: #1359

Signed-off-by: Tim Zhang <tim@hyper.sh>
2021-02-04 21:18:37 +08:00
Chelsea Mafrica
38b5a43267 Merge pull request #1318 from jongwu/acpi
arm64: enable acpi for qemu/virt.
2021-02-03 16:37:49 -08:00
Tim Zhang
254b98dd2f rustjail: fix unit test test_process
test_process has a assertion that waitpid(-1) will fail
because there is no child process in most cases.

But if there is any child process forked by other unit test,
the test test_process will fail.

Because waitpid(-1) will wait for any child process including the
process created by other unit tests.

Signed-off-by: Tim Zhang <tim@hyper.sh>
2021-02-03 22:27:50 +08:00
Tim Zhang
b25575b430 agent: remove crate signal-hook which are no longer used
Had replaced by tokio::signal.

Signed-off-by: Tim Zhang <tim@hyper.sh>
2021-02-03 18:30:18 +08:00
Tim Zhang
b1880b3e80 rustjail: remove unnecessary #[async_trait]
Remove unnecessary #[async_trait]

Signed-off-by: Tim Zhang <tim@hyper.sh>
2021-02-03 18:30:15 +08:00
Tim Zhang
83e9414f4f rustjail: add unittest test_execute_hook
use xargs to test execute_hook.

Signed-off-by: Tim Zhang <tim@hyper.sh>
2021-02-03 18:30:15 +08:00
Tim Zhang
d2041001ed rustjail: close stdin in execute_hook after it was sent
So that hook program could receive EOF.

Signed-off-by: Tim Zhang <tim@hyper.sh>
2021-02-03 18:30:15 +08:00
Tim Zhang
bb08131151 rustjail: fix fork/child in execute_hook
Tokio in fork child does not work well as it easily deadlocks.
https://github.com/tokio-rs/tokio/issues/1541

Fixes: #1348

Signed-off-by: Tim Zhang <tim@hyper.sh>
2021-02-03 18:30:11 +08:00
Jianyong Wu
b7a1f752c0 arm64: enable acpi for qemu/virt.
acpi is enabled for kata 1.x, port and rebase code for 2.x
including:
runtime: enable pflash;
agent: add acpi support for pci bus path;
packaging: enable CONFIG_RTC_DRV_EFI;

Fixes: #1317
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
2021-01-29 22:12:43 +08:00
Fupan Li
5e39980858 Merge pull request #1216 from houstar/2.0-dev
agent: add secure_join to prevent softlink escape
2021-01-28 10:41:02 +08:00
fupan.lfp
448771f53d rustjail: fix the issue of container's cgroup root path
We should create the container's cgroup under the system's
cgroup default path such as "/sys/fs/cgroup/<sub system>",
instead of under the kata-agnet's process's cgroup path,
which would under the systemd's cgroup such as
"/sys/fs/cgroup/systemd/system.slice/kata-agent.service"

Fixes: #1319

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
2021-01-27 15:38:45 +08:00
Qingyuan Hou
e111093b83 agent: add secure_join to prevent softlink escape
This patch fixed the security issue if the container images has
unsafe symlink to the container rootfs and hackers can be exploit
this symlink to hack the guest system. e.g. make directory or files
on guest.

CVE-2015-3629

Fixes: #1219

Signed-off-by: Qingyuan Hou <qingyuan.hou@linux.alibaba.com>
2021-01-26 23:51:23 +08:00
Fupan Li
06d1dd2220 Merge pull request #1297 from mxpv/netlink
Migrate to rtnetlink
2021-01-22 09:39:17 +08:00
Tim Zhang
14a63cce22 agent: Add underscore for constants
To make them follow the rust convention and easier to read.

Fixes: #1235

Signed-off-by: Tim Zhang <tim@hyper.sh>
2021-01-20 17:12:29 +08:00
Maksym Pavlenko
fa93831f66 agent: Address linter and tests
- Fix clippy complains
- Use #[tokio::test] for async tests
- Improve IPv6 check

Fixes: #1294

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-01-19 20:23:11 -08:00
Maksym Pavlenko
96762ab7ab agent: Remove old netlink crate
Cleans up unused code.

Fixes: #1294

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-01-19 09:58:50 -08:00
Maksym Pavlenko
33367be4c7 agent: Integrate netlink
This patch integrates new netlink module routines with the agent (mainly
replaces calls to old netlink module with the new one).

Fixes: #1294

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-01-19 09:48:51 -08:00
Maksym Pavlenko
23f3aefa1d agent: Implement new netlink module
This PR adds new netlink module (based on `rtnetlink` crate), so we don’t have to
write a low level code to interact with netlink sockets, but use a high level API.

As a side effect, `rtnetlink` crate got full IPv6 support, so it fixes #1171

Fixes: #1294

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-01-19 09:44:50 -08:00
Julio Montes
12551de8a2 agent: implement NVDIMM/PMEM block driver
Support pmem-csi[1] k8s pluging, unlike SCSI and virtio devices,
NVDIMM/PMEM devices support DAX, improving IO Read and Write
operations.

fixes #1289

Signed-off-by: Julio Montes <julio.montes@intel.com>

[1]: https://github.com/intel/pmem-csi
2021-01-19 09:28:41 -06:00
fupan.lfp
6abb1be724 rustjail: fix the issue of missing destroy contaienr cgroups
In the container's destroy method, it should destroy
the container's cgroups.

Fixes: #1291

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
2021-01-19 16:00:41 +08:00
Tim Zhang
fe67f57c46 agent: set edition = "2018" in .rustfmt.toml to fix rustfmt about async fn
Got:
find . -type f -name "*.rs"  | egrep -v "target/|grpc-rs/|protocols/" | xargs rustfmt --check

error[E0670]: `async fn` is not permitted in the 2015 edition

This commit fixes this issue.

Signed-off-by: Tim Zhang <tim@hyper.sh>
2021-01-18 15:38:19 +08:00
Maksym Pavlenko
37e285bf7b agent: Make debug console async
Fixes: #1209

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-01-18 15:38:19 +08:00
Tim Zhang
f3bd439465 agent: fix tests for async functions
Use tokio::test to test async functions.

Signed-off-by: Tim Zhang <tim@hyper.sh>
2021-01-18 15:38:19 +08:00
Tim Zhang
9f79ddb9df agent: use tokio Notify instead of epoll to fix #1160
Fixes: #1160

Signed-off-by: Tim Zhang <tim@hyper.sh>
2021-01-18 15:38:19 +08:00
Tim Zhang
332fa4c65f agent: switch to async runtime
Fixes: #1209

Signed-off-by: Tim Zhang <tim@hyper.sh>
2021-01-18 15:38:15 +08:00
Maksym Pavlenko
5561755e3c agent: Initial switch to async runtime
This commit includes minimal changes in order to switch to Tokio:
- Update protocol crate to generate async server code
- Adds async entry point to the Agent
- Updates agent services signatures in rpc.rs

Fixes: #1209

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-01-11 16:50:53 +08:00
GabyCT
a6d52d3da1 Merge pull request #1208 from GabyCT/topic/addgithu
github: Add github actions
2021-01-08 14:27:19 -06:00
Archana Shinde
ebd9fcc2c3 actions: Run static checks before make agent
Run static checks prior to building the agent.Checks
fail if run after since the compilation process
produces new rust code.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2021-01-08 11:04:54 -06:00
Fabiano Fidêncio
31519333a0 Merge pull request #1221 from wainersm/agent_improve
Agent: return error on trying to persist a pid namespace and minor improvements
2021-01-08 14:58:15 +01:00
Fabiano Fidêncio
dcfbf03781 Merge pull request #1229 from snir911/sysctl_fix
rustjail: allow network sysctls
2021-01-08 14:56:18 +01:00
Peng Tao
855fe10bfd Merge pull request #1234 from lifupan/2.0-dev-fix-read
rustjail: fix the issue of sync read
2021-01-08 14:03:46 +08:00
fupan.lfp
0d3736d5c5 rustjail: fix the issue of sync read
It should check the read count and return an
error if read count didn't match the expected
number.

Fixes: #1233

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
2021-01-07 17:21:22 +08:00
fupan.lfp
0dc02f6dd3 rustjail: fix the issue of bind mount /dev
In case the container rootfs's /dev was overrided
by binding mount from another directory, then there's
no need to create the default devices nodes and symlinks
in /dev.

Fixes: #692

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
2021-01-07 16:12:25 +08:00
Snir Sheriber
894fa42a57 rustjail: allow network sysctls
The network ns is shared with the guest skip looking for it
in the spec

Fixes: #1228
Signed-off-by: Snir Sheriber <ssheribe@redhat.com>
2021-01-05 17:12:42 +02:00
Tim Zhang
91c6ba74fa Merge pull request #1225 from Tim-Zhang/update-cgroup-to-0.2.0
agent: upgrade cgroups to 0.2.0
2021-01-05 19:50:05 +08:00
Tim Zhang
d4cd255485 agent: Avoid container stats panic caused by cgroup controller non-exist
Return SingularPtrField::none() instead of panic when getting stats
from cgroup failed caused by cgroup controller missing.

Signed-off-by: Tim Zhang <tim@hyper.sh>
2021-01-05 11:35:41 +08:00
Tim Zhang
157e055fdd agent: upgrade crate cgroups to 0.2.0
Fixes: #1224

35ecd6f (origin/change-name, change-name) Update readme
eb6577e Change package name to cgroups-rs
8f6a7e0 Merge pull request #19 from Tim-Zhang/0.2.0
9baa065 (origin/0.2.0, 0.2.0) release: v0.2.0
e160df0 Make read_i64_from private and merge read_str_from to its caller
e1e05d3 Make new_with_relative_paths=new and load_with_relative_paths=new in v2
a89f4a0 Support set notify_on_release & release_agent
61a0957 Fix set_swappiness in cgroup v2
0592045 Ignore kmem in cgroup v2
c254fff Update readme
438d774 Fix test
42ee1ba Make Cgroup can be stored in struct
b6bb5ae docs: Hide Re-exports
d2882b1 Print cause when println!("{}")
abcb5ed Add more logs for create_dir error in controller.create
1f188be Detect subsystems and get root from /proc/self/mountinfo
fbd7164 Fix warnings in tests
f342254 Remove Box wrap of Cgroup.hire
cd998f3 Do not place cgroup under relative path read from cgroup by default
1ac76b6 Make function find_v1_mount pub
121f78d Expose deletion error
0f76570 Avoid exception caused by cgroup writeback feature
10650e2 Update tests to adapt new type of fields in resource
567cdb4 Use Option as resource fields, remove the update switch: update_values
0c18b08 Support customized attributes for CpuController and MemController
ca610bb add add_task_by_tgid

Signed-off-by: Tim Zhang <tim@hyper.sh>
2021-01-05 11:35:34 +08:00
David Gibson
e3ec1d509e agent: Simplify .or_else() to .or()
get_bool_value() in src/agent/src/config.rs includes a Result::or_else()
call with a trivial closure which can be replaced by a Result::or.  This
removes a clippy warning.

fixes #1201

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-01-05 12:54:21 +11:00
Wainer dos Santos Moschetta
14e7042cf6 agent: Clean up commented use declarations
There are some commented use declarations, removed them all.

Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
2020-12-29 09:16:29 -05:00
Wainer dos Santos Moschetta
5fe5b3212f agent: Fix temp prefix on Namespace::test_setup_persistent_ns
Wrong prefix on the created temp directory on the test_setup_persistent_ns
for uts namesmpace type test.

Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
2020-12-29 09:16:29 -05:00
Wainer dos Santos Moschetta
3a891d4e8f agent: Return error on trying to persist a pid namespace
An pid namespace cannot be persisted, so add a check-and-error on
Namespace::setup() for handling that case.

Fixes #1220

Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
2020-12-29 09:16:26 -05:00
Liu Jiang
b366af9358 jail: add more test cases for validator
Fixes: #1214

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2020-12-24 20:17:06 +08:00
Liu Jiang
d38a5d3fcf jail/validator: introduce helpers to reduce duplicated code
Fixes: #1214

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2020-12-24 19:02:31 +08:00
Liu Jiang
76ad32136f jail/validator: avoid unwrap() for safety
Explicitly return error codes instead of unwrap().

Fixes: #1214

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2020-12-24 19:02:13 +08:00