diff mbox

[2/2] ocfs2_iop_set/get_acl() are also called from the VFS so we must take inode lock

Message ID 1428097580-25352-2-git-send-email-tariq.x.saeed@oracle.com (mailing list archive)
State New, archived
Headers show

Commit Message

Tariq Saeed April 3, 2015, 9:46 p.m. UTC
Orabug: 20189959

This bug in mainline code is pointed out by Mark Fasheh. When ocfs2_iop_set_acl
and ocfs2_iop_ge_acl are entered from VFS layer, inode lock is not held. This
seems to be regression from older kernels. The patch is to fix that.

Signed-off-by: Tariq Saeed <tariq.x.saeed@oracle.com>
---
 fs/ocfs2/acl.c |   28 +++++++++++++++++++++-------
 1 files changed, 21 insertions(+), 7 deletions(-)

Comments

Junxiao Bi April 16, 2015, 8:48 a.m. UTC | #1
Hi Tariq,

On 04/04/2015 05:46 AM, Tariq Saeed wrote:
> Orabug: 20189959
> 
> This bug in mainline code is pointed out by Mark Fasheh. When ocfs2_iop_set_acl
> and ocfs2_iop_ge_acl are entered from VFS layer, inode lock is not held. This
> seems to be regression from older kernels. The patch is to fix that.
> 
> Signed-off-by: Tariq Saeed <tariq.x.saeed@oracle.com>
> ---
>  fs/ocfs2/acl.c |   28 +++++++++++++++++++++-------
>  1 files changed, 21 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c
> index 7e8282d..d7b5542 100644
> --- a/fs/ocfs2/acl.c
> +++ b/fs/ocfs2/acl.c
> @@ -286,7 +286,19 @@ int ocfs2_set_acl(handle_t *handle,
>  
>  int ocfs2_iop_set_acl(struct inode *inode, struct posix_acl *acl, int type)
>  {
> -	return ocfs2_set_acl(NULL, inode, NULL, type, acl, NULL, NULL);
> +	struct buffer_head *bh = NULL;
> +	int status = 0;
> +
> +	status = ocfs2_inode_lock(inode, &bh, 1);
> +	if (status < 0) {
> +		if (status != -ENOENT)
> +			mlog_errno(status);
> +		return status;
> +	}
> +	status = ocfs2_set_acl(NULL, inode, bh, type, acl, NULL, NULL);
> +	ocfs2_inode_unlock(inode, 1);
> +	brelse(bh);
> +	return status;
>  }
>  
>  struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type)
> @@ -294,19 +306,21 @@ struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type)
>  	struct ocfs2_super *osb;
>  	struct buffer_head *di_bh = NULL;
>  	struct posix_acl *acl;
> -	int ret = -EAGAIN;
> +	int ret;
>  
>  	osb = OCFS2_SB(inode->i_sb);
>  	if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
>  		return NULL;
> -
> -	ret = ocfs2_read_inode_block(inode, &di_bh);
> -	if (ret < 0)
> -		return ERR_PTR(ret);
> +	ret = ocfs2_inode_lock(inode, &di_bh, 0);
> +	if (ret < 0) {
> +		mlog_errno(ret);
> +		acl = ERR_PTR(ret);
> +		return acl;
I think "return ERR_PTR(ret);" is more simple here.
Also why you check "status != -ENOENT" in ocfs2_iop_set_acl() but not here?

Thanks,
Junxiao.

> +	}
>  
>  	acl = ocfs2_get_acl_nolock(inode, type, di_bh);
>  
> +	ocfs2_inode_unlock(inode, 0);
>  	brelse(di_bh);
> -
>  	return acl;
>  }
>
Tariq Saeed April 16, 2015, 6:51 p.m. UTC | #2
On 04/16/2015 01:48 AM, Junxiao Bi wrote:
> I think "return ERR_PTR(ret);" is more simple here.
True. I am guilty of just copy-paste from an older kernel.
> Also why you check "status != -ENOENT" in ocfs2_iop_set_acl() but not here
Same reason -- copy-and-paste from an older kernel. Having said that,
I don't think it matters one way or the other. Does it?

