Skip to contentSkip to conversation

cifs: Percolate error up to the caller during get/set acls

PATCH In review [email protected] 2 participants 4 messages Nov 9, 2010 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cifs: Percolate error up to the caller during get/set acls

From: Shirish Pargaonkar <[email protected]>

Modify get/set_cifs_acl* calls to reutrn error code and percolate the error code up to the caller.

---
 fs/cifs/cifsacl.c |   46 ++++++++++++++++++++++++++++++----------------
 1 files changed, 30 insertions(+), 16 deletions(-)
fs/cifs/cifsacl.c +30 -16
index c9b4792..003588a 100644
@@ -568,8 +568,11 @@ static struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb,
 
 	cifs_put_tlink(tlink);
 
-	cFYI(1, "GetCIFSACL rc = %d ACL len %d", rc, *pacllen);
-	return pntsd;
+	cFYI(1, "%s: rc = %d ACL len %d", __func__, rc, *pacllen);
+	if (rc)
+		return ERR_PTR(rc);
+	else
+		return pntsd;
 }
 
 static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb,
@@ -591,19 +594,19 @@ static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb,
 	rc = CIFSSMBOpen(xid, tcon, path, FILE_OPEN, READ_CONTROL, 0,
 			 &fid, &oplock, NULL, cifs_sb->local_nls,
 			 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
-	if (rc) {
-		cERROR(1, "Unable to open file to get ACL");
-		goto out;
+	if (!rc) {
+		rc = CIFSSMBGetCIFSACL(xid, tcon, fid, &pntsd, pacllen);
+		CIFSSMBClose(xid, tcon, fid);
 	}
 
-	rc = CIFSSMBGetCIFSACL(xid, tcon, fid, &pntsd, pacllen);
-	cFYI(1, "GetCIFSACL rc = %d ACL len %d", rc, *pacllen);
-
-	CIFSSMBClose(xid, tcon, fid);
- out:
 	cifs_put_tlink(tlink);
 	FreeXid(xid);
-	return pntsd;
+
+	cFYI(1, "%s: rc = %d ACL len %d", __func__, rc, *pacllen);
+	if (rc)
+		return ERR_PTR(rc);
+	else
+		return pntsd;
 }
 
 /* Retrieve an ACL from the server */
@@ -711,12 +714,18 @@ cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr,
 		pntsd = get_cifs_acl(cifs_sb, inode, path, &acllen);
 
 	/* if we can retrieve the ACL, now parse Access Control Entries, ACEs */
-	if (pntsd)
+	if (!pntsd)
+		cERROR(1, "%s: NULL sec desc", __func__);
+	else if (IS_ERR(pntsd)) {
+		rc = PTR_ERR(pntsd);
+		cERROR(1, "%s: error %d getting sec desc", __func__, rc);
+	} else {
 		rc = parse_sec_desc(pntsd, acllen, fattr);
-	if (rc)
-		cFYI(1, "parse sec desc failed rc = %d", rc);
+		kfree(pntsd);
+		if (rc)
+			cERROR(1, "parse sec desc failed rc = %d", rc);
+	}
 
-	kfree(pntsd);
 	return;
 }
 
@@ -736,7 +745,12 @@ int mode_to_acl(struct inode *inode, const char *path, __u64 nmode)
 	/* Add three ACEs for owner, group, everyone getting rid of
 	   other ACEs as chmod disables ACEs and set the security descriptor */
 
