2009-12-28 14:59:20

by liu weni

[permalink] [raw]
Subject: [PATCHv3 0/3]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


2009-12-28 15:01:00

by liu weni

[permalink] [raw]
Subject: [PATCHv3 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.

---
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..45f8afa 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)
+ 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 15:01:30

by liu weni

[permalink] [raw]
Subject: Re: [PATCHv3 2/3]posix_acl: add the pointer check into fs/posix_acl.c

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 15:02:09

by liu weni

[permalink] [raw]
Subject: [PATCHv3 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.

---

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:

2009-12-28 15:38:48

by Cong Wang

[permalink] [raw]
Subject: Re: [PATCHv3 1/3]posix_acl: add the pointer check into fs/posix_acl.c

On Mon, Dec 28, 2009 at 11:00:58PM +0800, liu weni wrote:
>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..45f8afa 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)

Did you even do a compile test?
I don't think this line will work...


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

2009-12-28 23:29:11

by liu weni

[permalink] [raw]
Subject: Re: [PATCHv3 1/3]posix_acl: add the pointer check into fs/posix_acl.c

Sorry. I forgot diff it again.

2009/12/28 Am?rico Wang <[email protected]>:
> On Mon, Dec 28, 2009 at 11:00:58PM +0800, liu weni wrote:
>>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..45f8afa 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)
>
> Did you even do a compile test?
> I don't think this line will work...
>
>
>>+ ? ? ? ? ? ? ?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.
>
>