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

Access control in Assise #17

Open
cmolder opened this issue Nov 17, 2021 · 2 comments
Open

Access control in Assise #17

cmolder opened this issue Nov 17, 2021 · 2 comments

Comments

@cmolder
Copy link
Contributor

cmolder commented Nov 17, 2021

Hi,

We're working on implementing access control using Assise leases. We have a proposed methodology, but have a few questions about the code.

Before presenting the questions, here's our current proposed methodology:

  • Each LibFS registers with a SharedFS upon initialization. We would add an extra step where the LibFS shares its owner and the owner's primary group with the local SharedFS.
    • The local SharedFS would track these values in a map (PID to owner and group).
    • The map could be backed up to a private file for crash consistency.
    • Any LibFS requests must first go through the local SharedFS, so if we need to forward this information to another SharedFS, any forwarded requests would also include this owner + group information.
  • The SharedFS holding the requested file/directory will make the lease decision. Three new fields in the inode, uid, gid, and perms, will be added.
    • uid and gid match the process's class (user, group, other).
    • The type of lease (read/write) will determine which set of permissions in perms to check against.
  • If the lease is granted, it will behave identically to current Assise, regardless of whether the permissions of the file/directory change.
    • If a process maliciously writes to its log when it's denied permissions (or has no lease in general), digesting those log entries should fail because the process didn't have the lease at that time.

Here's our questions:

  1. Do we also need to implement execute permissions?
  2. Read leases don't seem to be implemented in KernFS's modify_lease_state function.
    • Do we need to implement these?
    • Could we instead just do a naive check and return something like -EACCES if the permissions check doesn't work out?
  3. acquire_lease is commented out in namex, which is presumably where Assise goes to acquire leases.
    • Is this supposed to be left commented out?
    • If so, where does LibFS guide POSIX calls to acquire read/write leases?
  4. We propose to have SharedFSes track the owner / the owner's primary group of each local LibFS.
    • We can't find any existing data structure in libfs/src/mkfs/mfks.c or kernfs/fs.c that explicitly sets up relationships between LibFSes and KernFSes.
    • Can we assume that these relationships are registered statically?
    • If so, how can we send process owner + group information to SharedFSes when a LibFS starts up? Is this a secure procedure, or should we assume processes can lie about their owner?
  5. Should there be any changes to the digestion of logs?
    • If our permission checks are correct, and digestion rejects writes from processes that lack(ed) the write leases at the time of their writes, then the answer should be no.
    • Are there any edge cases where lease history is unused for checking the validity of log writes?
  6. How can we run libfs as a non-privileged user?
    • For example, running ./run.sh iotest sw 2G 4K 1 (no sudo) yields the following error. It looks like something in the shim requires extra privileges.
    • Would it be okay to spoof LibFS owners / groups in our tests, if this is something we can't avoid?
dev-dax engine is initialized: dev_path /dev/dax0.0 size 4096 MB
fetching node's IP address..
Process pid is 19681
ip address on interface 'lo' is 127.0.0.1
cluster settings:
--- node 0 - ip:127.0.0.1
Connecting to KernFS instance 0 [ip: 127.0.0.1]
[Local-Client] Creating connection (pid:19681, app_type:0, status:pending) to 127.0.0.1:12345 on sockfd 0
[Local-Client] Creating connection (pid:19681, app_type:1, status:pending) to 127.0.0.1:12345 on sockfd 1
[Local-Client] Creating connection (pid:19681, app_type:2, status:pending) to 127.0.0.1:12345 on sockfd 2
In thread
In thread
In thread
SEND --> MSG_INIT [pid 0|19681]
RECV <-- MSG_SHM [paths: /shm_recv_0|/shm_send_0]
shm_open failed.
: Permission denied
  1. When running the lease test, e.g. sudo ./run.sh lease_test c 1 1, we cannot run the test as we get an error, for example: incorrect fd -2: file /mlfs/fileset/f0_7618.
    • Other tests, like many_files_test, work fine.
    • We see similar errors when running sudo ./run_lease_test_example.sh in the output logs. What can we do to solve this?

Thanks for your help!

@simpeter
Copy link

simpeter commented Nov 18, 2021 via email

wreda added a commit that referenced this issue Nov 19, 2021
@wreda
Copy link
Contributor

wreda commented Nov 19, 2021

acquire_lease is commented out in namex, which is presumably where Assise goes to acquire leases.
Is this supposed to be left commented out?
If so, where does LibFS guide POSIX calls to acquire read/write leases?

Write leases are acquired at src/filesystem/file.c in 'mlfs_object_create()'. The lines you found are specifically for read leases, and are commented temporarily. They will be re-enabled in the future once I get a chance to properly test them.

How can we run libfs as a non-privileged user?
For example, running ./run.sh iotest sw 2G 4K 1 (no sudo) yields the following error. It looks like something in the shim requires extra privileges.
Would it be okay to spoof LibFS owners / groups in our tests, if this is something we can't avoid?

The permissions issue you're encountering is indeed related to the shm files, which are created at this line. One quick workaround is to change the permissions of these files manually. On ubuntu, running sudo chmod 777 /dev/shm/shm_* should do the trick. I'll see if I can introduce a proper patch for this in the future.

When running the lease test, e.g. sudo ./run.sh lease_test c 1 1, we cannot run the test as we get an error, for example: incorrect fd -2: file /mlfs/fileset/f0_7618.
Other tests, like many_files_test, work fine.
We see similar errors when running sudo ./run_lease_test_example.sh in the output logs. What can we do to solve this?

I have pushed a hotfix for the 'lease_test' benchmark. It should run to completion now.

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

No branches or pull requests

3 participants