2009-12-17 14:12:15

by liu weni

[permalink] [raw]
Subject: [PATCH 1/3]posix acl:Add an acl check

In this function, the parameter of acl will be called by FOREACH_ACL_ENTRY(macro)
without null point check. I add a null point check to it.

---
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..956df14 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -76,6 +76,9 @@ posix_acl_valid(const struct posix_acl *acl)
unsigned int id = 0; /* keep gcc happy */
int needs_mask = 0;

+ if (!acl)
+ return -EINVAL;
+
FOREACH_ACL_ENTRY(pa, acl, pe) {
if (pa->e_perm & ~(ACL_READ|ACL_WRITE|ACL_EXECUTE))
return -EINVAL;


--------------
Best Regards,
Liuweni
2009-12-17


2009-12-17 14:19:13

by Matthew Wilcox

[permalink] [raw]
Subject: Re: [PATCH 1/3]posix acl:Add an acl check

On Thu, Dec 17, 2009 at 10:15:43PM +0800, Liuweni wrote:
> In this function, the parameter of acl will be called by FOREACH_ACL_ENTRY(macro)
> without null point check. I add a null point check to it.

All the callers of posix_acl_valid() currently check for acl being a
null pointer themselves. Moving the check to posix_acl_valid() certainly
seems like a good idea to me, but you need to delete the check from all
the callers.

Further, it seems like many of the callers might have a PTR_ERR value
for 'acl', so you should also move this check into posix_acl_valid().

--
Matthew Wilcox Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours. We can't possibly take such
a retrograde step."