[PATCHv2 06/12]posix_acl: Add the check items

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



move the ACL validation check in to fs/posix_acl.c.
Including nullpointer check and PTR_ERR check.

---
Signed-off-by: Liuwenyi <qingshenlwy@xxxxxxxxx>
Cc: Alexander Viro <viro@xxxxxxxxxxxxxxxxxx>
Cc: Christoph Hellwig <hch@xxxxxx>
Cc: linux-fsdevel@xxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx

---
diff --git a/fs/generic_acl.c b/fs/generic_acl.c
index 5545803..5d88218 100644
--- a/fs/generic_acl.c
+++ b/fs/generic_acl.c
@@ -68,6 +68,7 @@ generic_acl_set(struct dentry *dentry, const char
*name, const void *value,
struct inode *inode = dentry->d_inode;
struct posix_acl *acl = NULL;
int error;
+ mode_t mode;

if (strcmp(name, "") != 0)
return -EINVAL;
@@ -80,32 +81,31 @@ generic_acl_set(struct dentry *dentry, const char
*name, const void *value,
if (IS_ERR(acl))
return PTR_ERR(acl);
}
- if (acl) {
- mode_t mode;

- error = posix_acl_valid(acl);
- if (error)
+ error = posix_acl_valid(acl);
+ if (error)
+ goto failed;
+
+ switch (type) {
+ case ACL_TYPE_ACCESS:
+ mode = inode->i_mode;
+ error = posix_acl_equiv_mode(acl, &mode);
+ if (error < 0)
goto failed;
- switch (type) {
- case ACL_TYPE_ACCESS:
- mode = inode->i_mode;
- error = posix_acl_equiv_mode(acl, &mode);
- if (error < 0)
- goto failed;
- inode->i_mode = mode;
- if (error == 0) {
- posix_acl_release(acl);
- acl = NULL;
- }
- break;
- case ACL_TYPE_DEFAULT:
- if (!S_ISDIR(inode->i_mode)) {
- error = -EINVAL;
- goto failed;
- }
- break;
+ inode->i_mode = mode;
+ if (error == 0) {
+ posix_acl_release(acl);
+ acl = NULL;
}
+ break;
+ case ACL_TYPE_DEFAULT:
+ if (!S_ISDIR(inode->i_mode)) {
+ error = -EINVAL;
+ goto failed;
+ }
+ break;
}
+
set_cached_acl(inode, type, acl);
error = 0;
failed:

-- 
Best Regards,
Liuwenyi

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux