Regression with getcifsacl(1) in v6.14-rc1
Subsystems (2)
Steve,
The commit 438e2116d7bd ("cifs: Change translation of STATUS_PRIVILEGE_NOT_HELD to -EPERM") regressed getcifsacl(1) because it expects -EIO to be returned from getxattr(2) when the client can't read system.cifs_ntsd_full attribute and then fall back to system.cifs_acl attribute. Either -EIO or -EPERM is wrong for getxattr(2), but that's a different problem, though.
Reproduced against samba-4.22 server.
Quoted 10 lines · On Wednesday 12 February 2025 17:49:31 Paulo Alcantara wrote:
Steve,
The commit
438e2116d7bd("cifs: Change translation ofSTATUS_PRIVILEGE_NOT_HELDto-EPERM") regressed getcifsacl(1) because it expects-EIOto be returned from getxattr(2) when the client can't read system.cifs_ntsd_full attribute and then fall back to system.cifs_acl attribute. Either-EIOor-EPERMis wrong for getxattr(2), but that's a different problem, though.Reproduced against samba-4.22 server.
That is bad. I can prepare a fix for cifs.ko getxattr syscall to translate -EPERM to -EIO. This will ensure that getcifsacl will work as before as it would still see -EIO error.
But as discussed before, we need to distinguish between privilege/permission error and other generic errors (access/io). So I think that we need 438e2116d7bd commit.
Based on linux-fsdevel discussion it is a good idea to distinguish between errors by mapping status codes to appropriate posix errno, and then updating linux syscall manpages.
Quoted 10 lines · Pali Rohár
Quoted 9 lines · On Wednesday 12 February 2025 17:49:31 Paulo Alcantara wrote:
Steve,
The commit
438e2116d7bd("cifs: Change translation ofSTATUS_PRIVILEGE_NOT_HELDto-EPERM") regressed getcifsacl(1) because it expects-EIOto be returned from getxattr(2) when the client can't read system.cifs_ntsd_full attribute and then fall back to system.cifs_acl attribute. Either-EIOor-EPERMis wrong for getxattr(2), but that's a different problem, though.
Quoted 5 lines
Quoted 1 line
Reproduced against samba-4.22 server.
That is bad. I can prepare a fix for cifs.ko getxattr syscall to translate
-EPERMto-EIO. This will ensure that getcifsacl will work as before as it would still see-EIOerror.
Sounds good.
Quoted 3 lines
But as discussed before, we need to distinguish between privilege/permission error and other generic errors (access/io). So I think that we need
438e2116d7bdcommit.
OK.
Quoted 3 lines
Based on linux-fsdevel discussion it is a good idea to distinguish between errors by mapping status codes to appropriate posix errno, and then updating linux syscall manpages.
Either way, we shouldn't be leaking -EIO or -EPERM to userland from getxattr(2). By looking at the man pages, -ENODATA seems to be the appropriate error to return instead.
Quoted 26 lines · On Wednesday 12 February 2025 19:19:00 Paulo Alcantara wrote:
Quoted 10 lines · Pali Rohár
Quoted 9 lines · On Wednesday 12 February 2025 17:49:31 Paulo Alcantara wrote:
Steve,
The commit
438e2116d7bd("cifs: Change translation ofSTATUS_PRIVILEGE_NOT_HELDto-EPERM") regressed getcifsacl(1) because it expects-EIOto be returned from getxattr(2) when the client can't read system.cifs_ntsd_full attribute and then fall back to system.cifs_acl attribute. Either-EIOor-EPERMis wrong for getxattr(2), but that's a different problem, though.Quoted 5 lines
Quoted 1 line
Reproduced against samba-4.22 server.
That is bad. I can prepare a fix for cifs.ko getxattr syscall to translate
-EPERMto-EIO. This will ensure that getcifsacl will work as before as it would still see-EIOerror.Sounds good.
Quoted 3 lines
But as discussed before, we need to distinguish between privilege/permission error and other generic errors (access/io). So I think that we need
438e2116d7bdcommit.OK.
Quoted 7 lines
Quoted 3 lines
Based on linux-fsdevel discussion it is a good idea to distinguish between errors by mapping status codes to appropriate posix errno, and then updating linux syscall manpages.
Either way, we shouldn't be leaking
-EIOor-EPERMto userland from getxattr(2). By looking at the man pages,-ENODATAseems to be the appropriate error to return instead.
It looks like there are missing error codes for getxattr. Because any path based syscall can return -EACCES if trying to open path to which calling process does not have access.
And EACCES is not mentioned nor documented in getxattr(2). Same applies for listxattr(2). Now I have tried listxattr() and it really returns EACCES for /root/file called by nobody.
-EIO is generic I/O error. And I think that this error code could be returned by any I/O syscall when unknown I/O error occurs.
Returning -ENODATA for generic or unknown I/O error is a bad idea because ENODATA (= ENOATTR) has already specific meaning when attribute does not exists at all (or process does not have access to it).
For me it makes sense to return -EIO and -EPERM by those syscalls. But for getxattr() we cannot do it due that backward compatibility needed by getcifsacl application.
Quoted 35 lines · Pali Rohár
Quoted 26 lines · On Wednesday 12 February 2025 19:19:00 Paulo Alcantara wrote:
Quoted 10 lines · Pali Rohár
Quoted 9 lines · On Wednesday 12 February 2025 17:49:31 Paulo Alcantara wrote:
Steve,
The commit
438e2116d7bd("cifs: Change translation ofSTATUS_PRIVILEGE_NOT_HELDto-EPERM") regressed getcifsacl(1) because it expects-EIOto be returned from getxattr(2) when the client can't read system.cifs_ntsd_full attribute and then fall back to system.cifs_acl attribute. Either-EIOor-EPERMis wrong for getxattr(2), but that's a different problem, though.Quoted 5 lines
Quoted 1 line
Reproduced against samba-4.22 server.
That is bad. I can prepare a fix for cifs.ko getxattr syscall to translate
-EPERMto-EIO. This will ensure that getcifsacl will work as before as it would still see-EIOerror.Sounds good.
Quoted 3 lines
But as discussed before, we need to distinguish between privilege/permission error and other generic errors (access/io). So I think that we need
438e2116d7bdcommit.OK.
Quoted 7 lines
Quoted 3 lines
Based on linux-fsdevel discussion it is a good idea to distinguish between errors by mapping status codes to appropriate posix errno, and then updating linux syscall manpages.
Either way, we shouldn't be leaking
-EIOor-EPERMto userland from getxattr(2). By looking at the man pages,-ENODATAseems to be the appropriate error to return instead.
Quoted 7 lines
It looks like there are missing error codes for getxattr. Because any path based syscall can return
-EACCESif trying to open path to which calling process does not have access.And EACCES is not mentioned nor documented in getxattr(2). Same applies for listxattr(2). Now I have tried
listxattr()and it really returns EACCES for/root/filecalled by nobody.
Both man pages have this:
> In addition, the errors documented in stat(2) can also occur.
and stat(2) actually documents EACCES.
Quoted 2 lines
-EIOis generic I/O error. And I think that this error code could be returned by any I/O syscall when unknown I/O error occurs.
Makes sense.
Quoted 3 lines
Returning
-ENODATAfor generic or unknown I/O error is a bad idea because ENODATA (= ENOATTR) has already specific meaning when attribute does not exists at all (or process does not have access to it).
You are right.
Quoted 3 lines
For me it makes sense to return
-EIOand-EPERMby those syscalls. But forgetxattr()we cannot do it due that backward compatibility needed by getcifsacl application.
-EACCES seems the correct one. But yeah, we can't do it due to
getcifsacl(1) relying on -EIO.
Quoted 61 lines · Paulo Alcantara
Quoted 35 lines · Pali Rohár
Quoted 26 lines · On Wednesday 12 February 2025 19:19:00 Paulo Alcantara wrote:
Quoted 10 lines · Pali Rohár
Quoted 9 lines · On Wednesday 12 February 2025 17:49:31 Paulo Alcantara wrote:
Steve,
The commit
438e2116d7bd("cifs: Change translation ofSTATUS_PRIVILEGE_NOT_HELDto-EPERM") regressed getcifsacl(1) because it expects-EIOto be returned from getxattr(2) when the client can't read system.cifs_ntsd_full attribute and then fall back to system.cifs_acl attribute. Either-EIOor-EPERMis wrong for getxattr(2), but that's a different problem, though.Quoted 5 lines
Quoted 1 line
Reproduced against samba-4.22 server.
That is bad. I can prepare a fix for cifs.ko getxattr syscall to translate
-EPERMto-EIO. This will ensure that getcifsacl will work as before as it would still see-EIOerror.Sounds good.
Quoted 3 lines
But as discussed before, we need to distinguish between privilege/permission error and other generic errors (access/io). So I think that we need
438e2116d7bdcommit.OK.
Quoted 7 lines
Quoted 3 lines
Based on linux-fsdevel discussion it is a good idea to distinguish between errors by mapping status codes to appropriate posix errno, and then updating linux syscall manpages.
Either way, we shouldn't be leaking
-EIOor-EPERMto userland from getxattr(2). By looking at the man pages,-ENODATAseems to be the appropriate error to return instead.Quoted 7 lines
It looks like there are missing error codes for getxattr. Because any path based syscall can return
-EACCESif trying to open path to which calling process does not have access.And EACCES is not mentioned nor documented in getxattr(2). Same applies for listxattr(2). Now I have tried
listxattr()and it really returns EACCES for/root/filecalled by nobody.Both man pages have this:
> In addition, the errors documented in stat(2) can also occur.
and stat(2) actually documents EACCES.
Quoted 2 lines
-EIOis generic I/O error. And I think that this error code could be returned by any I/O syscall when unknown I/O error occurs.Makes sense.
Quoted 3 lines
Returning
-ENODATAfor generic or unknown I/O error is a bad idea because ENODATA (= ENOATTR) has already specific meaning when attribute does not exists at all (or process does not have access to it).
Quoted 8 lines
You are right.
Quoted 3 lines
For me it makes sense to return
-EIOand-EPERMby those syscalls. But forgetxattr()we cannot do it due that backward compatibility needed by getcifsacl application.
-EACCESseems the correct one. But yeah, we can't do it due to
getcifsacl(1) relying on-EIO.
Since EIO is incorrect, we probably should fix getcifsacl ASAP so we can start returning something more correct for this call e.g. -EACCESS or -EPERM
Since updating cifs-utils for newer kernels is relatively easy (and the next version of cifs-utils has some security fixes so will be easier to rollout), why don't we also change getcifsacl ASAP to handle the correct rc to give us more freedom for cifs.ko to return the correct error on newer kernels. Thoughts about this change to getcifsacl() function which would work with both old and newer kernels with the rc mapping change? Change to fix the cifs.ko mapping to EIO could be delayed as well so cifs-utils with the updated check is rolled out?!
getcifsacl.c +0 -1
@@ -447,7 +447,8 @@ getxattr:free (attrval); bufsize +=BUFSIZE ; goto cifsacl; - } else if (errno == EIO && !(strcmp(attrname,
ATTRNAME_NTSD_FULL))) {
+ } else if (((errno == EIO) || (errno == EPERM) ||
(errno == EACCES)) &&
+ !(strcmp(attrname, ATTRNAME_NTSD_FULL))) {
/*
* attempt to fetch SACL in addition to owner
and DACL via
* ATTRNAME_NTSD_FULL, fall back to owner/DACL via
Thanks,
Steve
getcifsacl.c +2 -1
@@ -447,7 +447,8 @@ getxattr:free (attrval); bufsize +=BUFSIZE ; goto cifsacl; - }else if (errno ==EIO && !(strcmp (attrname,ATTRNAME_NTSD_FULL ))) { + }else if (((errno ==EIO ) || (errno ==EPERM ) || (errno ==EACCES )) && + !(strcmp (attrname,ATTRNAME_NTSD_FULL ))) {/* * attempt to fetch SACL in addition to owner and DACL via * ATTRNAME_NTSD_FULL, fall back to owner/DACL via
Quoted 75 lines · On Wednesday 12 February 2025 17:47:19 Steve French wrote:
Quoted 61 lines · Paulo Alcantara
Quoted 35 lines · Pali Rohár
Quoted 26 lines · On Wednesday 12 February 2025 19:19:00 Paulo Alcantara wrote:
Quoted 10 lines · Pali Rohár
Quoted 9 lines · On Wednesday 12 February 2025 17:49:31 Paulo Alcantara wrote:
Steve,
The commit
438e2116d7bd("cifs: Change translation ofSTATUS_PRIVILEGE_NOT_HELDto-EPERM") regressed getcifsacl(1) because it expects-EIOto be returned from getxattr(2) when the client can't read system.cifs_ntsd_full attribute and then fall back to system.cifs_acl attribute. Either-EIOor-EPERMis wrong for getxattr(2), but that's a different problem, though.Quoted 5 lines
Quoted 1 line
Reproduced against samba-4.22 server.
That is bad. I can prepare a fix for cifs.ko getxattr syscall to translate
-EPERMto-EIO. This will ensure that getcifsacl will work as before as it would still see-EIOerror.Sounds good.
Quoted 3 lines
But as discussed before, we need to distinguish between privilege/permission error and other generic errors (access/io). So I think that we need
438e2116d7bdcommit.OK.
Quoted 7 lines
Quoted 3 lines
Based on linux-fsdevel discussion it is a good idea to distinguish between errors by mapping status codes to appropriate posix errno, and then updating linux syscall manpages.
Either way, we shouldn't be leaking
-EIOor-EPERMto userland from getxattr(2). By looking at the man pages,-ENODATAseems to be the appropriate error to return instead.Quoted 7 lines
It looks like there are missing error codes for getxattr. Because any path based syscall can return
-EACCESif trying to open path to which calling process does not have access.And EACCES is not mentioned nor documented in getxattr(2). Same applies for listxattr(2). Now I have tried
listxattr()and it really returns EACCES for/root/filecalled by nobody.Both man pages have this:
> In addition, the errors documented in stat(2) can also occur.
and stat(2) actually documents EACCES.
Quoted 2 lines
-EIOis generic I/O error. And I think that this error code could be returned by any I/O syscall when unknown I/O error occurs.Makes sense.
Quoted 3 lines
Returning
-ENODATAfor generic or unknown I/O error is a bad idea because ENODATA (= ENOATTR) has already specific meaning when attribute does not exists at all (or process does not have access to it).Quoted 8 lines
You are right.
Quoted 3 lines
For me it makes sense to return
-EIOand-EPERMby those syscalls. But forgetxattr()we cannot do it due that backward compatibility needed by getcifsacl application.
-EACCESseems the correct one. But yeah, we can't do it due to
getcifsacl(1) relying on-EIO.Since EIO is incorrect, we probably should fix getcifsacl ASAP so we can start returning something more correct for this call e.g.
-EACCESSor-EPERM
Quoted 9 lines
Since updating cifs-utils for newer kernels is relatively easy (and the next version of cifs-utils has some security fixes so will be easier to rollout), why don't we also change getcifsacl ASAP to handle the correct rc to give us more freedom for cifs.ko to return the correct error on newer kernels. Thoughts about this change to
getcifsacl()function which would work with both old and newer kernels with the rc mapping change? Change to fix the cifs.ko mapping to EIO could be delayed as well so cifs-utils with the updated check is rolled out?!
That should work too.
Anyway, if I'm looking correctly at that getcifsacl.c code, it contains fallback from fetching SACL+DACL attribute (ATTRNAME_NTSD_FULL) to DACL-only attribute.
And if the user does not have permission to access SACL then STATUS_PRIVILEGE_NOT_HELD is returned by the SMB server. STATUS_PRIVILEGE_NOT_HELD is being mapped to EPERM.
So EACCES should not be needed there.
If SMB server returns STATUS_ACCESS_DENIED (EACCES) then it means that user does not have access to path or DACL, and so fallback from SACL+DACL (ATTRNAME_NTSD_FULL) to DACL-only attribute is useless.
Quoted 23 lines
getcifsacl.c +1
-1@@ -447,7 +447,8 @@ getxattr:free (attrval); bufsize +=BUFSIZE ; goto cifsacl; - }else if (errno ==EIO && !(strcmp (attrname, ATTRNAME_NTSD_FULL))) { + } else if (((errno == EIO) || (errno == EPERM) ||(errno == EACCES)) &&
+ !(strcmp(attrname,ATTRNAME_NTSD_FULL))) {
/*
* attempt to fetch SACL in addition to owner
and DACL via
*ATTRNAME_NTSD_FULL, fall back to owner/DACL viaThanks,
Steve
ok - how about this updated patch to getcifsacl?
Presumably the rc check for the getcifsacl retry is only needed by more cifs-utils in last four years
due to this patch.
Author: Boris Protopopov <[email protected]> Date: Thu Nov 19 21:40:42 2020 +0000
Extend cifs acl utilities to handle SACLs
Extend getcifsacl/setcifsacl utilities to handle System ACLs (SACLs) in addition to Discretionary ACLs (DACLs). The SACL extensions depend on CIFS client support for system.cifs_ntsd_full extended attribute.
Quoted 126 lines · Pali Rohár
Quoted 75 lines · On Wednesday 12 February 2025 17:47:19 Steve French wrote:
Quoted 61 lines · Paulo Alcantara
Quoted 35 lines · Pali Rohár
Quoted 26 lines · On Wednesday 12 February 2025 19:19:00 Paulo Alcantara wrote:
Quoted 10 lines · Pali Rohár
Quoted 9 lines · On Wednesday 12 February 2025 17:49:31 Paulo Alcantara wrote:
Steve,
The commit
438e2116d7bd("cifs: Change translation ofSTATUS_PRIVILEGE_NOT_HELDto-EPERM") regressed getcifsacl(1) because it expects-EIOto be returned from getxattr(2) when the client can't read system.cifs_ntsd_full attribute and then fall back to system.cifs_acl attribute. Either-EIOor-EPERMis wrong for getxattr(2), but that's a different problem, though.Quoted 5 lines
Quoted 1 line
Reproduced against samba-4.22 server.
That is bad. I can prepare a fix for cifs.ko getxattr syscall to translate
-EPERMto-EIO. This will ensure that getcifsacl will work as before as it would still see-EIOerror.Sounds good.
Quoted 3 lines
But as discussed before, we need to distinguish between privilege/permission error and other generic errors (access/io). So I think that we need
438e2116d7bdcommit.OK.
Quoted 7 lines
Quoted 3 lines
Based on linux-fsdevel discussion it is a good idea to distinguish between errors by mapping status codes to appropriate posix errno, and then updating linux syscall manpages.
Either way, we shouldn't be leaking
-EIOor-EPERMto userland from getxattr(2). By looking at the man pages,-ENODATAseems to be the appropriate error to return instead.Quoted 7 lines
It looks like there are missing error codes for getxattr. Because any path based syscall can return
-EACCESif trying to open path to which calling process does not have access.And EACCES is not mentioned nor documented in getxattr(2). Same applies for listxattr(2). Now I have tried
listxattr()and it really returns EACCES for/root/filecalled by nobody.Both man pages have this:
> In addition, the errors documented in stat(2) can also occur.
and stat(2) actually documents EACCES.
Quoted 2 lines
-EIOis generic I/O error. And I think that this error code could be returned by any I/O syscall when unknown I/O error occurs.Makes sense.
Quoted 3 lines
Returning
-ENODATAfor generic or unknown I/O error is a bad idea because ENODATA (= ENOATTR) has already specific meaning when attribute does not exists at all (or process does not have access to it).Quoted 8 lines
You are right.
Quoted 3 lines
For me it makes sense to return
-EIOand-EPERMby those syscalls. But forgetxattr()we cannot do it due that backward compatibility needed by getcifsacl application.
-EACCESseems the correct one. But yeah, we can't do it due to
getcifsacl(1) relying on-EIO.Since EIO is incorrect, we probably should fix getcifsacl ASAP so we can start returning something more correct for this call e.g.
-EACCESSor-EPERMQuoted 9 lines
Since updating cifs-utils for newer kernels is relatively easy (and the next version of cifs-utils has some security fixes so will be easier to rollout), why don't we also change getcifsacl ASAP to handle the correct rc to give us more freedom for cifs.ko to return the correct error on newer kernels. Thoughts about this change to
getcifsacl()function which would work with both old and newer kernels with the rc mapping change? Change to fix the cifs.ko mapping to EIO could be delayed as well so cifs-utils with the updated check is rolled out?!That should work too.
Anyway, if I'm looking correctly at that
getcifsacl.ccode, it contains fallback from fetching SACL+DACL attribute (ATTRNAME_NTSD_FULL) to DACL-only attribute.And if the user does not have permission to access SACL then
STATUS_PRIVILEGE_NOT_HELDis returned by the SMB server.STATUS_PRIVILEGE_NOT_HELDis being mapped to EPERM.So EACCES should not be needed there.
If SMB server returns
STATUS_ACCESS_DENIED(EACCES) then it means that user does not have access to path or DACL, and so fallback from SACL+DACL (ATTRNAME_NTSD_FULL) to DACL-only attribute is useless.Quoted 23 lines
getcifsacl.c +1
-1@@ -447,7 +447,8 @@ getxattr:free (attrval); bufsize +=BUFSIZE ; goto cifsacl; - }else if (errno ==EIO && !(strcmp (attrname, ATTRNAME_NTSD_FULL))) { + } else if (((errno == EIO) || (errno == EPERM) ||(errno == EACCES)) &&
+ !(strcmp(attrname,ATTRNAME_NTSD_FULL))) {
/*
* attempt to fetch SACL in addition to owner
and DACL via
*ATTRNAME_NTSD_FULL, fall back to owner/DACL viaThanks,
Steve
Signature · 3 lines
Thanks, Steve
From 6b1bd1d5f96fd64fc697ccde671d63799c75ed8a Mon Sep 17 00:00:00 2001
From: Steve French <[email protected]>
Date: Wed, 12 Feb 2025 20:22:00 -0600
Subject: [PATCH] getcifsacl: fix return code check for getting full ACL
Older clients incorrectly mapped STATUS_PRIVILEGE_NOT_HELD to EIO instead of EPERM, so make sure we check for either of these rc when deciding whether to fall back to querying just the DACL (and owner) when querying the complete ACL including SACL (ie Auditing information) fails with insufficient permissions.
--- getcifsacl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
getcifsacl.c +3 -2
@@ -447,12 +447,13 @@ getxattr:free (attrval); bufsize +=BUFSIZE ; goto cifsacl; - }else if (errno ==EIO && !(strcmp (attrname,ATTRNAME_NTSD_FULL ))) { + }else if (((errno ==EIO ) || (errno ==EPERM )) && + !(strcmp (attrname,ATTRNAME_NTSD_FULL ))) {/* * attempt to fetch SACL in addition to owner and DACL via * ATTRNAME_NTSD_FULL, fall back to owner/DACL via * ATTRNAME_ACL if not allowed -* CIFS client maps STATUS_PRIVILEGE_NOT_HELD to EIO +* Older CIFS client maps STATUS_PRIVILEGE_NOT_HELD to EIO instead of EPERM */ fprintf (stderr,"WARNING: Insufficient priviledges to fetch SACL for %s\n" , filename);
Signature · 1 line
2.43.0
Paulo Alcantara
Reviewed-byQuoted 1 line · Steve French
ok - how about this updated patch to getcifsacl?
LGTM. Please also make sure to add:
Quoted 1 line · On Wednesday 12 February 2025 20:46:35 Steve French wrote:
ok - how about this updated patch to getcifsacl?
Looks good.
As an additional improvement it would be nice to show exact reason what is missing in error message - missing SeSecurityPrivilege privilege. Because just generic error "Insufficient priviledges" does not say what exactly is missing.
Quoted 12 lines · On Wednesday 12 February 2025 19:19:00 Paulo Alcantara wrote:
Quoted 10 lines · Pali Rohár
Quoted 9 lines · On Wednesday 12 February 2025 17:49:31 Paulo Alcantara wrote:
Steve,
The commit
438e2116d7bd("cifs: Change translation ofSTATUS_PRIVILEGE_NOT_HELDto-EPERM") regressed getcifsacl(1) because it expects-EIOto be returned from getxattr(2) when the client can't read system.cifs_ntsd_full attribute and then fall back to system.cifs_acl attribute. Either-EIOor-EPERMis wrong for getxattr(2), but that's a different problem, though.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Reproduced against samba-4.22 server.
That is bad. I can prepare a fix for cifs.ko getxattr syscall to translate
-EPERMto-EIO. This will ensure that getcifsacl will work as before as it would still see-EIOerror.Sounds good.
Now I quickly prepared a fix, it is straightforward but I have not tested it yet. Testing requires non-admin user which does not have SeSecurityPrivilege privilege configured. Could you check if it is fixing this problem?
From c9032ef054acd0a92ea641dc33a7b62a5833e00c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <[email protected]>
Date: Thu, 13 Feb 2025 19:37:29 +0100
Subject: [PATCH] cifs: Reports -EIO for getxattr(system.cifs_ntsd_full)
privilege error
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Commit 438e2116d7bd ("cifs: Change translation of STATUS_PRIVILEGE_NOT_HELD to -EPERM") globally changed translation of STATUS_PRIVILEGE_NOT_HELD status code from -EIO to -EPERM which is more appropriate errno code.
Unfortunately it broke getcifsacl utility when called by user which does not have SeSecurityPrivilege privilege, which is required to fetch SACLs.
Userspace utility getcifsacl expects that kernel reports privilege error for system.cifs_ntsd_full xattr as EIO errno, not as EPERM errno.
When privilege error via EIO errno is detected then getcifsacl request security descriptor without SACLs via system.cifs_acl xattr. This is allowed also without SeSecurityPrivilege privilege.
This change fixes the errno returned by getxattr(system.cifs_ntsd_full) call, as required by backward compatibility for getcifsacl utility. With this change EIO is returned as before the mentioned commit.
--- fs/smb/client/xattr.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
fs/smb/client/xattr.c +14 -0
@@ -331,6 +331,20 @@ static int cifs_xattr_get(const struct xattr_handler *handler, rc =PTR_ERR (pacl);cifs_dbg (VFS ,"%s: error %zd getting sec desc\n" , __func__, rc); +if (rc == -EPERM && handler->flags ==XATTR_CIFS_NTSD_FULL ) { +/* +* Report STATUS_PRIVILEGE_NOT_HELD error (signaled by -EPERM) +* to userspace as EIO errno for system.cifs_ntsd_full xattr. +* This is backward compatibility for old version of getcifsacl +* utility which is doing fallback from system.cifs_ntsd_full xattr +* to system.cifs_acl xattr when user does not have privilege to +* fetch SACL and expects that kernel reports insufficient privilege +* error via EIO errno (instead of EPERM errno). +*/ + rc = -EIO ; +cifs_dbg (FYI ,"%s: error changed to %zd for compatibility\n" , + __func__, rc); + } }else {if (value) {if (acllen > size)
Signature · 1 line
2.20.1
This change to fs/smb/client/xattr.c is probably safe, and presumably could be removed in future kernels in a year or two as the updated cifs-utils which properly checks the error codes is rolled out broadly.
Quoted 26 lines · Pali Rohár
Quoted 12 lines · On Wednesday 12 February 2025 19:19:00 Paulo Alcantara wrote:
Quoted 10 lines · Pali Rohár
Quoted 9 lines · On Wednesday 12 February 2025 17:49:31 Paulo Alcantara wrote:
Steve,
The commit
438e2116d7bd("cifs: Change translation ofSTATUS_PRIVILEGE_NOT_HELDto-EPERM") regressed getcifsacl(1) because it expects-EIOto be returned from getxattr(2) when the client can't read system.cifs_ntsd_full attribute and then fall back to system.cifs_acl attribute. Either-EIOor-EPERMis wrong for getxattr(2), but that's a different problem, though.Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Reproduced against samba-4.22 server.
That is bad. I can prepare a fix for cifs.ko getxattr syscall to translate
-EPERMto-EIO. This will ensure that getcifsacl will work as before as it would still see-EIOerror.Sounds good.
Now I quickly prepared a fix, it is straightforward but I have not tested it yet. Testing requires non-admin user which does not have SeSecurityPrivilege privilege configured. Could you check if it is fixing this problem?
Signature · 3 lines
Thanks, Steve
Hello, I would like to ask, how you handled this regression? Have you taken this my fix to address it? Or is it going to be addresses in other way?
Quoted 39 lines · On Thursday 13 February 2025 12:52:50 Steve French wrote:
This change to
fs/smb/client/xattr.cis probably safe, and presumably could be removed in future kernels in a year or two as the updated cifs-utils which properly checks the error codes is rolled out broadly.Quoted 26 lines · Pali Rohár
Quoted 12 lines · On Wednesday 12 February 2025 19:19:00 Paulo Alcantara wrote:
Quoted 10 lines · Pali Rohár
Quoted 9 lines · On Wednesday 12 February 2025 17:49:31 Paulo Alcantara wrote:
Steve,
The commit
438e2116d7bd("cifs: Change translation ofSTATUS_PRIVILEGE_NOT_HELDto-EPERM") regressed getcifsacl(1) because it expects-EIOto be returned from getxattr(2) when the client can't read system.cifs_ntsd_full attribute and then fall back to system.cifs_acl attribute. Either-EIOor-EPERMis wrong for getxattr(2), but that's a different problem, though.Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Reproduced against samba-4.22 server.
That is bad. I can prepare a fix for cifs.ko getxattr syscall to translate
-EPERMto-EIO. This will ensure that getcifsacl will work as before as it would still see-EIOerror.Sounds good.
Now I quickly prepared a fix, it is straightforward but I have not tested it yet. Testing requires non-admin user which does not have SeSecurityPrivilege privilege configured. Could you check if it is fixing this problem?
Signature · 3 lines
Thanks, Steve
Quoted 3 lines · Pali Rohár
Hello, I would like to ask, how you handled this regression? Have you taken this my fix to address it? Or is it going to be addresses in other way?
It's already fixed in cifs-utils-7.2 by commit 8b4b6e459d2a ("getcifsacl: fix return code check for getting full ACL").
Quoted 8 lines · On Sunday 23 March 2025 21:36:56 Paulo Alcantara wrote:
Quoted 3 lines · Pali Rohár
Hello, I would like to ask, how you handled this regression? Have you taken this my fix to address it? Or is it going to be addresses in other way?
It's already fixed in cifs-utils-7.2 by commit
8b4b6e459d2a("getcifsacl: fix return code check for getting full ACL").
Ok, and into kernel is not going to be addressed that regression for older cifs-utils?
Quoted 8 lines · Pali Rohár
Quoted 6 lines · On Sunday 23 March 2025 21:36:56 Paulo Alcantara wrote:
Quoted 3 lines · Pali Rohár
Hello, I would like to ask, how you handled this regression? Have you taken this my fix to address it? Or is it going to be addresses in other way?
Quoted 5 lines
Quoted 2 lines
It's already fixed in cifs-utils-7.2 by commit
8b4b6e459d2a("getcifsacl: fix return code check for getting full ACL").Ok, and into kernel is not going to be addressed that regression for older cifs-utils?
I thought we had decided that it was risky to intentionally return the wrong return code to
userspace, to workaround an app bug (especially since it is easier to update cifs-utils than update the kernel, and also since cifs-utils update to 7.3 is strongly
encouraged for users due to multiple security issues fixed)
Signature · 3 lines
Thanks, Steve
Quoted 15 lines · On Monday 24 March 2025 10:33:06 Steve French wrote:
Quoted 8 lines · Pali Rohár
Quoted 6 lines · On Sunday 23 March 2025 21:36:56 Paulo Alcantara wrote:
Quoted 3 lines · Pali Rohár
Hello, I would like to ask, how you handled this regression? Have you taken this my fix to address it? Or is it going to be addresses in other way?
Quoted 5 lines
Quoted 2 lines
It's already fixed in cifs-utils-7.2 by commit
8b4b6e459d2a("getcifsacl: fix return code check for getting full ACL").Ok, and into kernel is not going to be addressed that regression for older cifs-utils?
Quoted 11 lines
I thought we had decided that it was risky to intentionally return the wrong return code to
userspace, to workaround an app bug (especially since it is easier to update cifs-utils than update the kernel, and also since cifs-utils update to 7.3 is strongly
encouraged for users due to multiple security issues fixed)Signature · 3 lines
Thanks, Steve
Ok, fine. I just wanted to be sure that we have not forgot for something.
Quoted 1 line
I just wanted to be sure that we have not forgot for something
On that subject, given the business of the week (LSF/MM/Storage summit) and merge window opening up, it is very possible we could miss patches (and over 40 of yours to still rereview as well, and decide what is safest to cherrypick of those) - so let me know if I have
missed critical patches. There are some very urgent ones (e.g.
finding out why multichannel to ksmbd broke just before 6.13 kernel came out) and the directory lease fixes (and perf improvements)
Quoted 30 lines · Pali Rohár
Quoted 22 lines · On Monday 24 March 2025 10:33:06 Steve French wrote:
Quoted 8 lines · Pali Rohár
Quoted 6 lines · On Sunday 23 March 2025 21:36:56 Paulo Alcantara wrote:
Quoted 3 lines · Pali Rohár
Hello, I would like to ask, how you handled this regression? Have you taken this my fix to address it? Or is it going to be addresses in other way?
Quoted 5 lines
Quoted 2 lines
It's already fixed in cifs-utils-7.2 by commit
8b4b6e459d2a("getcifsacl: fix return code check for getting full ACL").Ok, and into kernel is not going to be addressed that regression for older cifs-utils?
I thought we had decided that it was risky to intentionally return the wrong return code to
userspace, to workaround an app bug (especially since it is easier to update cifs-utils than update the kernel, and also since cifs-utils update to 7.3 is strongly
encouraged for users due to multiple security issues fixed)Quoted 4 lines
--
Thanks,Steve
Ok, fine. I just wanted to be sure that we have not forgot for something.
Signature · 3 lines
Thanks, Steve