Skip to contentSkip to conversation

Yama: verify inode is symlink to avoid bind mounts

PATCH In review Kees Cook 2 participants 2 messages Jul 14, 2010 – Jul 20, 2010

Subsystems (2)
lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH v2 1/1 Yama: verify inode is symlink to avoid bind mounts

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.

---
v2:
- actually set inode in time to use it. *face palm*

---
 security/yama/yama_lsm.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
security/yama/yama_lsm.c +5 -1
index 3b76386..51c6a3a 100644
@@ -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;
 
Signature · 6 lines
1.7.1


-- 
Kees Cook
Ubuntu Security Team
maintainer
#1 lore raw
Quoted 9 lines · Kees Cook

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.

---
v2:
- actually set inode in time to use it. *face palm*

Applied to
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6#next

Signature · 2 lines
James Morris
<[email protected]>