lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1468421095-22322-10-git-send-email-vgoyal@redhat.com>
Date:	Wed, 13 Jul 2016 10:44:55 -0400
From:	Vivek Goyal <vgoyal@...hat.com>
To:	miklos@...redi.hu, sds@...ho.nsa.gov, pmoore@...hat.com,
	casey@...aufler-ca.com, linux-kernel@...r.kernel.org,
	linux-unionfs@...r.kernel.org,
	linux-security-module@...r.kernel.org
Cc:	dwalsh@...hat.com, dhowells@...hat.com, viro@...IV.linux.org.uk,
	vgoyal@...hat.com, linux-fsdevel@...r.kernel.org
Subject: [PATCH 9/9] overlayfs: Append MAY_READ when diluting write checks

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@...hat.com>
Signed-off-by: Vivek Goyal <vgoyal@...hat.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) {
+			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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