linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] libnfs4acl: Check file mode before getxattr call
@ 2022-08-11 19:48 Kenneth D'souza
  2022-09-12 18:24 ` Kenneth Dsouza
  0 siblings, 1 reply; 3+ messages in thread
From: Kenneth D'souza @ 2022-08-11 19:48 UTC (permalink / raw)
  To: linux-nfs; +Cc: steved, kdsouza

Currently we are checking file mode after getxattr call.
Due to this the return value would be 0, which would change the getxattr return value.
As xattr_size will be 0, nfs4_getfacl will fail with error EINVAL.
This patch fixes this issue by moving the file mode check before
getxattr call.

Signed-off-by: Kenneth D'souza <kdsouza@redhat.com>
---
 libnfs4acl/nfs4_getacl.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/libnfs4acl/nfs4_getacl.c b/libnfs4acl/nfs4_getacl.c
index 7821da3..aace5cd 100644
--- a/libnfs4acl/nfs4_getacl.c
+++ b/libnfs4acl/nfs4_getacl.c
@@ -39,6 +39,13 @@ static struct nfs4_acl *nfs4_getacl_byname(const char *path,
 		return NULL;
 	}
 
+	ret = stat(path, &st);
+	if (ret == -1)
+		goto err;
+
+	if (S_ISDIR(st.st_mode))
+		iflags = NFS4_ACL_ISDIR;
+
 	/* find necessary buffer size */
 	ret = getxattr(path, xattr_name, NULL, 0);
 	if (ret == -1)
@@ -53,13 +60,6 @@ static struct nfs4_acl *nfs4_getacl_byname(const char *path,
 	if (ret == -1)
 		goto err_free;
 
-	ret = stat(path, &st);
-	if (ret == -1)
-		goto err_free;
-
-	if (S_ISDIR(st.st_mode))
-		iflags = NFS4_ACL_ISDIR;
-
 	acl = acl_nfs41_xattr_load(buf, ret, iflags, type);
 
 	free(buf);
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] libnfs4acl: Check file mode before getxattr call
  2022-08-11 19:48 [PATCH v2] libnfs4acl: Check file mode before getxattr call Kenneth D'souza
@ 2022-09-12 18:24 ` Kenneth Dsouza
  2022-09-13 15:36   ` Steve Dickson
  0 siblings, 1 reply; 3+ messages in thread
From: Kenneth Dsouza @ 2022-09-12 18:24 UTC (permalink / raw)
  To: linux-nfs; +Cc: steved

ping

On Fri, Aug 12, 2022 at 1:19 AM Kenneth D'souza <kdsouza@redhat.com> wrote:
>
> Currently we are checking file mode after getxattr call.
> Due to this the return value would be 0, which would change the getxattr return value.
> As xattr_size will be 0, nfs4_getfacl will fail with error EINVAL.
> This patch fixes this issue by moving the file mode check before
> getxattr call.
>
> Signed-off-by: Kenneth D'souza <kdsouza@redhat.com>
> ---
>  libnfs4acl/nfs4_getacl.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/libnfs4acl/nfs4_getacl.c b/libnfs4acl/nfs4_getacl.c
> index 7821da3..aace5cd 100644
> --- a/libnfs4acl/nfs4_getacl.c
> +++ b/libnfs4acl/nfs4_getacl.c
> @@ -39,6 +39,13 @@ static struct nfs4_acl *nfs4_getacl_byname(const char *path,
>                 return NULL;
>         }
>
> +       ret = stat(path, &st);
> +       if (ret == -1)
> +               goto err;
> +
> +       if (S_ISDIR(st.st_mode))
> +               iflags = NFS4_ACL_ISDIR;
> +
>         /* find necessary buffer size */
>         ret = getxattr(path, xattr_name, NULL, 0);
>         if (ret == -1)
> @@ -53,13 +60,6 @@ static struct nfs4_acl *nfs4_getacl_byname(const char *path,
>         if (ret == -1)
>                 goto err_free;
>
> -       ret = stat(path, &st);
> -       if (ret == -1)
> -               goto err_free;
> -
> -       if (S_ISDIR(st.st_mode))
> -               iflags = NFS4_ACL_ISDIR;
> -
>         acl = acl_nfs41_xattr_load(buf, ret, iflags, type);
>
>         free(buf);
> --
> 2.31.1
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] libnfs4acl: Check file mode before getxattr call
  2022-09-12 18:24 ` Kenneth Dsouza
@ 2022-09-13 15:36   ` Steve Dickson
  0 siblings, 0 replies; 3+ messages in thread
From: Steve Dickson @ 2022-09-13 15:36 UTC (permalink / raw)
  To: Kenneth Dsouza, linux-nfs



On 9/12/22 2:24 PM, Kenneth Dsouza wrote:
> ping
Sorry about that... Thanks for the ping!

> 
> On Fri, Aug 12, 2022 at 1:19 AM Kenneth D'souza <kdsouza@redhat.com> wrote:
>>
>> Currently we are checking file mode after getxattr call.
>> Due to this the return value would be 0, which would change the getxattr return value.
>> As xattr_size will be 0, nfs4_getfacl will fail with error EINVAL.
>> This patch fixes this issue by moving the file mode check before
>> getxattr call.
>>
>> Signed-off-by: Kenneth D'souza <kdsouza@redhat.com>
Committed... (tag: nfs4-acl-tools-0.4.1-rc2)

steved.
>> ---
>>   libnfs4acl/nfs4_getacl.c | 14 +++++++-------
>>   1 file changed, 7 insertions(+), 7 deletions(-)
>>
>> diff --git a/libnfs4acl/nfs4_getacl.c b/libnfs4acl/nfs4_getacl.c
>> index 7821da3..aace5cd 100644
>> --- a/libnfs4acl/nfs4_getacl.c
>> +++ b/libnfs4acl/nfs4_getacl.c
>> @@ -39,6 +39,13 @@ static struct nfs4_acl *nfs4_getacl_byname(const char *path,
>>                  return NULL;
>>          }
>>
>> +       ret = stat(path, &st);
>> +       if (ret == -1)
>> +               goto err;
>> +
>> +       if (S_ISDIR(st.st_mode))
>> +               iflags = NFS4_ACL_ISDIR;
>> +
>>          /* find necessary buffer size */
>>          ret = getxattr(path, xattr_name, NULL, 0);
>>          if (ret == -1)
>> @@ -53,13 +60,6 @@ static struct nfs4_acl *nfs4_getacl_byname(const char *path,
>>          if (ret == -1)
>>                  goto err_free;
>>
>> -       ret = stat(path, &st);
>> -       if (ret == -1)
>> -               goto err_free;
>> -
>> -       if (S_ISDIR(st.st_mode))
>> -               iflags = NFS4_ACL_ISDIR;
>> -
>>          acl = acl_nfs41_xattr_load(buf, ret, iflags, type);
>>
>>          free(buf);
>> --
>> 2.31.1
>>
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-09-13 16:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-11 19:48 [PATCH v2] libnfs4acl: Check file mode before getxattr call Kenneth D'souza
2022-09-12 18:24 ` Kenneth Dsouza
2022-09-13 15:36   ` Steve Dickson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).