Skip to contentSkip to conversation

posix_acl: handle NULL ACL in posix_acl_equiv_mode

PATCH In review Christoph Hellwig 3 participants 3 messages May 4, 2014 – May 5, 2014 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 posix_acl: handle NULL ACL in posix_acl_equiv_mode

Various filesystems don't bother checking for a NULL ACL in posix_acl_equiv_mode, and thus can dereference a NULL pointer when it gets passed one. This usually happens from the NFS server, as the ACL tools never pass a NULL ACL, but instead of one representing the mode bits.

Instead of adding boilerplat to all filesystems put this check into one place, which will allow us to remove the check from other filesystems as well later on.

---
 fs/posix_acl.c |    6 ++++++
 1 file changed, 6 insertions(+)
fs/posix_acl.c +6 -0
index 9e363e4..0855f77 100644
@@ -246,6 +246,12 @@ posix_acl_equiv_mode(const struct posix_acl *acl, umode_t *mode_p)
 	umode_t mode = 0;
 	int not_equiv = 0;
 
+	/*
+	 * A null ACL can always be presented as mode bits.
+	 */
+	if (!acl)
+		return 0;
+
 	FOREACH_ACL_ENTRY(pa, acl, pe) {
 		switch (pa->e_tag) {
 			case ACL_USER_OBJ:
Signature · 1 line
1.7.10.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Christoph Hellwig

Various filesystems don't bother checking for a NULL ACL in posix_acl_equiv_mode, and thus can dereference a NULL pointer when it gets passed one. This usually happens from the NFS server, as the ACL tools never pass a NULL ACL, but instead of one representing the mode bits.

Instead of adding boilerplat to all filesystems put this check into one place, which will allow us to remove the check from other filesystems as well later on.

Quoted 5 lines
Reviewed-by on v1 1/1
#2 lore raw
In reply to Christoph Hellwig
Quoted 5 lines · Christoph Hellwig

Various filesystems don't bother checking for a NULL ACL in posix_acl_equiv_mode, and thus can dereference a NULL pointer when it gets passed one. This usually happens from the NFS server, as the ACL tools never pass a NULL ACL, but instead of one representing the mode bits.

Quoted 8 lines

Instead of adding boilerplat to all filesystems put this check into one place, which will allow us to remove the check from other filesystems as well later on.

Good clean-up.

Quoted 29 lines

---
fs/posix_acl.c | 6 ++++++

1 file changed, 6 insertions(+)
fs/posix_acl.c +6 -0
index 9e363e4..0855f77 100644
@@ -246,6 +246,12 @@ posix_acl_equiv_mode(const struct posix_acl *acl, umode_t *mode_p)
 	umode_t mode = 0;
 	int not_equiv = 0;
 
+	/*
+	 * A null ACL can always be presented as mode bits.
+	 */
+	if (!acl)
+		return 0;
+
 	FOREACH_ACL_ENTRY(pa, acl, pe) {
 		switch (pa->e_tag) {
 			case ACL_USER_OBJ:
Signature · 6 lines
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com