17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5ea8dc4b6Seschrock * Common Development and Distribution License (the "License"). 6ea8dc4b6Seschrock * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22134a1f4eSCasper H.S. Dik * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 23*37294019SJerry Jelinek * Copyright 2015, Joyent, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_POLICY_H 277c478bd9Sstevel@tonic-gate #define _SYS_POLICY_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #include <sys/types.h> 307c478bd9Sstevel@tonic-gate #include <sys/cred.h> 317c478bd9Sstevel@tonic-gate #include <sys/vnode.h> 327c478bd9Sstevel@tonic-gate #include <sys/fs/snode.h> 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #ifdef __cplusplus 357c478bd9Sstevel@tonic-gate extern "C" { 367c478bd9Sstevel@tonic-gate #endif 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #ifdef _KERNEL 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate #ifndef _IN_PORT_T 417c478bd9Sstevel@tonic-gate #define _IN_PORT_T 427c478bd9Sstevel@tonic-gate typedef uint16_t in_port_t; 437c478bd9Sstevel@tonic-gate #endif 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate /* 467c478bd9Sstevel@tonic-gate * Policy routines; in case we check privileges in-line. 477c478bd9Sstevel@tonic-gate * 487c478bd9Sstevel@tonic-gate * priv_policy 497c478bd9Sstevel@tonic-gate * privilege debugging 507c478bd9Sstevel@tonic-gate * audits success & failure 517c478bd9Sstevel@tonic-gate * returns 0 on success, error on failure 527c478bd9Sstevel@tonic-gate * 537c478bd9Sstevel@tonic-gate * priv_policy_choice 547c478bd9Sstevel@tonic-gate * determines extend of operation 557c478bd9Sstevel@tonic-gate * audit on success 567c478bd9Sstevel@tonic-gate * returns a boolean_t indicating success (B_TRUE) or failure. 577c478bd9Sstevel@tonic-gate * 587c478bd9Sstevel@tonic-gate * priv_policy_only 597c478bd9Sstevel@tonic-gate * when auditing is in appropriate (interrupt context) 607c478bd9Sstevel@tonic-gate * to determine context of operation 617c478bd9Sstevel@tonic-gate * returns a boolean_t indicating success (B_TRUE) or failure. 627c478bd9Sstevel@tonic-gate * 637c478bd9Sstevel@tonic-gate */ 647c478bd9Sstevel@tonic-gate int priv_policy(const cred_t *, int, boolean_t, int, const char *); 657c478bd9Sstevel@tonic-gate boolean_t priv_policy_only(const cred_t *, int, boolean_t); 667c478bd9Sstevel@tonic-gate boolean_t priv_policy_choice(const cred_t *, int, boolean_t); 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate struct kipc_perm; 697c478bd9Sstevel@tonic-gate struct vfs; 707c478bd9Sstevel@tonic-gate struct proc; 71ddf7fe95Scasper struct priv_set; 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate int secpolicy_acct(const cred_t *); 74ddf7fe95Scasper int secpolicy_require_privs(const cred_t *, const struct priv_set *); 757c478bd9Sstevel@tonic-gate int secpolicy_allow_setid(const cred_t *, uid_t, boolean_t); 767c478bd9Sstevel@tonic-gate int secpolicy_audit_config(const cred_t *); 77134a1f4eSCasper H.S. Dik int secpolicy_audit_getattr(const cred_t *, boolean_t); 787c478bd9Sstevel@tonic-gate int secpolicy_audit_modify(const cred_t *); 797c478bd9Sstevel@tonic-gate int secpolicy_blacklist(const cred_t *); 807c478bd9Sstevel@tonic-gate int secpolicy_chroot(const cred_t *); 817c478bd9Sstevel@tonic-gate int secpolicy_clock_highres(const cred_t *); 827c478bd9Sstevel@tonic-gate int secpolicy_console(const cred_t *); 837b209c2cSacruz int secpolicy_contract_identity(const cred_t *); 847c478bd9Sstevel@tonic-gate int secpolicy_contract_observer(const cred_t *, struct contract *); 857c478bd9Sstevel@tonic-gate boolean_t secpolicy_contract_observer_choice(const cred_t *); 867c478bd9Sstevel@tonic-gate int secpolicy_contract_event(const cred_t *); 877c478bd9Sstevel@tonic-gate boolean_t secpolicy_contract_event_choice(const cred_t *); 887c478bd9Sstevel@tonic-gate int secpolicy_coreadm(const cred_t *); 897c478bd9Sstevel@tonic-gate int secpolicy_cpc_cpu(const cred_t *); 907c478bd9Sstevel@tonic-gate int secpolicy_dispadm(const cred_t *); 917aec1d6eScindi int secpolicy_error_inject(const cred_t *); 927c478bd9Sstevel@tonic-gate int secpolicy_excl_open(const cred_t *); 930fbb751dSJohn Levon int secpolicy_fs_allowed_mount(const char *); 947c478bd9Sstevel@tonic-gate int secpolicy_fs_config(const cred_t *, const struct vfs *); 957c478bd9Sstevel@tonic-gate int secpolicy_fs_linkdir(const cred_t *, const struct vfs *); 967c478bd9Sstevel@tonic-gate int secpolicy_fs_minfree(const cred_t *, const struct vfs *); 970fbb751dSJohn Levon int secpolicy_fs_mount(cred_t *, vnode_t *, struct vfs *); 987c478bd9Sstevel@tonic-gate int secpolicy_fs_quota(const cred_t *, const struct vfs *); 990fbb751dSJohn Levon int secpolicy_fs_unmount(cred_t *, struct vfs *); 100f48205beScasper int secpolicy_idmap(const cred_t *); 101f4b3ec61Sdh155122 int secpolicy_ip(const cred_t *, int, boolean_t); 102f4b3ec61Sdh155122 int secpolicy_ip_config(const cred_t *, boolean_t); 103eae72b5bSSebastien Roy int secpolicy_dl_config(const cred_t *); 1042b24ab6bSSebastien Roy int secpolicy_iptun_config(const cred_t *); 1057c478bd9Sstevel@tonic-gate int secpolicy_ipc_access(const cred_t *, const struct kipc_perm *, mode_t); 1067c478bd9Sstevel@tonic-gate int secpolicy_ipc_config(const cred_t *); 1077c478bd9Sstevel@tonic-gate int secpolicy_ipc_owner(const cred_t *, const struct kipc_perm *); 1087c478bd9Sstevel@tonic-gate int secpolicy_kmdb(const cred_t *); 1097c478bd9Sstevel@tonic-gate int secpolicy_lock_memory(const cred_t *); 110*37294019SJerry Jelinek int secpolicy_meminfo(const cred_t *); 1117c478bd9Sstevel@tonic-gate int secpolicy_modctl(const cred_t *, int); 1127c478bd9Sstevel@tonic-gate int secpolicy_net(const cred_t *, int, boolean_t); 11345916cd2Sjpk int secpolicy_net_bindmlp(const cred_t *); 1147c478bd9Sstevel@tonic-gate int secpolicy_net_config(const cred_t *, boolean_t); 1157c478bd9Sstevel@tonic-gate int secpolicy_net_icmpaccess(const cred_t *); 11645916cd2Sjpk int secpolicy_net_mac_aware(const cred_t *); 1175d3b8cb7SBill Sommerfeld int secpolicy_net_mac_implicit(const cred_t *); 1180a0e9771SDarren Reed int secpolicy_net_observability(const cred_t *); 119ddf7fe95Scasper int secpolicy_net_privaddr(const cred_t *, in_port_t, int proto); 1207c478bd9Sstevel@tonic-gate int secpolicy_net_rawaccess(const cred_t *); 12145916cd2Sjpk boolean_t secpolicy_net_reply_equal(const cred_t *); 1227c478bd9Sstevel@tonic-gate int secpolicy_newproc(const cred_t *); 1237c478bd9Sstevel@tonic-gate int secpolicy_nfs(const cred_t *); 124bbf58fc5S int secpolicy_pbind(const cred_t *); 1257c478bd9Sstevel@tonic-gate int secpolicy_pcfs_modify_bootpartition(const cred_t *); 126134a1f4eSCasper H.S. Dik int secpolicy_pfexec_register(const cred_t *); 1277c478bd9Sstevel@tonic-gate int secpolicy_ponline(const cred_t *); 1287c478bd9Sstevel@tonic-gate int secpolicy_pool(const cred_t *); 1297c478bd9Sstevel@tonic-gate int secpolicy_power_mgmt(const cred_t *); 130f53eecf5SJames Carlson int secpolicy_ppp_config(const cred_t *); 1317c478bd9Sstevel@tonic-gate int secpolicy_proc_access(const cred_t *); 1327c478bd9Sstevel@tonic-gate int secpolicy_proc_excl_open(const cred_t *); 1337c478bd9Sstevel@tonic-gate int secpolicy_proc_owner(const cred_t *, const cred_t *, int); 1347c478bd9Sstevel@tonic-gate int secpolicy_proc_zone(const cred_t *); 1357c478bd9Sstevel@tonic-gate int secpolicy_pset(const cred_t *); 1367c478bd9Sstevel@tonic-gate int secpolicy_rctlsys(const cred_t *, boolean_t); 1377c478bd9Sstevel@tonic-gate int secpolicy_resource(const cred_t *); 1381c7cef2bSStan Studzinski int secpolicy_resource_anon_mem(const cred_t *); 1397c478bd9Sstevel@tonic-gate int secpolicy_rpcmod_open(const cred_t *); 1407c478bd9Sstevel@tonic-gate int secpolicy_rsm_access(const cred_t *, uid_t, mode_t); 14124d819e6SJerry Jelinek int secpolicy_raisepriority(const cred_t *); 1427c478bd9Sstevel@tonic-gate int secpolicy_setpriority(const cred_t *); 1437c478bd9Sstevel@tonic-gate int secpolicy_settime(const cred_t *); 144da6c28aaSamw int secpolicy_smb(const cred_t *); 1454bff34e3Sthurlow int secpolicy_smbfs_login(const cred_t *, uid_t); 1467c478bd9Sstevel@tonic-gate int secpolicy_spec_open(const cred_t *, struct vnode *, int); 1477c478bd9Sstevel@tonic-gate int secpolicy_sti(const cred_t *); 1487c478bd9Sstevel@tonic-gate int secpolicy_swapctl(const cred_t *); 1497c478bd9Sstevel@tonic-gate int secpolicy_sys_config(const cred_t *, boolean_t); 1507c478bd9Sstevel@tonic-gate int secpolicy_zone_admin(const cred_t *, boolean_t); 1517c478bd9Sstevel@tonic-gate int secpolicy_zone_config(const cred_t *); 1527c478bd9Sstevel@tonic-gate int secpolicy_sys_devices(const cred_t *); 1537c478bd9Sstevel@tonic-gate int secpolicy_systeminfo(const cred_t *); 1547c478bd9Sstevel@tonic-gate int secpolicy_tasksys(const cred_t *); 1557c478bd9Sstevel@tonic-gate int secpolicy_vnode_access(const cred_t *, vnode_t *, uid_t, mode_t); 156134a1f4eSCasper H.S. Dik int secpolicy_vnode_access2(const cred_t *, vnode_t *, uid_t, mode_t, mode_t); 157134a1f4eSCasper H.S. Dik int secpolicy_vnode_any_access(const cred_t *, vnode_t *, uid_t); 158e02bc683SMark Shellenbaum int secpolicy_vnode_chown(const cred_t *, uid_t); 1597c478bd9Sstevel@tonic-gate int secpolicy_vnode_create_gid(const cred_t *); 1607c478bd9Sstevel@tonic-gate int secpolicy_vnode_owner(const cred_t *, uid_t); 1617c478bd9Sstevel@tonic-gate int secpolicy_vnode_remove(const cred_t *); 1627c478bd9Sstevel@tonic-gate int secpolicy_vnode_setdac(const cred_t *, uid_t); 1637c478bd9Sstevel@tonic-gate int secpolicy_vnode_setid_retain(const cred_t *, boolean_t); 1647c478bd9Sstevel@tonic-gate int secpolicy_vnode_setids_setgids(const cred_t *, gid_t); 1657c478bd9Sstevel@tonic-gate int secpolicy_vnode_stky_modify(const cred_t *); 166911106dfSjm199354 int secpolicy_vscan(const cred_t *); 167ea8dc4b6Seschrock int secpolicy_zinject(const cred_t *); 168fa9e4066Sahrens int secpolicy_zfs(const cred_t *); 1692449e17fSsherrym int secpolicy_ucode_update(const cred_t *); 170e6bdcbd5Sdh155122 int secpolicy_sadopen(const cred_t *); 17113f9f30eSmarks void secpolicy_setid_clear(vattr_t *, cred_t *); 172ecd6cf80Smarks void secpolicy_fs_mount_clearopts(cred_t *, struct vfs *); 173f92daba9Smarks int secpolicy_setid_setsticky_clear(vnode_t *, vattr_t *, 174f92daba9Smarks const vattr_t *, cred_t *); 175da6c28aaSamw int secpolicy_xvattr(xvattr_t *, uid_t, cred_t *, vtype_t); 176b26a64aeSjohnlev int secpolicy_xvm_control(const cred_t *); 1777c478bd9Sstevel@tonic-gate 178ddf7fe95Scasper int secpolicy_basic_exec(const cred_t *, vnode_t *); 1797c478bd9Sstevel@tonic-gate int secpolicy_basic_fork(const cred_t *); 180ddf7fe95Scasper int secpolicy_basic_link(const cred_t *); 181134a1f4eSCasper H.S. Dik int secpolicy_basic_file_read(const cred_t *, vnode_t *, const char *); 182134a1f4eSCasper H.S. Dik int secpolicy_basic_file_write(const cred_t *, vnode_t *, const char *); 183634e26ecSCasper H.S. Dik int secpolicy_basic_net_access(const cred_t *); 1847c478bd9Sstevel@tonic-gate int secpolicy_basic_proc(const cred_t *); 1857c478bd9Sstevel@tonic-gate int secpolicy_basic_procinfo(const cred_t *, struct proc *, struct proc *); 1867c478bd9Sstevel@tonic-gate 1877c478bd9Sstevel@tonic-gate int secpolicy_gart_access(const cred_t *); 1887c478bd9Sstevel@tonic-gate int secpolicy_gart_map(const cred_t *); 1897c478bd9Sstevel@tonic-gate /* 1907c478bd9Sstevel@tonic-gate * This function to be called from xxfs_setattr(). 1917c478bd9Sstevel@tonic-gate * Must be called with the node's attributes read-write locked. 1927c478bd9Sstevel@tonic-gate * 1937c478bd9Sstevel@tonic-gate * cred_t * - acting credentials 1947c478bd9Sstevel@tonic-gate * struct vnode * - vnode we're operating on 1957c478bd9Sstevel@tonic-gate * struct vattr *va - new attributes, va_mask may be 1967c478bd9Sstevel@tonic-gate * changed on return from a call 1977c478bd9Sstevel@tonic-gate * struct vattr *oldva - old attributes, need include owner 1987c478bd9Sstevel@tonic-gate * and mode only 1997c478bd9Sstevel@tonic-gate * int flags - setattr flags 2007c478bd9Sstevel@tonic-gate * int iaccess(void *node, int mode, cred_t *cr) 2017c478bd9Sstevel@tonic-gate * - non-locking internal access function 2027c478bd9Sstevel@tonic-gate * mode be checked 2037c478bd9Sstevel@tonic-gate * w/ VREAD|VWRITE|VEXEC, not fs 2047c478bd9Sstevel@tonic-gate * internal mode encoding. 2057c478bd9Sstevel@tonic-gate * 2067c478bd9Sstevel@tonic-gate * void *node - internal node (inode, tmpnode) to 2077c478bd9Sstevel@tonic-gate * pass as arg to iaccess 2087c478bd9Sstevel@tonic-gate */ 2097c478bd9Sstevel@tonic-gate int secpolicy_vnode_setattr(cred_t *, struct vnode *, struct vattr *, 2107c478bd9Sstevel@tonic-gate const struct vattr *, int, int (void *, int, cred_t *), void *); 2117c478bd9Sstevel@tonic-gate 2127c478bd9Sstevel@tonic-gate /* 2137c478bd9Sstevel@tonic-gate * Test privilege. Audit success or failure, allow privilege debugging. 2147c478bd9Sstevel@tonic-gate * Returns 0 for success, err for failure. 2157c478bd9Sstevel@tonic-gate */ 2167c478bd9Sstevel@tonic-gate #define PRIV_POLICY(cred, priv, all, err, reason) \ 2177c478bd9Sstevel@tonic-gate priv_policy((cred), (priv), (all), (err), (reason)) 2187c478bd9Sstevel@tonic-gate 2197c478bd9Sstevel@tonic-gate /* 2207c478bd9Sstevel@tonic-gate * Test privilege. Audit success only, no privilege debugging. 2217c478bd9Sstevel@tonic-gate * Returns 1 for success, and 0 for failure. 2227c478bd9Sstevel@tonic-gate */ 2237c478bd9Sstevel@tonic-gate #define PRIV_POLICY_CHOICE(cred, priv, all) \ 2247c478bd9Sstevel@tonic-gate priv_policy_choice((cred), (priv), (all)) 2257c478bd9Sstevel@tonic-gate 2267c478bd9Sstevel@tonic-gate /* 2277c478bd9Sstevel@tonic-gate * Test privilege. No priv_debugging, no auditing. 2287c478bd9Sstevel@tonic-gate * Returns 1 for success, and 0 for failure. 2297c478bd9Sstevel@tonic-gate */ 2307c478bd9Sstevel@tonic-gate 2317c478bd9Sstevel@tonic-gate #define PRIV_POLICY_ONLY(cred, priv, all) \ 2327c478bd9Sstevel@tonic-gate priv_policy_only((cred), (priv), (all)) 2337c478bd9Sstevel@tonic-gate 2347c478bd9Sstevel@tonic-gate 2357c478bd9Sstevel@tonic-gate #endif 2367c478bd9Sstevel@tonic-gate 2377c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2387c478bd9Sstevel@tonic-gate } 2397c478bd9Sstevel@tonic-gate #endif 2407c478bd9Sstevel@tonic-gate 2417c478bd9Sstevel@tonic-gate #endif /* _SYS_POLICY_H */ 242