From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 003B7C982D2 for ; Fri, 18 Sep 2026 04:27:46 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x7QAi-0005nH-Ta; Fri, 18 Sep 2026 00:26:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x7QAd-0005cw-3I for qemu-devel@nongnu.org; Fri, 18 Sep 2026 00:25:55 -0400 Received: from mail-oi2-x24.google.com ([2607:f8b0:4864:32::24]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x7QAb-0004PU-5r for qemu-devel@nongnu.org; Fri, 18 Sep 2026 00:25:54 -0400 Received: by mail-oi2-x24.google.com with SMTP id 46e09a7af769-7f4f0dd5507so111716a34.3 for ; Thu, 17 Sep 2026 21:25:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20251104.gappssmtp.com; s=20251104; t=1789705552; x=1790310352; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=NrpL46Nay44SFqEpTz9O0LUdm+A+DGPsy/qGZpi6vus=; b=MqtiBM2cJr4lVF3QFkrgK9UT/YF1HBDq+9K0GMIwyhIiwPUqltTNSB5fkxomB3pq2D Qm051X/cdiLNnr7g4HVRhibengyM695eGlcJ32cIRshyCq6DyoR5opw9jzxEFwNGxXLE QqmrdcqvdhkLDurkdrmyjgaK5XoqpzBeX+Y8RZJKJMO1qFby60jVSmPK5vEiWG+742/2 ikL3sqebYhK64i6p2xj0D1FiB6dFn51e0Z+mah9Cziyp6s5ld4TatOQscSgxQklv+TLg YtIqizwn7VZIy5IKPs6FwkxdWhm36+DXpqVhrmspt91eo5chCxw9YNG5j1/+Uf2HCFm2 xd8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789705552; x=1790310352; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=NrpL46Nay44SFqEpTz9O0LUdm+A+DGPsy/qGZpi6vus=; b=eRn59AjSWo6tx4k24TtMlVK+iR70+JWql2TEmlHzIkoUDEQky3fSKZlOTwGXIigx3+ 5Y3XUkIhSXNtZymi5PEmf4FCSuc8KJzN/jxqVC20IBQf+/gm7OUZnyhlAvCLuOcmQ8un vk913I8AgwsOtuC6c3LGipIai8Atm9v4NLamvUrRGu2F1xQT1Yxv5kODrDW3dF1IVPj/ EzTT338ja5Mjm3JSasFVAICn1H6FZBq8USPxbhWD8XX+CfUuzyN5fEjKgctggx1ZYOPw pkDZB0yuOnNnLHGqFpxxrsXqC8/2PTfYzkKsMQ3q9CHqQrhvUegmb/X7kOu6EkHgoGcB ZreQ== X-Gm-Message-State: AFuF++mEFVjQ67Q+EmzcIbzr5MF0VzoOddCfGMeVsl2lQrRIU8moFTCB 7ptcIBiCHy0OR5itIFciqP4GYVZttKgX7t/O4HhPNIE2bmgmzMIEZ4ELeVYR7l3cMcWAKNg70j7 U9+tFcgQ= X-Gm-Gg: AYBFou1apzoUFISRbFnisM1Fr9bpVerszCpjvzUM6ldnvefJLuT+WgphIz1F1hSt5Ir kvp6Y3Ic75GP1vFW198bx7szKIIZVp3xgWvN3tpcb1mbPgjsKYddP2fsnY0fGi5A1G06S4YXYt0 freV3D/Xcdxwv15oiXLCLs9/4JcA4HtIi/CZEoXc1E2xo9sD9LbtUFIHHoFTIOvuVzgfKyu614Y tMUF/OzzmGBAwg8BRICGjh/D2fkYzM04kQiVOF7+imlDIvwNN26GFdEyMnFcT4aXZgz6aCtbn1O kQOExMgbSitqaWOfZX+SvMEJgVRKUn2GFb0uPrXHCcNjMbEo1gtTRrszEfCt/YbkIPFKU6GZhES McUE2Z9OUvBtkXhinh4OCBIxjFXF6AQ/zccprJgnoQ9xe+JF2LlJs3glAWO7/1xWE2izF4jvWB5 l0nFyAARGFxoS3/8DixF8783ywdYB6hl7wKgWzgoKM2/oWlP6wDv6EZ5Hh5A== X-Received: by 2002:a05:6830:7312:b0:7fa:ab72:9df8 with SMTP id 46e09a7af769-80de33e988cmr1692051a34.16.1789705552015; Thu, 17 Sep 2026 21:25:52 -0700 (PDT) Received: from rebo.bsdimp.com ([50.253.99.174]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-80e51d627b5sm489718a34.20.2026.09.17.21.25.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2026 21:25:51 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Kyle Evans , Warner Losh , Stacey Son , Richard Henderson Subject: [PULL 35/41] bsd-user: Add ACL system call shims to os-extattr.h Date: Thu, 17 Sep 2026 22:24:16 -0600 Message-ID: <20260918042422.38713-36-imp@bsdimp.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260918042422.38713-1-imp@bsdimp.com> References: <20260918042422.38713-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: none client-ip=2607:f8b0:4864:32::24; envelope-from=imp@bsdimp.com; helo=mail-oi2-x24.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 Assisted-by: Claude Opus 4.6 (1M context) Acked-by: Richard Henderson Signed-off-by: Warner Losh --- bsd-user/freebsd/os-extattr.h | 289 +++++++++++++++++++++++++++++++++- 1 file changed, 285 insertions(+), 4 deletions(-) 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; +} -- 2.55.0