Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: do not set protobuf has_* field too early #2555

Open
wants to merge 1 commit into
base: criu-dev
Choose a base branch
from

Conversation

adrianreber
Copy link
Member

For two cases libcriu was setting the RPC protobuf field has_* before checking if the given parameter is valid. This can lead to situations, if the caller doesn't check the return value, that we pass as RPC struct to CRIU which has the has_* protobuf field set to true, but does not have a verified value (or non at all) set for the actual RPC entry.

Detected via containers/crun#1627

For two cases libcriu was setting the RPC protobuf field `has_*` before
checking if the given parameter is valid. This can lead to situations,
if the caller doesn't check the return value, that we pass as RPC struct
to CRIU which has the `has_*` protobuf field set to true, but does not
have a verified value (or non at all) set for the actual RPC entry.

Signed-off-by: Adrian Reber <[email protected]>
if (method == CRIU_NETWORK_LOCK_IPTABLES || method == CRIU_NETWORK_LOCK_NFTABLES || method == CRIU_NETWORK_LOCK_SKIP) {
opts->rpc->has_network_lock = true;

Choose a reason for hiding this comment

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

dropping an (unrelated) comment here, because I can't on line 1875.

Some other APIs return a -errno return code on errors, does the -1 here must be treated differently (I guess it doesn't mean EPERM)? Should it be changed to -EINVAL?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. Not sure if this, however, would count as an API break. It isn't very consistent, that is true.

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