Re: [PATCH -V4 08/11] vfs: Add new file and directory create permission flags

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Andreas Gruenbacher
Date: Monday, September 27, 2010 - 6:14 am

On Friday 24 September 2010 17:54:23 Jeff Layton wrote:

Ah, you mean this:

--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2450,7 +2450,9 @@ int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_de
 	if (!inode)
 		return -ENOENT;
 
-	error = may_create(dir, new_dentry, S_ISDIR(inode->i_mode));
+	if (S_ISDIR(inode->i_mode))
+		return -EPERM;
+	error = may_create(dir, new_dentry, 0);
 	if (error)
 		return error;
 
@@ -2464,8 +2466,6 @@ int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_de
 		return -EPERM;
 	if (!dir->i_op->link)
 		return -EPERM;
-	if (S_ISDIR(inode->i_mode))
-		return -EPERM;
 
 	error = security_inode_link(old_dentry, dir, new_dentry);
 	if (error)

This is a clear improvement; I don't think it matters that user-space will
get -EPERM instead of -EXDEV when trying to hard-link a directory across
devices.

Thanks,
Andreas
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH -V4 00/11] New ACL format for better NFSv4 acl int ..., Aneesh Kumar K.V, (Fri Sep 24, 5:48 am)
[PATCH -V4 03/11] vfs: Add a comment to inode_permission(), Aneesh Kumar K.V, (Fri Sep 24, 5:48 am)
Re: [PATCH -V4 07/11] vfs: Make acl_permission_check() wor ..., Aneesh Kumar K. V, (Fri Sep 24, 11:55 am)
Re: [PATCH -V4 08/11] vfs: Add new file and directory crea ..., Aneesh Kumar K. V, (Fri Sep 24, 12:16 pm)
Re: [PATCH -V4 07/11] vfs: Make acl_permission_check() wor ..., Andreas Gruenbacher, (Mon Sep 27, 6:03 am)
Re: [PATCH -V4 08/11] vfs: Add new file and directory crea ..., Andreas Gruenbacher, (Mon Sep 27, 6:14 am)
Re: [PATCH -V4 00/11] New ACL format for better NFSv4 acl ..., Aneesh Kumar K. V, (Tue Oct 12, 12:17 am)
Re: [PATCH -V4 00/11] New ACL format for better NFSv4 acl ..., J. Bruce Fields, (Mon Oct 25, 12:09 pm)
Re: [PATCH -V4 00/11] New ACL format for better NFSv4 acl ..., Aneesh Kumar K. V, (Mon Oct 25, 9:35 pm)