Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1443105
| From | Miklos Szeredi <miklos@szeredi.hu> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 9/9] overlayfs: Append MAY_READ when diluting write checks |
| Date | 2016-07-14 08:50 +0200 |
| Message-ID | <rUID8-614-15@gated-at.bofh.it> (permalink) |
| References | <rUtE5-4my-5@gated-at.bofh.it> <rUtE6-4my-27@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Wed, Jul 13, 2016 at 4:44 PM, Vivek Goyal <vgoyal@redhat.com> wrote:
> Right now we remove MAY_WRITE/MAY_APPEND bits from mask if realfile is
> on lower/. This is done as files on lower will never be written and will
> be copied up. But to copy up a file, mounter should have MAY_READ permission
> otherwise copy up will fail. So set MAY_READ in mask when MAY_WRITE is
> reset.
>
> Dan Walsh noticed this when he did access(lowerfile, W_OK) and it returned
> True (context mounts) but when he tried to actually write to file, it failed
> as mounter did not have permission on lower file.
>
> Reported-by: Dan Walsh <dwalsh@redhat.com>
> Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
> ---
> fs/overlayfs/inode.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
> index 6d9d86e..83b2422 100644
> --- a/fs/overlayfs/inode.c
> +++ b/fs/overlayfs/inode.c
> @@ -140,8 +140,13 @@ int ovl_permission(struct inode *inode, int mask)
> return err;
>
> old_cred = ovl_override_creds(inode->i_sb);
> - if (!is_upper && !special_file(realinode->i_mode))
> - mask &= ~(MAY_WRITE | MAY_APPEND);
> + if (!is_upper && !special_file(realinode->i_mode)) {
> + if (mask & MAY_WRITE || mask & MAY_APPEND) {
Hmm. From what I can tell O_APPEND with O_RDONLY is equivalent to
O_RDONLY, hence MAY_APPEND without MAY_WRITE should not behave as if
MAY_WRITE was given. I.e. it should not trigger a copy up. Not sure
what MAC checks do with MAY_APPEND, though.
Pushed amended commit to overlayfs-next.
Thanks,
Miklos
> + mask &= ~(MAY_WRITE | MAY_APPEND);
> + /* Make sure mounter can read file for copy up later */
> + mask |= MAY_READ;
> + }
> + }
> err = inode_permission(realinode, mask);
> revert_creds(old_cred);
>
> --
> 2.7.4
>
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[RFC PATCH 0/9][V3] Overlayfs SELinux Support Vivek Goyal <vgoyal@redhat.com> - 2016-07-13 16:50 +0200
[PATCH 6/9] security, overlayfs: Provide hook to correctly label newly created files Vivek Goyal <vgoyal@redhat.com> - 2016-07-13 16:50 +0200
Re: [PATCH 6/9] security, overlayfs: Provide hook to correctly label newly created files Stephen Smalley <sds@tycho.nsa.gov> - 2016-07-13 17:10 +0200
Re: [PATCH 6/9] security, overlayfs: Provide hook to correctly label newly created files Stephen Smalley <sds@tycho.nsa.gov> - 2016-07-13 17:10 +0200
Re: [PATCH 6/9] security, overlayfs: Provide hook to correctly label newly created files Stephen Smalley <sds@tycho.nsa.gov> - 2016-07-14 16:30 +0200
[PATCH 9/9] overlayfs: Append MAY_READ when diluting write checks Vivek Goyal <vgoyal@redhat.com> - 2016-07-13 16:50 +0200
Re: [PATCH 9/9] overlayfs: Append MAY_READ when diluting write checks Miklos Szeredi <miklos@szeredi.hu> - 2016-07-14 08:50 +0200
Re: [RFC PATCH 0/9][V3] Overlayfs SELinux Support Paul Moore <paul@paul-moore.com> - 2016-07-21 23:20 +0200
Re: [RFC PATCH 0/9][V3] Overlayfs SELinux Support James Morris <jmorris@namei.org> - 2016-07-22 01:10 +0200
Re: [RFC PATCH 0/9][V3] Overlayfs SELinux Support Miklos Szeredi <miklos@szeredi.hu> - 2016-07-22 09:10 +0200
Re: [RFC PATCH 0/9][V3] Overlayfs SELinux Support Paul Moore <paul@paul-moore.com> - 2016-07-22 17:40 +0200
csiph-web