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

Incorrect /opt mount permission on 2605.8.0 on AWS #279

Closed
ghost opened this issue Nov 19, 2020 · 6 comments · Fixed by flatcar/baselayout#8
Closed

Incorrect /opt mount permission on 2605.8.0 on AWS #279

ghost opened this issue Nov 19, 2020 · 6 comments · Fixed by flatcar/baselayout#8

Comments

@ghost
Copy link

ghost commented Nov 19, 2020

Description

We updated our AWS EC2 Kubernetes worker nodes to the latest AMI version, ami-006c88b6ca69f7811, which is version 2605.8.0. Our weave CNI plugin was not loading. When looking at the permissions of /opt we found it to be 711. Our weave plugin is expecting to reside in /opt/cni/bin

drwx--x--x. 3 root root 4096 Nov 19 21:18 opt

We reverted back to 2512.2.1 and opt is 755

drwxr-xr-x. 4 root root 4096 Nov 19 22:05 /opt

Impact

Kubernetes pods fail to launch due to weave not coming up

Environment and steps to reproduce

  1. Set-up:

AWS: us-east-1
AMI: ami-006c88b6ca69f7811

  1. Task:

Spin up EC2 instance on AMI ami-006c88b6ca69f7811

  1. Action(s):

Spin up EC2 instance on AMI ami-006c88b6ca69f7811

  1. Error:

/opt has incorrect permissions of 711

Expected behavior

/opt permissions should be 755

Additional information

N/A

@ghost
Copy link
Author

ghost commented Nov 19, 2020

Could this problem be why #278 exists?

@pothos
Copy link
Member

pothos commented Nov 20, 2020

Interesting, this folder is not created by Flatcar because it doesn't exist by default nor has a systemd-tmpfile directive to be created. In #176 you can see some ways how to find the process that does the modification. Can you try to find it out?

@zytrik
Copy link

zytrik commented Nov 20, 2020

I created a new EC2 instance with the referenced AMI with no userdata at all. @pothos to your point it looks like /opt is not part of the base image, it doesn't exist immediately on start up. However, without starting or placing any special software, after a minute or so the following directory tree appeared:

sudo ls -lRa /opt/
/opt/:
total 20
drwx--x--x.  3 root root 4096 Nov 20 15:39 .
drwxr-xr-x. 18 root root 4096 Nov 20 15:39 ..
drwx--x--x.  4 root root 4096 Nov 20 15:39 containerd

/opt/containerd:
total 32
drwx--x--x. 4 root root 4096 Nov 20 15:39 .
drwx--x--x. 3 root root 4096 Nov 20 15:39 ..
drwx--x--x. 2 root root 4096 Nov 20 15:39 bin
drwx--x--x. 2 root root 4096 Nov 20 15:39 lib

/opt/containerd/bin:
total 16
drwx--x--x. 2 root root 4096 Nov 20 15:39 .
drwx--x--x. 4 root root 4096 Nov 20 15:39 ..

/opt/containerd/lib:
total 16
drwx--x--x. 2 root root 4096 Nov 20 15:39 .
drwx--x--x. 4 root root 4096 Nov 20 15:39 ..

I suspect it's being triggered by the initial dockerd or containerd startup, but it's certainly related to the flatcar base configuration.

What's not too clear is what has changed in the last couple releases. Was there an existing /opt directory with appropriate permissions before? Are dockerd's default directory creation permissions different for some reason?

@zytrik
Copy link

zytrik commented Nov 20, 2020

Shutting down dockerd and containerd then starting them up individually, I was able to isolate the containerd startup as the action causing /opt to be created. This is approximately discussed here.

Workarounds aside, what's the best way to get back to having sane permissions on /opt by default? Does containerd need to be more thoughtful? Or do we need to have the directory back in the base image so we don't leave permissions up to whatever gets there first?

@pothos
Copy link
Member

pothos commented Nov 23, 2020

Thanks for tracking it down. I think containerd shouldn't create /opt with restrictive permissions but since it doesn't change existing permissions we can work around this by creating a systemd tmpfile directive.
Until it is shipped you can create your own and reboot:

$ cat /etc/tmpfiles.d/opt.conf
d   /opt                    0755    root    root    -   -

It will also adjust existing wrong permissions.

pothos added a commit to flatcar/baselayout that referenced this issue Nov 23, 2020
The well-known path /opt/bin is used in PATH as place for extra
binaries and /opt in general is a place for additional software.
Containerd creates /opt on runtime if it is not present but uses
restrictive permissions, causing non-root programs to fail accessing,
e.g., /opt/bin.
Add tmpfile directives for /opt and /opt/bin to ensure that they
have the correct permissions.

Fixes flatcar/Flatcar#279
@pothos
Copy link
Member

pothos commented Nov 24, 2020

The fix will be part of the next releases in all channels, e.g., > 2605.8.0 for Stable.

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 a pull request may close this issue.

2 participants