Commit 08aa32d881 for qemu.org
commit 08aa32d881ae81630d39a74223f63b78d54cae19
Author: Warner Losh <imp@bsdimp.com>
Date: Tue May 5 00:35:43 2026 -0600
bsd-user: Add ACL system call shims to os-extattr.h
Complete os-extattr.h with ACL operations: __acl_aclcheck_fd,
__acl_aclcheck_file, __acl_aclcheck_link, __acl_delete_fd,
__acl_delete_file, __acl_delete_link, __acl_get_fd, __acl_get_file,
__acl_get_link, __acl_set_fd, __acl_set_file, and __acl_set_link.
Signed-off-by: Stacey Son <sson@FreeBSD.org>
Assisted-by: Claude Opus 4.6 (1M context)
Acked-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
diff --git a/bsd-user/freebsd/os-extattr.h b/bsd-user/freebsd/os-extattr.h
index 90f0c64c93..b6fe9051f1 100644
--- a/bsd-user/freebsd/os-extattr.h
+++ b/bsd-user/freebsd/os-extattr.h
@@ -65,7 +65,7 @@ static inline abi_long do_freebsd_extattr_set_file(abi_long arg1,
return -TARGET_EFAULT;
}
ret = get_errno(extattr_set_file(path(p), arg2, a, d, arg5));
- unlock_user(d, arg4, arg5);
+ unlock_user(d, arg4, 0);
unlock_user(a, arg3, 0);
unlock_user(p, arg1, 0);
@@ -151,7 +151,7 @@ static inline abi_long do_freebsd_extattr_set_fd(abi_long arg1, abi_long arg2,
return -TARGET_EFAULT;
}
ret = get_errno(extattr_set_fd(arg1, arg2, a, d, arg5));
- unlock_user(d, arg4, arg5);
+ unlock_user(d, arg4, 0);
unlock_user(a, arg3, 0);
return ret;
@@ -267,7 +267,7 @@ static inline abi_long do_freebsd_extattr_set_link(abi_long arg1,
return -TARGET_EFAULT;
}
ret = get_errno(extattr_set_link(path(p), arg2, a, d, arg5));
- unlock_user(d, arg4, arg5);
+ unlock_user(d, arg4, 0);
unlock_user(a, arg3, 0);
unlock_user(p, arg1, 0);
@@ -376,5 +376,286 @@ static inline abi_long do_freebsd_extattr_list_link(
* Access Control Lists
*/
+/* __acl_aclcheck_fd(int filedes, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_aclcheck_fd(abi_long arg1, abi_long arg2,
+ abi_long arg3)
+{
+ abi_long ret;
+ struct acl host_acl;
+ acl_type_t type;
+
+ ret = t2h_freebsd_acl_type(&type, arg2);
+ if (is_error(ret)) {
+ return ret;
+ }
+ ret = t2h_freebsd_acl(&host_acl, arg3);
+ if (!is_error(ret)) {
+ ret = get_errno(__acl_aclcheck_fd(arg1, type, &host_acl));
+ }
+
+ return ret;
+}
+
+/* __acl_aclcheck_file(const char *path, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_aclcheck_file(abi_long arg1,
+ abi_long arg2,
+ abi_long arg3)
+{
+ abi_long ret;
+ void *p;
+ struct acl host_acl;
+ acl_type_t type;
+
+ ret = t2h_freebsd_acl_type(&type, arg2);
+ if (is_error(ret)) {
+ return ret;
+ }
+ p = lock_user_string(arg1);
+ if (p == NULL) {
+ return -TARGET_EFAULT;
+ }
+ ret = t2h_freebsd_acl(&host_acl, arg3);
+ if (!is_error(ret)) {
+ ret = get_errno(__acl_aclcheck_file(path(p), type, &host_acl));
+ }
+ unlock_user(p, arg1, 0);
+
+ return ret;
+}
+
+/* __acl_aclcheck_link(const char *path, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_aclcheck_link(abi_long arg1,
+ abi_long arg2,
+ abi_long arg3)
+{
+ abi_long ret;
+ void *p;
+ struct acl host_acl;
+ acl_type_t type;
+
+ ret = t2h_freebsd_acl_type(&type, arg2);
+ if (is_error(ret)) {
+ return ret;
+ }
+ p = lock_user_string(arg1);
+ if (p == NULL) {
+ return -TARGET_EFAULT;
+ }
+ ret = t2h_freebsd_acl(&host_acl, arg3);
+ if (!is_error(ret)) {
+ ret = get_errno(__acl_aclcheck_link(path(p), type, &host_acl));
+ }
+ unlock_user(p, arg1, 0);
+
+ return ret;
+}
+
+/* int __acl_delete_fd(int filedes, acl_type_t type); */
+static inline abi_long do_freebsd__acl_delete_fd(abi_long arg1, abi_long arg2)
+{
+ abi_long ret;
+ acl_type_t type;
+
+ ret = t2h_freebsd_acl_type(&type, arg2);
+ if (is_error(ret)) {
+ return ret;
+ }
+ return get_errno(__acl_delete_fd(arg1, type));
+}
+
+/* int __acl_delete_file(const char *path, acl_type_t type); */
+static inline abi_long do_freebsd__acl_delete_file(abi_long arg1,
+ abi_long arg2)
+{
+ abi_long ret;
+ void *p;
+ acl_type_t type;
+
+ ret = t2h_freebsd_acl_type(&type, arg2);
+ if (is_error(ret)) {
+ return ret;
+ }
+ p = lock_user_string(arg1);
+ if (p == NULL) {
+ return -TARGET_EFAULT;
+ }
+ ret = get_errno(__acl_delete_file(path(p), type));
+ unlock_user(p, arg1, 0);
+
+ return ret;
+}
+
+/* int __acl_delete_link(const char *path, acl_type_t type); */
+static inline abi_long do_freebsd__acl_delete_link(abi_long arg1,
+ abi_long arg2)
+{
+ abi_long ret;
+ void *p;
+ acl_type_t type;
+
+ ret = t2h_freebsd_acl_type(&type, arg2);
+ if (is_error(ret)) {
+ return ret;
+ }
+ p = lock_user_string(arg1);
+ if (p == NULL) {
+ return -TARGET_EFAULT;
+ }
+ ret = get_errno(__acl_delete_link(path(p), type));
+ unlock_user(p, arg1, 0);
+
+ return ret;
+}
+
+/* int __acl_get_fd(int filedes, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_get_fd(abi_long arg1, abi_long arg2,
+ abi_long arg3)
+{
+ abi_long ret;
+ acl_type_t type;
+ struct acl host_acl;
+
+ memset(&host_acl, 0, sizeof(struct acl));
+ host_acl.acl_maxcnt = ACL_MAX_ENTRIES;
-#endif /* FREEBSD_OS_EXTATTR_H */
+ ret = t2h_freebsd_acl_type(&type, arg2);
+ if (is_error(ret)) {
+ return ret;
+ }
+ ret = get_errno(__acl_get_fd(arg1, type, &host_acl));
+ if (!is_error(ret)) {
+ ret = h2t_freebsd_acl(arg3, &host_acl);
+ }
+
+ return ret;
+}
+
+/* __acl_get_file(const char *path, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_get_file(abi_long arg1, abi_long arg2,
+ abi_long arg3)
+{
+ abi_long ret;
+ void *p;
+ acl_type_t type;
+ struct acl host_acl;
+
+ memset(&host_acl, 0, sizeof(struct acl));
+ host_acl.acl_maxcnt = ACL_MAX_ENTRIES;
+
+ ret = t2h_freebsd_acl_type(&type, arg2);
+ if (is_error(ret)) {
+ return ret;
+ }
+ p = lock_user_string(arg1);
+ if (p == NULL) {
+ return -TARGET_EFAULT;
+ }
+ ret = get_errno(__acl_get_file(path(p), type, &host_acl));
+ if (!is_error(ret)) {
+ ret = h2t_freebsd_acl(arg3, &host_acl);
+ }
+ unlock_user(p, arg1, 0);
+
+ return ret;
+}
+
+/* int __acl_get_link(const char *path, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_get_link(abi_long arg1, abi_long arg2,
+ abi_long arg3)
+{
+ abi_long ret;
+ void *p;
+ acl_type_t type;
+ struct acl host_acl;
+
+ memset(&host_acl, 0, sizeof(struct acl));
+ host_acl.acl_maxcnt = ACL_MAX_ENTRIES;
+
+ ret = t2h_freebsd_acl_type(&type, arg2);
+ if (is_error(ret)) {
+ return ret;
+ }
+ p = lock_user_string(arg1);
+ if (p == NULL) {
+ return -TARGET_EFAULT;
+ }
+ ret = get_errno(__acl_get_link(path(p), type, &host_acl));
+ if (!is_error(ret)) {
+ ret = h2t_freebsd_acl(arg3, &host_acl);
+ }
+ unlock_user(p, arg1, 0);
+
+ return ret;
+}
+
+/* int __acl_set_fd(int filedes, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_set_fd(abi_long arg1, abi_long arg2,
+ abi_long arg3)
+{
+ abi_long ret;
+ acl_type_t type;
+ struct acl host_acl;
+
+ ret = t2h_freebsd_acl_type(&type, arg2);
+ if (is_error(ret)) {
+ return ret;
+ }
+ ret = t2h_freebsd_acl(&host_acl, arg3);
+ if (!is_error(ret)) {
+ ret = get_errno(__acl_set_fd(arg1, type, &host_acl));
+ }
+
+ return ret;
+}
+
+/* int __acl_set_file(const char *path, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_set_file(abi_long arg1, abi_long arg2,
+ abi_long arg3)
+{
+ abi_long ret;
+ void *p;
+ acl_type_t type;
+ struct acl host_acl;
+
+ ret = t2h_freebsd_acl_type(&type, arg2);
+ if (is_error(ret)) {
+ return ret;
+ }
+ p = lock_user_string(arg1);
+ if (p == NULL) {
+ return -TARGET_EFAULT;
+ }
+ ret = t2h_freebsd_acl(&host_acl, arg3);
+ if (!is_error(ret)) {
+ ret = get_errno(__acl_set_file(path(p), type, &host_acl));
+ }
+ unlock_user(p, arg1, 0);
+
+ return ret;
+}
+
+/* int __acl_set_link(const char *path, acl_type_t type, struct acl *aclp); */
+static inline abi_long do_freebsd__acl_set_link(abi_long arg1, abi_long arg2,
+ abi_long arg3)
+{
+ abi_long ret;
+ void *p;
+ acl_type_t type;
+ struct acl host_acl;
+
+ ret = t2h_freebsd_acl_type(&type, arg2);
+ if (is_error(ret)) {
+ return ret;
+ }
+ p = lock_user_string(arg1);
+ if (p == NULL) {
+ return -TARGET_EFAULT;
+ }
+ ret = t2h_freebsd_acl(&host_acl, arg3);
+ if (!is_error(ret)) {
+ ret = get_errno(__acl_set_link(path(p), type, &host_acl));
+ }
+ unlock_user(p, arg1, 0);
+
+ return ret;
+}