I have no objection to applying your suggestions and re-submitting the
patch. Mark, what is the protocol for that. Do I need to mention that 
this is a re-sumit?
Thanks,
-Tariq Saeed
Mark Fasheh April 16, 2015, 9:15 p.m. UTC | #3
On Thu, Apr 16, 2015 at 11:51:41AM -0700, Tariq Saeed wrote:
> I have no objection to applying your suggestions and re-submitting the
> patch. Mark, what is the protocol for that. Do I need to mention
> that this is a re-sumit?

If you're re-submitting something that hasn't gone upstream yet it's
sufficient to add a 'V2' (or whatever you like) to the subject line. Also, a
change log in those cases is nice.

Thanks,
	--Mark

--
Mark Fasheh
Tariq Saeed April 16, 2015, 9:23 p.m. UTC | #4
On 04/16/2015 02:15 PM, Mark Fasheh wrote:
> change log in those cases is nice.
Sorry, I don't understand what you mean by 'change log'.
I have not seen any message about this patch's -v1 into being
queued for main stream (unless the message is in transit -- very
unlikely!). So, basically, how do I request to discard the first version ...
or is that request implicit in submitting -v2?
Thanks
-Tariq
Mark Fasheh April 16, 2015, 9:54 p.m. UTC | #5
On Thu, Apr 16, 2015 at 02:23:52PM -0700, Tariq Saeed wrote:
> 
> On 04/16/2015 02:15 PM, Mark Fasheh wrote:
> > change log in those cases is nice.
> Sorry, I don't understand what you mean by 'change log'.

By changelog, I mean "what changed from the previous version of this patch".
For example:

Changes from v1 to v2 of this patch:
- whitespace cleanups
- fixed a bug in foobar() ...


> I have not seen any message about this patch's -v1 into being
> queued for main stream (unless the message is in transit -- very
> unlikely!). So, basically, how do I request to discard the first version ...
> or is that request implicit in submitting -v2?

Yeah that's implicit in the -v2 being there.
	--Mark

--
Mark Fasheh
diff mbox

Patch

diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c
index 7e8282d..d7b5542 100644
--- a/fs/ocfs2/acl.c
+++ b/fs/ocfs2/acl.c
@@ -286,7 +286,19 @@  int ocfs2_set_acl(handle_t *handle,
 
 int ocfs2_iop_set_acl(struct inode *inode, struct posix_acl *acl, int type)
 {
-	return ocfs2_set_acl(NULL, inode, NULL, type, acl, NULL, NULL);
+	struct buffer_head *bh = NULL;
+	int status = 0;
+
+	status = ocfs2_inode_lock(inode, &bh, 1);
+	if (status < 0) {
+		if (status != -ENOENT)
+			mlog_errno(status);
+		return status;
+	}
+	status = ocfs2_set_acl(NULL, inode, bh, type, acl, NULL, NULL);
+	ocfs2_inode_unlock(inode, 1);
+	brelse(bh);
+	return status;
 }
 
 struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type)
@@ -294,19 +306,21 @@  struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type)
 	struct ocfs2_super *osb;
 	struct buffer_head *di_bh = NULL;
 	struct posix_acl *acl;
-	int ret = -EAGAIN;
+	int ret;
 
 	osb = OCFS2_SB(inode->i_sb);
 	if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
 		return NULL;
-
-	ret = ocfs2_read_inode_block(inode, &di_bh);
-	if (ret < 0)
-		return ERR_PTR(ret);
+	ret = ocfs2_inode_lock(inode, &di_bh, 0);
+	if (ret < 0) {
+		mlog_errno(ret);
+		acl = ERR_PTR(ret);
+		return acl;
+	}
 
 	acl = ocfs2_get_acl_nolock(inode, type, di_bh);
 
+	ocfs2_inode_unlock(inode, 0);
 	brelse(di_bh);
-
 	return acl;
 }