Skip to contentSkip to conversation

posix acl:Add an acl check

PATCH In review Liuweni 2 participants 2 messages Dec 17, 2009 VFS

lore
Share & tools
lore

Liuweni

author
#0 lore raw

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.

---

---

fs/posix_acl.c +3 -0
index 39df95a..956df14 100644
@@ -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

#1 lore raw
Quoted 2 lines · Liuweni

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().

Signature · 4 lines
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."