mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] Yama: verify inode is symlink to avoid bind mounts
@ 2010-07-14  6:18 Kees Cook
  2010-07-20 23:01 ` James Morris
  0 siblings, 1 reply; 2+ messages in thread
From: Kees Cook @ 2010-07-14  6:18 UTC (permalink / raw)
  To: linux-security-module; +Cc: linux-kernel

The inode_follow_link LSM hook is called in bind mount situations as
well as for symlink situations, so we must explicitly check for the
inode being a symlink to not reject bind mounts in 1777 directories,
which seems to be a common NFSv4 configuration.

Signed-off-by: Kees Cook <kees.cook@canonical.com>
---
v2:
 - actually set inode in time to use it.  *face palm*
---
 security/yama/yama_lsm.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
index 3b76386..51c6a3a 100644
--- a/security/yama/yama_lsm.c
+++ b/security/yama/yama_lsm.c
@@ -116,9 +116,13 @@ static int yama_inode_follow_link(struct dentry *dentry,
 	if (!protected_sticky_symlinks)
 		return 0;
 
+	/* if inode isn't a symlink, don't try to evaluate blocking it */
+	inode = dentry->d_inode;
+	if (!S_ISLNK(inode->i_mode))
+		return 0;
+
 	/* owner and follower match? */
 	cred = current_cred();
-	inode = dentry->d_inode;
 	if (cred->fsuid == inode->i_uid)
 		return 0;
 
-- 
1.7.1


-- 
Kees Cook
Ubuntu Security Team

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-07-20 23:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-14  6:18 [PATCH v2] Yama: verify inode is symlink to avoid bind mounts Kees Cook
2010-07-20 23:01 ` James Morris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®