Skip to content

[ws-daemon] mknod /dev/fuse as S_IFCHR to consider major:minor #4594

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

Merged
merged 2 commits into from
Jun 25, 2021

Conversation

fntlnz
Copy link
Contributor

@fntlnz fntlnz commented Jun 23, 2021

Doing a mount with fuse is broken because the fuse device inside the workspace is not specifying the device type.

Actual

gitpod ~ $ ls -la /dev/fuse
-rw-rw-rw- 1 root root 0 Jun 23 09:42 /dev/fuse

Expected

ls -la /dev/fuse
crw-rw-rw- 1 root root 10, 229 Jun 23 14:06 /dev/fuse

Note how on the actual one we miss the device type c and the actual mkdev maj:min for this reason.

@fntlnz fntlnz requested a review from csweichel June 23, 2021 18:06
@fntlnz
Copy link
Contributor Author

fntlnz commented Jun 23, 2021

Ok one problem is solved with this one.

sudo sshfs -odebug,sshfs_debug,loglevel=debug -p 23001 [email protected]:/workspace /tmp/workspace
SSHFS version 2.10.0
fuse: failed to open /dev/fuse: Operation not permitted

Now there's an issue with uid/gid mappings on the device.

ls -la /dev/fuse
crw-rw-rw- 1 nobody nogroup 10, 229 Jun 23 18:09 /dev/fuse

@csweichel
Copy link
Contributor

csweichel commented Jun 23, 2021

Love it. I took the liberty and pushed a commit to your branch that fixes the ownership issue.

image

Update:
Actually I'm not sure the chown fixes anything here. While trying to use /dev/fuse in the workspace openat fails.

openat(AT_FDCWD, "/dev/fuse", O_RDWR)   = -1 EPERM (Operation not permitted)

@csweichel
Copy link
Contributor

csweichel commented Jun 24, 2021

/werft run

👍 started the job as gitpod-build-fix-fuse-mknod.2

@fntlnz
Copy link
Contributor Author

fntlnz commented Jun 24, 2021

The permission issue now seems to be related to mount_capable

from fs/super.c

bool mount_capable(struct fs_context *fc)
{
	if (!(fc->fs_type->fs_flags & FS_USERNS_MOUNT))
		return capable(CAP_SYS_ADMIN);
	else
		return ns_capable(fc->user_ns, CAP_SYS_ADMIN);
}

However, it looks like the fuse filesystem on kenrnel 5.4.0-1033 and 5.4.0-1030 is

static struct file_system_type fuse_fs_type = {
	.owner		= THIS_MODULE,
	.name		= "fuse",
	.fs_flags	= FS_HAS_SUBTYPE | FS_USERNS_MOUNT,
	.init_fs_context = fuse_init_fs_context,
	.parameters	= &fuse_fs_parameters,
	.kill_sb	= fuse_kill_sb_anon,
};

It's done in that way because we use user namespaces.

So still investigating.

@fntlnz
Copy link
Contributor Author

fntlnz commented Jun 24, 2021

Looks like mounting in the unprivileged userns works correctly as I'm able to do that accessing the namespace using nsenter.

@fntlnz fntlnz force-pushed the fix/fuse-mknod branch 2 times, most recently from 941f434 to 0eaf297 Compare June 24, 2021 16:35
@fntlnz
Copy link
Contributor Author

fntlnz commented Jun 25, 2021

Let's merge this change on its own since the purpose of this PR is fulfilled.
I'll continue investigating the permissions issue.

@fntlnz fntlnz merged commit f70c742 into main Jun 25, 2021
@fntlnz fntlnz deleted the fix/fuse-mknod branch June 25, 2021 09:02
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