-	if (pntsd) {
+	if (!pntsd)
+		cERROR(1, "%s: NULL sec desc", __func__);
+	else if (IS_ERR(pntsd)) {
+		rc = PTR_ERR(pntsd);
+		cERROR(1, "%s: error %d getting sec desc", __func__, rc);
+	} else {
 		/* allocate memory for the smb header,
 		   set security descriptor request security descriptor
 		   parameters, and secuirty descriptor itself */
Signature · 1 line
1.6.0.2

A message that is not in the archive (sent off-list or not yet received): 1289313302-31064-1-git-send-email-shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw
Quoted 17 lines · On Tue, 9 Nov 2010 08:35:02 -0600 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@pub…

From: Shirish Pargaonkar <[email protected]>

Modify get/set_cifs_acl* calls to reutrn error code and percolate the error code up to the caller.

---
 fs/cifs/cifsacl.c |   46 ++++++++++++++++++++++++++++++----------------
 1 files changed, 30 insertions(+), 16 deletions(-)
fs/cifs/cifsacl.c +0 -0
index c9b4792..003588a 100644

fs/cifs/cifsacl.c static struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb, · line 574

Quoted 9 lines
fs/cifs/cifsacl.c +4 -2
@@ -568,8 +568,11 @@ static struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb,
 
 	cifs_put_tlink(tlink);
 
-	cFYI(1, "GetCIFSACL rc = %d ACL len %d", rc, *pacllen);
-	return pntsd;
+	cFYI(1, "%s: rc = %d ACL len %d", __func__, rc, *pacllen);
+	if (rc)
+		return ERR_PTR(rc);
+	else
	^^^^
	This else isn't needed
Quoted 19 lines
fs/cifs/cifsacl.c +4 -6
+		return pntsd;
 }
 
 static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb,
@@ -591,19 +594,19 @@ static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb,
 	rc = CIFSSMBOpen(xid, tcon, path, FILE_OPEN, READ_CONTROL, 0,
 			 &fid, &oplock, NULL, cifs_sb->local_nls,
 			 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
-	if (rc) {
-		cERROR(1, "Unable to open file to get ACL");
-		goto out;
+	if (!rc) {
+		rc = CIFSSMBGetCIFSACL(xid, tcon, fid, &pntsd, pacllen);
+		CIFSSMBClose(xid, tcon, fid);
 	}
 
-	rc = CIFSSMBGetCIFSACL(xid, tcon, fid, &pntsd, pacllen);
-	cFYI(1, "GetCIFSACL rc = %d ACL len %d", rc, *pacllen);
-

fs/cifs/cifsacl.c static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb, · line 608

Quoted 10 lines
fs/cifs/cifsacl.c +5 -3
-	CIFSSMBClose(xid, tcon, fid);
- out:
 	cifs_put_tlink(tlink);
 	FreeXid(xid);
-	return pntsd;
+
+	cFYI(1, "%s: rc = %d ACL len %d", __func__, rc, *pacllen);
+	if (rc)
+		return ERR_PTR(rc);
+	else
	^^^^
	Also not needed...

fs/cifs/cifsacl.c cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr, · line 718

Quoted 11 lines
fs/cifs/cifsacl.c +3 -1
+		return pntsd;
 }
 
 /* Retrieve an ACL from the server */
@@ -711,12 +714,18 @@ cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr,
 		pntsd = get_cifs_acl(cifs_sb, inode, path, &acllen);
 
 	/* if we can retrieve the ACL, now parse Access Control Entries, ACEs */
-	if (pntsd)
+	if (!pntsd)
+		cERROR(1, "%s: NULL sec desc", __func__);

^^^^^^^^
Will this ever be a null pointer? I don't think it will. It's either going to be an ERR_PTR or a real cifs_ntsd. I think that check isn't needed.

Quoted 6 lines
fs/cifs/cifsacl.c +4 -1
+	else if (IS_ERR(pntsd)) {
+		rc = PTR_ERR(pntsd);
+		cERROR(1, "%s: error %d getting sec desc", __func__, rc);
+	} else {
 		rc = parse_sec_desc(pntsd, acllen, fattr);
-	if (rc)

fs/cifs/cifsacl.c cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr, · line 731

Quoted 10 lines
fs/cifs/cifsacl.c +4 -2
-		cFYI(1, "parse sec desc failed rc = %d", rc);
+		kfree(pntsd);
+		if (rc)
+			cERROR(1, "parse sec desc failed rc = %d", rc);
+	}
 
-	kfree(pntsd);
 	return;
 }
 
	^^^^^

Hmm, now that you're fixing this error, why not have it bubble up to cifs_get_inode_info too? It seems like cifs_acl_to_fattr could now return an int, and the caller should handle those errors.

fs/cifs/cifsacl.c int mode_to_acl(struct inode *inode, const char *path, __u64 nmode) · line 749

Quoted 7 lines
fs/cifs/cifsacl.c +2 -1
@@ -736,7 +745,12 @@ int mode_to_acl(struct inode *inode, const char *path, __u64 nmode)
 	/* Add three ACEs for owner, group, everyone getting rid of
 	   other ACEs as chmod disables ACEs and set the security descriptor */
 
-	if (pntsd) {
+	if (!pntsd)
+		cERROR(1, "%s: NULL sec desc", __func__);
	^^^^^^^^
	Again, this pointer will never be NULL. This can be removed.
Quoted 7 lines
fs/cifs/cifsacl.c +4 -0
+	else if (IS_ERR(pntsd)) {
+		rc = PTR_ERR(pntsd);
+		cERROR(1, "%s: error %d getting sec desc", __func__, rc);
+	} else {
 		/* allocate memory for the smb header,
 		   set security descriptor request security descriptor
 		   parameters, and secuirty descriptor itself */
Signature · 1 line
Jeff Layton <[email protected]>

A message that is not in the archive (sent off-list or not yet received): 20101109124033.28393639-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org

#4 lore raw
Quoted 71 lines · Jeff Layton
Quoted 17 lines · On Tue,  9 Nov 2010 08:35:02 -0600 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@pub…

From: Shirish Pargaonkar <[email protected]>

Modify get/set_cifs_acl* calls to reutrn error code and percolate the error code up to the caller.

---
 fs/cifs/cifsacl.c |   46 ++++++++++++++++++++++++++++++----------------

 1 files changed, 30 insertions(+), 16 deletions(-)
fs/cifs/cifsacl.c +0 -0
index c9b4792..003588a 100644

fs/cifs/cifsacl.c static struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb, · line 574

Quoted 9 lines
fs/cifs/cifsacl.c +4 -2
@@ -568,8 +568,11 @@ static struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb,
 
       cifs_put_tlink(tlink);
 
-     cFYI(1, "GetCIFSACL rc = %d ACL len %d", rc, *pacllen);
-     return pntsd;
+     cFYI(1, "%s: rc = %d ACL len %d", __func__, rc, *pacllen);
+     if (rc)
+             return ERR_PTR(rc);
+     else

       ^^^^
       This else isn't needed

Quoted 19 lines
fs/cifs/cifsacl.c +4 -6
+             return pntsd;
  }
 
  static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb,
@@ -591,19 +594,19 @@ static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb,
       rc = CIFSSMBOpen(xid, tcon, path, FILE_OPEN, READ_CONTROL, 0,
                        &fid, &oplock, NULL, cifs_sb->local_nls,
                        cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
-     if (rc) {
-             cERROR(1, "Unable to open file to get ACL");
-             goto out;
+     if (!rc) {
+             rc = CIFSSMBGetCIFSACL(xid, tcon, fid, &pntsd, pacllen);
+             CIFSSMBClose(xid, tcon, fid);
       }
 
-     rc = CIFSSMBGetCIFSACL(xid, tcon, fid, &pntsd, pacllen);
-     cFYI(1, "GetCIFSACL rc = %d ACL len %d", rc, *pacllen);
-

fs/cifs/cifsacl.c static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb, · line 608

Quoted 10 lines
fs/cifs/cifsacl.c +5 -3
-     CIFSSMBClose(xid, tcon, fid);
- out:
       cifs_put_tlink(tlink);
       FreeXid(xid);
-     return pntsd;
+
+     cFYI(1, "%s: rc = %d ACL len %d", __func__, rc, *pacllen);
+     if (rc)
+             return ERR_PTR(rc);
+     else

       ^^^^
       Also not needed...

Quoted 7 lines
fs/cifs/cifsacl.c +1 -0
+             return pntsd;
  }
 
  /* Retrieve an ACL from the server */
@@ -711,12 +714,18 @@ cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr,
               pntsd = get_cifs_acl(cifs_sb, inode, path, &acllen);
 
Quoted 8 lines

fs/cifs/cifsacl.c cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr, · line 718

Quoted 4 lines
fs/cifs/cifsacl.c +2 -1
       /* if we can retrieve the ACL, now parse Access Control Entries, ACEs */
-     if (pntsd)
+     if (!pntsd)
+             cERROR(1, "%s: NULL sec desc", __func__);

       ^^^^^^^^
       Will this ever be a null pointer? I don't think it will. It's either going to be an ERR_PTR or a real cifs_ntsd. I think that check isn't needed.

get_cifs_acl_by_pid/path can return NULL when the return thus

        if (IS_ERR(tlink))
                return NULL;
Quoted 44 lines
Quoted 7 lines
fs/cifs/cifsacl.c +4 -1
+     else if (IS_ERR(pntsd)) {
+             rc = PTR_ERR(pntsd);
+             cERROR(1, "%s: error %d getting sec desc", __func__, rc);
+     } else {
               rc = parse_sec_desc(pntsd, acllen, fattr);
-     if (rc)

fs/cifs/cifsacl.c cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr, · line 731

Quoted 10 lines
fs/cifs/cifsacl.c +4 -2
-             cFYI(1, "parse sec desc failed rc = %d", rc);
+             kfree(pntsd);
+             if (rc)
+                     cERROR(1, "parse sec desc failed rc = %d", rc);
+     }
 
-     kfree(pntsd);
       return;
  }
 

       ^^^^^
Hmm, now that you're fixing this error, why not have it bubble up to cifs_get_inode_info too? It seems like cifs_acl_to_fattr could now return an int, and the caller should handle those errors.

Quoted 7 lines
fs/cifs/cifsacl.c +0 -0
@@ -736,7 +745,12 @@ int mode_to_acl(struct inode *inode, const char *path, __u64 nmode)
       /* Add three ACEs for owner, group, everyone getting rid of

         other ACEs as chmod disables ACEs and set the security descriptor */

-     if (pntsd) {
+     if (!pntsd)
+             cERROR(1, "%s: NULL sec desc", __func__);

       ^^^^^^^^
       Again, this pointer will never be NULL. This can be removed.

Quoted 7 lines

+     else if (IS_ERR(pntsd)) {
+             rc = PTR_ERR(pntsd);
+             cERROR(1, "%s: error %d getting sec desc", __func__, rc);
+     } else {
              /* allocate memory for the smb header,
                 set security descriptor request security descriptor parameters, and secuirty descriptor itself */

--
Jeff Layton <[email protected]>

A message that is not in the archive (sent off-list or not yet received): AANLkTikgu1kS0hR3ENb6=v1YLOELR2tKomaAu7T_ViAm-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#6 lore raw
Quoted 81 lines · On Tue, 9 Nov 2010 12:52:16 -0600 Shirish Pargaonkar…
Quoted 71 lines · Jeff Layton
Quoted 17 lines · On Tue,  9 Nov 2010 08:35:02 -0600 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@pub…

From: Shirish Pargaonkar <[email protected]>

Modify get/set_cifs_acl* calls to reutrn error code and percolate the error code up to the caller.

---
 fs/cifs/cifsacl.c |   46 ++++++++++++++++++++++++++++++----------------

 1 files changed, 30 insertions(+), 16 deletions(-)
fs/cifs/cifsacl.c +0 -0
index c9b4792..003588a 100644

fs/cifs/cifsacl.c static struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb, · line 574

Quoted 9 lines
fs/cifs/cifsacl.c +4 -2
@@ -568,8 +568,11 @@ static struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb,
 
       cifs_put_tlink(tlink);
 
-     cFYI(1, "GetCIFSACL rc = %d ACL len %d", rc, *pacllen);
-     return pntsd;
+     cFYI(1, "%s: rc = %d ACL len %d", __func__, rc, *pacllen);
+     if (rc)
+             return ERR_PTR(rc);
+     else

       ^^^^
       This else isn't needed

Quoted 19 lines
fs/cifs/cifsacl.c +4 -6
+             return pntsd;
  }
 
  static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb,
@@ -591,19 +594,19 @@ static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb,
       rc = CIFSSMBOpen(xid, tcon, path, FILE_OPEN, READ_CONTROL, 0,
                        &fid, &oplock, NULL, cifs_sb->local_nls,
                        cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
-     if (rc) {
-             cERROR(1, "Unable to open file to get ACL");
-             goto out;
+     if (!rc) {
+             rc = CIFSSMBGetCIFSACL(xid, tcon, fid, &pntsd, pacllen);
+             CIFSSMBClose(xid, tcon, fid);
       }
 
-     rc = CIFSSMBGetCIFSACL(xid, tcon, fid, &pntsd, pacllen);
-     cFYI(1, "GetCIFSACL rc = %d ACL len %d", rc, *pacllen);
-

fs/cifs/cifsacl.c static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb, · line 608

Quoted 10 lines
fs/cifs/cifsacl.c +5 -3
-     CIFSSMBClose(xid, tcon, fid);
- out:
       cifs_put_tlink(tlink);
       FreeXid(xid);
-     return pntsd;
+
+     cFYI(1, "%s: rc = %d ACL len %d", __func__, rc, *pacllen);
+     if (rc)
+             return ERR_PTR(rc);
+     else

       ^^^^
       Also not needed...

Quoted 7 lines
fs/cifs/cifsacl.c +1 -0
+             return pntsd;
  }
 
  /* Retrieve an ACL from the server */
@@ -711,12 +714,18 @@ cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr,
               pntsd = get_cifs_acl(cifs_sb, inode, path, &acllen);
 
Quoted 8 lines

fs/cifs/cifsacl.c cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr, · line 718

Quoted 4 lines
fs/cifs/cifsacl.c +2 -1
       /* if we can retrieve the ACL, now parse Access Control Entries, ACEs */
-     if (pntsd)
+     if (!pntsd)
+             cERROR(1, "%s: NULL sec desc", __func__);

       ^^^^^^^^
       Will this ever be a null pointer? I don't think it will. It's either going to be an ERR_PTR or a real cifs_ntsd. I think that check isn't needed.

Quoted 5 lines

get_cifs_acl_by_pid/path can return NULL when the return thus

        if (IS_ERR(tlink))
                return NULL;

That needs to be fixed too. Don't return NULL there, return ERR_CAST(tlink) instead.

Signature · 1 line
Jeff Layton <[email protected]>