Linux NFS development
 help / color / mirror / Atom feed
From: Sander Smeenk <ssmeenk@freshdot.net>
To: linux-nfs@vger.kernel.org
Subject: CAP(abilities) and NFS mounted storage
Date: Tue, 13 Oct 2015 14:21:28 +0200	[thread overview]
Message-ID: <20151013122128.GD10632@dot.dmz.freshdot.net> (raw)

Hi,

I'm struggling with a permission issue involving NFS-mounted storage and
a certain set of capabilities set by cap_set_flags(). The behaviour
differs for local storage versus NFS mounted storage.

I have this structure on local storage (spinning disks):
| # namei -l /opt/home/sites/t/test/dir/structure/.htaccess
| f: /opt/home/sites/t/test/dir/structure/.htaccess
| drwxr-xr-x root      root                 /
| drwxr-xr-x root      root                 opt
| drwxr-x--x root      root                 home
| drwx--x--x root      root                 sites
| drwx--x--x root      root                 t
| drwx------ http-test http-linux_http-test test
| drwx--x--x http-test http-linux_http-test dir
| drwx------ http-test http-linux_http-test structure
| -rw------- http-test http-linux_http-test .htaccess

And this same structure on NFS-mounted storage:
| # namei -l /mnt/home/sites/t/test/dir/structure/.htaccess
| f: /mnt/home/sites/t/test/dir/structure/.htaccess
| drwxr-xr-x root      root                 /
| drwxr-xr-x root      root                 mnt
| drwxr-x--x root      root                 home
| drwx--x--x root      root                 sites
| drwx--x--x root      root                 t
| drwx------ http-test http-linux_http-test test
| drwx--x--x http-test http-linux_http-test dir
| drwx------ http-test http-linux_http-test structure
| -rw------- http-test http-linux_http-test .htaccess

The NFS server is a NetApp filer (-sec=sys,rw=clientip,root=clientip).
I tried this with a Linux server too (rw,no_root_squash,no_subtree_check).
The client is always a Linux machine (rw,vers=3,tcp,bg).

I made a little C program to illustrate the issue. It drops privileges
to www-data and tries to access the file specified with a certain set of
capabilties[*].

This works for local storage, fails on NFS:

LOCAL:
| # ./capset /opt/home/sites/t/test/dir/structure/.htaccess
| euid:33 uid:33 egid:33 gid:33
| Process capabilities: = cap_dac_read_search,cap_setgid,cap_setuid,cap_sys_nice+ep;
| Access: success!

NFS:
| # ./capset /mnt/home/sites/t/test/dir/structure/.htaccess
| euid:33 uid:33 egid:33 gid:33
| Process capabilities: = cap_dac_read_search,cap_setgid,cap_setuid,cap_sys_nice+ep;
| Access: error (13): Permission denied

The source for capset can be seen pasted at https://8n1.org/10831/12f0
Lines >=42

I've experimented with different capabilties, but CAP_DAC_OVERRIDE is
not enough. I'd very much like to hear if it is possible for this to
work on NFS like it does on local storage.

Any ideas? 

Thanks in advance.
-Sndr.

[*] This issue popped up since Apache module 'mpm_itk' started using
libcap capabilties to further enhance the security. The capabilties set
was taken from mpm_itk source to 'prove the point' w/o the entire Apache
setup. 
-- 
| I wish i was a glow worm, a glow worm's never glum.
| How can you be unhappy when the sun shines out your bum!
| 4096R/20CC6CD2 - 6D40 1A20 B9AA 87D4 84C7  FBD6 F3A9 9442 20CC 6CD2

             reply	other threads:[~2015-10-13 12:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-13 12:21 Sander Smeenk [this message]
2015-10-13 13:33 ` CAP(abilities) and NFS mounted storage Trond Myklebust
2015-10-13 14:34   ` Sander Smeenk
2015-10-13 15:02     ` Olga Kornievskaia
2015-10-13 15:13       ` Trond Myklebust
2015-10-13 17:59         ` Sander Smeenk
2015-10-13 17:52       ` Sander Smeenk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151013122128.GD10632@dot.dmz.freshdot.net \
    --to=ssmeenk@freshdot.net \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox