lkml.org 
[lkml]   [2009]   [Dec]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCHv2 06/12]posix_acl: Add the check items
move the ACL validation check in to fs/posix_acl.c.
Including nullpointer check and PTR_ERR check.

---
Signed-off-by: Liuwenyi <qingshenlwy@gmail.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org

---
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



\
 
 \ /
  Last update: 2009-12-21 12:57    [W:0.034 / U:1.480 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site