posix_acl: add the pointer check into fs/posix_acl.c
v3 cover posix_acl: add the pointer check into fs/posix_acl.c
Hi all:
Many filesystems have their own way to check the acl pointer, and
others not. It have something wrong while calling FOREACH_ACL_ENTRY. Then, I wanna add a pointer check before the Macro of FOREACH_ACL_ENTRY.
---
Best Regards,
Liuwenyi
2009-12-29
PATCH v3 1/3 posix_acl: add the pointer check into fs/posix_acl.c
If the acl pointer is NULL or have some error, the acl is invalid. The Macro of FOREACH_ACL_ENTRY will make some error.
---
---
fs/posix_acl.c +6 -0
@@ -76,6 +76,12 @@ posix_acl_valid(const struct posix_acl *acl)unsigned int id =0 ;/* keep gcc happy */ int needs_mask =0 ; +if (!acl) +return -EINVAL ; + +if (IS_ERR ) +return PTR_ERR (acl); + FOREACH_ACL_ENTRY(pa, acl, pe) {if (pa->e_perm & ~(ACL_READ |ACL_WRITE |ACL_EXECUTE ))return -EINVAL ;
Add two acl pointer checks before this function.
---
---
fs/posix_acl.c +0 -0
@@ -150,6 +150,12 @@ posix_acl_equiv_mode(const struct posix_acl *acl,
mode_t *mode_p)
mode_t mode = 0;
int not_equiv = 0;
+ if (!acl)
+ return -EINVAL;
+
+ if (IS_ERR(acl))
+ return PTR_ERR(acl);
+
FOREACH_ACL_ENTRY(pa, acl, pe) {
switch (pa->e_tag) {
case ACL_USER_OBJ:
PATCH v3 3/3 posix_acl: add the pointer check into fs/posix_acl.c
While the acl pointer is IS_ERR, We cannot get the correct return.
And the acl pointer is NULL. Oh, my god! The FOREACH_ACL_ENTRY will call that.
---
---
fs/posix_acl.c +0 -0
@@ -213,6 +213,12 @@ posix_acl_permission(struct inode *inode, const
struct posix_acl *acl, int want)
const struct posix_acl_entry *pa, *pe, *mask_obj; int found = 0;
+ if (!acl)
+ return -EINVAL;
+
+ if (IS_ERR(acl))
+ return PTR_ERR(acl);
+
FOREACH_ACL_ENTRY(pa, acl, pe) {
switch(pa->e_tag) {
case ACL_USER_OBJ:Quoted 15 lines · liu weni
If the acl pointer is NULL or have some error, the acl is invalid. The Macro of
FOREACH_ACL_ENTRYwill make some error.---
Signed-off-by Liuwenyi <[email protected]>Cc Alexander Viro <[email protected]>---
fs/posix_acl.c +0
-0
fs/posix_acl.c posix_acl_valid(const struct posix_acl *acl) · line 82
Quoted 7 lines
fs/posix_acl.c +4
-0@@ -76,6 +76,12 @@ posix_acl_valid(const struct posix_acl *acl)unsigned int id =0 ;/* keep gcc happy */ int needs_mask =0 ; +if (!acl) +return -EINVAL ; + +if (IS_ERR )
Did you even do a compile test?
I don't think this line will work...
Quoted 10 lines
fs/posix_acl.c +2
-1+return PTR_ERR (acl); + FOREACH_ACL_ENTRY(pa, acl, pe) {if (pa->e_perm & ~(ACL_READ |ACL_WRITE |ACL_EXECUTE ))return -EINVAL ; --To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Signature · 1 line
Live like a child, think like the god.
Sorry. I forgot diff it again.
2009/12/28 Américo Wang <[email protected]>:
Quoted 43 lines · liu weni
Quoted 18 lines
If the acl pointer is NULL or have some error, the acl is invalid. The Macro of
FOREACH_ACL_ENTRYwill make some error.---
Signed-off-by Liuwenyi <[email protected]>Cc Alexander Viro <[email protected]>---
fs/posix_acl.c +0
-0@@ -76,6 +76,12 @@ posix_acl_valid(const struct posix_acl *acl)unsigned int id = 0; /* keep gcc happy */
intneeds_mask= 0;Quoted 4 lines
+ if (!acl)
+ return-EINVAL;
+
+ if (IS_ERR)Did you even do a compile test?
I don't think this line will work...Quoted 10 lines
+ return
PTR_ERR(acl);
+
FOREACH_ACL_ENTRY(pa, acl, pe){
if (pa->e_perm& ~(ACL_READ|ACL_WRITE|ACL_EXECUTE)) return-EINVAL;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/--
Live like a child, think like the god.