2009-12-28 23:34:31

by liu weni

[permalink] [raw]
Subject: [PATCHv4 0/3]posix_acl: Add the acl pointer check

Sorry for previous version. I changed the source but forgot patch it again.
And then, I upload this version.


2009-12-28 23:35:51

by liu weni

[permalink] [raw]
Subject: [PATCHv4 1/3]posix_acl: Add the acl pointer check

If the acl pointer is NULL or have some error, the acl is invalid.
The Macro of FOREACH_ACL_ENTRY will make some error.

---
Signed-off-by: Liuwenyi <[email protected]>
Cc: Alexander Viro <[email protected]>
Cc: [email protected]
Cc: [email protected]

---
diff --git a/fs/posix_acl.c b/fs/posix_acl.c
index 39df95a..d4bacb9 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -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(acl))
+ return PTR_ERR(acl);
+
FOREACH_ACL_ENTRY(pa, acl, pe) {
if (pa->e_perm & ~(ACL_READ|ACL_WRITE|ACL_EXECUTE))
return -EINVAL;

2009-12-28 23:36:28

by liu weni

[permalink] [raw]
Subject: [PATCHv4 2/3]posix_acl: Add the acl pointer check

Add two acl pointer checks before this function.

---

Signed-off-by: Liuwenyi <[email protected]>
CC: Alexander Viro <[email protected]>
Cc: [email protected]
Cc: [email protected]

diff --git a/fs/posix_acl.c b/fs/posix_acl.c
index 39df95a..0d2a7a2 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -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:

2009-12-28 23:37:06

by liu weni

[permalink] [raw]
Subject: [PATCHv4 3/3]posix_acl: Add the acl pointer check

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.

---

Signed-off-by: Liuwenyi <[email protected]>
Cc: Alexander Viro <[email protected]>
Cc: [email protected]
Cc: [email protected]


---
diff --git a/fs/posix_acl.c b/fs/posix_acl.c
index 39df95a..4e0261b 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -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: