2014-07-26 11:59:44

by Andrey Utkin

[permalink] [raw]
Subject: [PATCH] nfs3_list_one_acl(): check get_acl() result with IS_ERR_OR_NULL

There was a check for result being not NULL. But get_acl() may return
NULL, or ERR_PTR, or actual pointer.
The purpose of the function where current change is done is to "list
ACLs only when they are available", so any error condition of get_acl()
mustn't be elevated, and returning 0 there is still valid.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=81111
Signed-off-by: Andrey Utkin <[email protected]>
---
fs/nfs/nfs3acl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nfs/nfs3acl.c b/fs/nfs/nfs3acl.c
index 8f854dd..d0fec26 100644
--- a/fs/nfs/nfs3acl.c
+++ b/fs/nfs/nfs3acl.c
@@ -256,7 +256,7 @@ nfs3_list_one_acl(struct inode *inode, int type, const char *name, void *data,
char *p = data + *result;

acl = get_acl(inode, type);
- if (!acl)
+ if (IS_ERR_OR_NULL(acl))
return 0;

posix_acl_release(acl);
--
2.0.0



2014-07-27 19:50:45

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH] nfs3_list_one_acl(): check get_acl() result with IS_ERR_OR_NULL

On Sun, Jul 27, 2014 at 11:13:50AM -0400, Trond Myklebust wrote:
> Why are we not passing the error code back to the caller here in the
> case where we have one? One of the main purposes of returning an error
> in get_acl() is to ensure that we pass -EOPNOTSUPP if the operation
> fails due to lack of server support.

Do we really want to return EOPNOTSUPP from listxattr? Seems like
simply not listing anything if the server doesn't support ACLs would
be the usual behaviour. E.g. on local filesystems we'll also just get
back an empty list of xattrs if ACLs aren't supported and not other
attribute is set.


2014-07-27 15:13:51

by Trond Myklebust

[permalink] [raw]
Subject: Re: [PATCH] nfs3_list_one_acl(): check get_acl() result with IS_ERR_OR_NULL

On Sun, Jul 27, 2014 at 9:19 AM, Christoph Hellwig <[email protected]> wrote:
> On Sat, Jul 26, 2014 at 02:58:01PM +0300, Andrey Utkin wrote:
>> There was a check for result being not NULL. But get_acl() may return
>> NULL, or ERR_PTR, or actual pointer.
>> The purpose of the function where current change is done is to "list
>> ACLs only when they are available", so any error condition of get_acl()
>> mustn't be elevated, and returning 0 there is still valid.
>>
>> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=81111
>> Signed-off-by: Andrey Utkin <[email protected]>
>
> Looks good, thanks!
>
> Reviewed-by: Christoph Hellwig <[email protected]>
>
> should probably get a cc to stable as the original patch has one
> as well.

Why are we not passing the error code back to the caller here in the
case where we have one? One of the main purposes of returning an error
in get_acl() is to ensure that we pass -EOPNOTSUPP if the operation
fails due to lack of server support.

Cheers
Trond

--
Trond Myklebust

Linux NFS client maintainer, PrimaryData

[email protected]

2014-07-27 13:19:23

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH] nfs3_list_one_acl(): check get_acl() result with IS_ERR_OR_NULL

On Sat, Jul 26, 2014 at 02:58:01PM +0300, Andrey Utkin wrote:
> There was a check for result being not NULL. But get_acl() may return
> NULL, or ERR_PTR, or actual pointer.
> The purpose of the function where current change is done is to "list
> ACLs only when they are available", so any error condition of get_acl()
> mustn't be elevated, and returning 0 there is still valid.
>
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=81111
> Signed-off-by: Andrey Utkin <[email protected]>

Looks good, thanks!

Reviewed-by: Christoph Hellwig <[email protected]>

should probably get a cc to stable as the original patch has one
as well.