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

mkdirall regression when default ACL is set #4408

Closed
lifubang opened this issue Sep 21, 2024 · 9 comments · Fixed by #4421
Closed

mkdirall regression when default ACL is set #4408

lifubang opened this issue Sep 21, 2024 · 9 comments · Fixed by #4421
Milestone

Comments

@lifubang
Copy link
Member

If we use a bundle dir in tmp fs to start a container, it will fail when we mount a dir to the container.
The error msg is:

ERRO[0000] runc run failed: unable to start container process: error during container init: error mounting "/opt" to rootfs at "/foo": create mountpoint for /foo mount: possible attack detected: newly created directory "/tmp/ubuntu/rootfs/foo" has incorrect mode 0o40754 (expected 0o40755)

The /tmp mount options:

mount | grep /tmp
/dev/sda1 on /tmp type ext4 (rw,relatime)
@lifubang
Copy link
Member Author

@cyphar PTAL

@cyphar
Copy link
Member

cyphar commented Sep 21, 2024

Hmm, I can't reproduce this. Can you share the config you used? What is your umask? If you manually do mkdir -p in your tmpfs, what modes do you get?

We could probably loosen the checks to permit the created directory to be more strict than what we requested (i.e. the mode has fewer bits set than the expected set) but I'd like to know where the issue is coming from.

@cyphar
Copy link
Member

cyphar commented Sep 21, 2024

Though it should be noted that if we mkdirall on vfat you will get errors either way. Maybe we should just skip checking the mode -- the owner checks are probably the main thing we care about in practice.

@lifubang
Copy link
Member Author

You can use GitHub codespace online webide, then run ‘bats . /tests/integration/run.bats’, it can reproduce easily.

@kolyshkin
Copy link
Contributor

You can use GitHub codespace online webide, then run ‘bats . /tests/integration/run.bats’, it can reproduce easily.

Reproduced.

It's not tmpfs in there, it's ext4.

$ sudo bats tests/integration/run.bats 
...
 ✗ runc run [execve error]
   (in test file tests/integration/run.bats, line 276)
     `[[ ${lines[0]} = "exec /run.sh: no such file or directory" ]]' failed
   runc spec (status=0):
   
   runc run test_hello (status=1):
   time="2024-09-22T19:23:04Z" level=error msg="runc run failed: unable to start container process: error during container init: error mounting \"proc\" to rootfs at \"/proc\": possible attack detected: newly created directory \"/tmp/bats-run-Uf8Lsc/runc.YGDOUv/bundle/rootfs/proc\" has incorrect mode 0o40754 (expected 0o40755)"
...
$ umask
0022
$ grep /tmp /proc/self/mountinfo 
762 753 8:1 /containerTmp /tmp rw,relatime - ext4 /dev/sda1 rw
$ ls -ld /tmp
drwxr-xrwt+ 4 root root 4096 Sep 22 19:29 /tmp
$ lsattr -d /tmp
--------------e----- /tmp
$ getfacl  /tmp
getfacl: Removing leading '/' from absolute path names
# file: tmp
# owner: root
# group: root
# flags: --t
user::rwx
group::r-x
other::rwx
default:user::rwx
default:group::r-x
default:other::rw-

I believe this is because of default:other::rw- ACL entry. If I remove it, tests run just fine:

$ sudo setfacl -k /tmp
$ sudo bats tests/integration/run.bats 
run.bats
 ✓ runc run
 ✓ runc run --keep
 ✓ runc run --keep (check cgroup exists)
 ✓ runc run [hostname domainname]
 ✓ runc run with tmpfs
 ✓ runc run with tmpfs perms
 ✓ RUNC_DMZ=true runc run [runc-dmz]
 ✓ RUNC_DMZ=true runc run [cap_sys_ptrace -> /proc/self/exe clone]
 ✓ runc run [/proc/self/exe clone]
 ✓ runc run [joining existing container namespaces]
 ✓ RUNC_DMZ=true runc run [exec error]
 ✓ runc run [execve error]

12 tests, 0 failures

@kolyshkin
Copy link
Contributor

To reproduce locally, run sudo setfacl -m default:other::rw- /tmp

@kolyshkin kolyshkin changed the title mkdirall regression on tmp fs mkdirall regression when default ACL is set Sep 22, 2024
@cyphar
Copy link
Member

cyphar commented Sep 22, 2024

Grr, ACLs... Yeah, we should probably just skip the mode checks given that this is the second bug we've had. I'm currently travelling, I'll write a patch next week.

@kolyshkin
Copy link
Contributor

We could probably loosen the checks to permit the created directory to be more strict than what we requested (i.e. the mode has fewer bits set than the expected set)

Yes, I think this is the way to go

Maybe we should just skip checking the mode

Or downgrade it to a warning.

@cyphar
Copy link
Member

cyphar commented Sep 24, 2024

We can also drop the umask logic entirely if we only care if there are extra bits set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants