mirror of
https://github.com/opnsense/src.git
synced 2026-06-11 09:41:03 -04:00
linux(4): Return ENOTSUP from xattr syscalls instead of EPERM
FreeBSD does not permits manipulating extended attributes in the system
namespace by unprivileged accounts, even if account has appropriate
privileges to access filesystem object.
In Linux the system namespace is used to preserve posix acls. Some Gnu
coreutils binaries uses posix acls, eg, install, ls. And fails if we
unexpectedly return EPERM error from xattr system calls.
In the other hands, in Linux read and write access to the system
namespace depend on the policy implemented for each filesystem, so we'll
mimics we're a filesystem that prohibits this for unpriveleged accounts.
Reported by: zirias
Tested by: zirias
MFC after: 1 week
(cherry picked from commit 1bfc4574f7)
This commit is contained in:
parent
0f35bf8b29
commit
bce9c2e340
1 changed files with 13 additions and 3 deletions
|
|
@ -87,6 +87,16 @@ struct removexattr_args {
|
|||
static char *extattr_namespace_names[] = EXTATTR_NAMESPACE_NAMES;
|
||||
|
||||
|
||||
static int
|
||||
error_to_xattrerror(int attrnamespace, int error)
|
||||
{
|
||||
|
||||
if (attrnamespace == EXTATTR_NAMESPACE_SYSTEM && error == EPERM)
|
||||
return (ENOTSUP);
|
||||
else
|
||||
return (error);
|
||||
}
|
||||
|
||||
static int
|
||||
xatrr_to_extattr(const char *uattrname, int *attrnamespace, char *attrname)
|
||||
{
|
||||
|
|
@ -188,7 +198,7 @@ listxattr(struct thread *td, struct listxattr_args *args)
|
|||
if (error == 0)
|
||||
td->td_retval[0] = cnt;
|
||||
free(data, M_LINUX);
|
||||
return (error);
|
||||
return (error_to_xattrerror(attrnamespace, error));
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -248,7 +258,7 @@ removexattr(struct thread *td, struct removexattr_args *args)
|
|||
else
|
||||
error = kern_extattr_delete_fd(td, args->fd, attrnamespace,
|
||||
attrname);
|
||||
return (error);
|
||||
return (error_to_xattrerror(attrnamespace, error));
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -392,7 +402,7 @@ setxattr(struct thread *td, struct setxattr_args *args)
|
|||
attrname, args->value, args->size);
|
||||
out:
|
||||
td->td_retval[0] = 0;
|
||||
return (error);
|
||||
return (error_to_xattrerror(attrnamespace, error));
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
|||
Loading…
Reference in a new issue