kernel - Add per-process capability-based restrictions
authorMatthew Dillon <dillon@apollo.backplane.com>
Fri, 13 Oct 2023 02:55:19 +0000 (19:55 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Fri, 13 Oct 2023 05:56:27 +0000 (22:56 -0700)
commit2b3f93ea6d1f70880f3e87f3c2cbe0dc0bfc9332
tree4ffe6f66589a06cddeb1ca2d936afe93e4af5051
parentf2bb8deffb3aaa3032c73b184f65e7f76bf5285a
kernel - Add per-process capability-based restrictions

* This new system allows userland to set capability restrictions which
  turns off numerous kernel features and root accesses.  These restrictions
  are inherited by sub-processes recursively.  Once set, restrictions cannot
  be removed.

  Basic restrictions that mimic an unadorned jail can be enabled without
  creating a jail, but generally speaking real security also requires
  creating a chrooted filesystem topology, and a jail is still needed
  to really segregate processes from each other.  If you do so, however,
  you can (for example) disable mount/umount and most global root-only
  features.

* Add new system calls and a manual page for syscap_get(2) and syscap_set(2)

* Add sys/caps.h

* Add the "setcaps" userland utility and manual page.

* Remove priv.9 and the priv_check infrastructure, replacing it with
  a newly designed caps infrastructure.

* The intention is to add path restriction lists and similar features to
  improve jailess security in the near future, and to optimize the
  priv_check code.
255 files changed:
Makefile_upgrade.inc
bin/ps/print.c
bin/ps/ps.1
lib/libc/sys/Makefile.inc
lib/libc/sys/Symbol.map
lib/libc/sys/syscap_get.2 [new file with mode: 0644]
share/man/man9/Makefile
share/man/man9/priv.9 [deleted file]
sys/bus/u4b/audio/uaudio.c
sys/bus/u4b/controller/ehci.c
sys/bus/u4b/controller/ehci_pci.c
sys/bus/u4b/controller/ohci.c
sys/bus/u4b/controller/ohci_pci.c
sys/bus/u4b/controller/uhci.c
sys/bus/u4b/controller/uhci_pci.c
sys/bus/u4b/controller/usb_controller.c
sys/bus/u4b/controller/xhci.c
sys/bus/u4b/controller/xhci_pci.c
sys/bus/u4b/gadget/g_audio.c
sys/bus/u4b/gadget/g_keyboard.c
sys/bus/u4b/gadget/g_modem.c
sys/bus/u4b/gadget/g_mouse.c
sys/bus/u4b/input/uhid.c
sys/bus/u4b/input/ukbd.c
sys/bus/u4b/input/ums.c
sys/bus/u4b/misc/ufm.c
sys/bus/u4b/net/if_aue.c
sys/bus/u4b/net/if_cdce.c
sys/bus/u4b/net/if_cue.c
sys/bus/u4b/net/if_ipheth.c
sys/bus/u4b/net/if_kue.c
sys/bus/u4b/net/if_mos.c
sys/bus/u4b/net/if_udav.c
sys/bus/u4b/net/if_urndis.c
sys/bus/u4b/quirk/usb_quirk.c
sys/bus/u4b/serial/u3g.c
sys/bus/u4b/serial/uark.c
sys/bus/u4b/serial/ubsa.c
sys/bus/u4b/serial/ubser.c
sys/bus/u4b/serial/uchcom.c
sys/bus/u4b/serial/ucycom.c
sys/bus/u4b/serial/ufoma.c
sys/bus/u4b/serial/uftdi.c
sys/bus/u4b/serial/ugensa.c
sys/bus/u4b/serial/uipaq.c
sys/bus/u4b/serial/ulpt.c
sys/bus/u4b/serial/umcs.c
sys/bus/u4b/serial/umct.c
sys/bus/u4b/serial/umodem.c
sys/bus/u4b/serial/umoscom.c
sys/bus/u4b/serial/uplcom.c
sys/bus/u4b/serial/usb_serial.c
sys/bus/u4b/serial/uslcom.c
sys/bus/u4b/serial/uvisor.c
sys/bus/u4b/serial/uvscom.c
sys/bus/u4b/storage/umass.c
sys/bus/u4b/storage/urio.c
sys/bus/u4b/storage/ustorage_fs.c
sys/bus/u4b/template/usb_template.c
sys/bus/u4b/template/usb_template_audio.c
sys/bus/u4b/template/usb_template_cdce.c
sys/bus/u4b/template/usb_template_kbd.c
sys/bus/u4b/template/usb_template_modem.c
sys/bus/u4b/template/usb_template_mouse.c
sys/bus/u4b/template/usb_template_msc.c
sys/bus/u4b/template/usb_template_mtp.c
sys/bus/u4b/template/usb_template_phone.c
sys/bus/u4b/template/usb_template_serialnet.c
sys/bus/u4b/usb_busdma.c
sys/bus/u4b/usb_core.c
sys/bus/u4b/usb_debug.c
sys/bus/u4b/usb_dev.c
sys/bus/u4b/usb_device.c
sys/bus/u4b/usb_dynamic.c
sys/bus/u4b/usb_error.c
sys/bus/u4b/usb_generic.c
sys/bus/u4b/usb_handle_request.c
sys/bus/u4b/usb_hid.c
sys/bus/u4b/usb_hub.c
sys/bus/u4b/usb_lookup.c
sys/bus/u4b/usb_mbuf.c
sys/bus/u4b/usb_msctest.c
sys/bus/u4b/usb_parse.c
sys/bus/u4b/usb_process.c
sys/bus/u4b/usb_request.c
sys/bus/u4b/usb_transfer.c
sys/bus/u4b/usb_util.c
sys/conf/files
sys/dev/disk/fd/fd.c
sys/dev/disk/nata/atapi-cd.c
sys/dev/disk/vn/vn.c
sys/dev/drm/include/linux/capability.h
sys/dev/drm/ttm/ttm_memory.c
sys/dev/misc/cpuctl/cpuctl.c
sys/dev/misc/dcons/dcons_os.c
sys/dev/misc/nmdm/nmdm.c
sys/dev/misc/syscons/syscons.c
sys/dev/misc/syscons/sysmouse.c
sys/dev/netif/ath/ath/if_ath.c
sys/dev/netif/ath/ath/if_ath_beacon.c
sys/dev/netif/ath/ath/if_ath_debug.c
sys/dev/netif/ath/ath/if_ath_descdma.c
sys/dev/netif/ath/ath/if_ath_ioctl.c
sys/dev/netif/ath/ath/if_ath_keycache.c
sys/dev/netif/ath/ath/if_ath_led.c
sys/dev/netif/ath/ath/if_ath_rx.c
sys/dev/netif/ath/ath/if_ath_rx_edma.c
sys/dev/netif/ath/ath/if_ath_sysctl.c
sys/dev/netif/ath/ath/if_ath_tdma.c
sys/dev/netif/ath/ath/if_ath_tx.c
sys/dev/netif/ath/ath/if_ath_tx_edma.c
sys/dev/netif/ath/ath/if_ath_tx_ht.c
sys/dev/netif/iwn/if_iwn.c
sys/dev/netif/oce/oce_if.c
sys/dev/netif/oce/oce_if.h
sys/dev/netif/sbsh/if_sbsh.c
sys/dev/netif/wi/if_wi.c
sys/dev/raid/asr/asr.c
sys/dev/raid/mpr/mpr.c
sys/dev/raid/vinum/vinum.c
sys/dev/raid/vinum/vinumhdr.h
sys/dev/serial/sio/sio.c
sys/kern/imgact_resident.c
sys/kern/init_sysent.c
sys/kern/kern_acct.c
sys/kern/kern_caps.c [new file with mode: 0644]
sys/kern/kern_clock.c
sys/kern/kern_dmsg.c
sys/kern/kern_environment.c
sys/kern/kern_exec.c
sys/kern/kern_fp.c
sys/kern/kern_jail.c
sys/kern/kern_kinfo.c
sys/kern/kern_linker.c
sys/kern/kern_memio.c
sys/kern/kern_ntptime.c
sys/kern/kern_plimit.c
sys/kern/kern_prot.c
sys/kern/kern_resource.c
sys/kern/kern_shutdown.c
sys/kern/kern_sig.c
sys/kern/kern_spinlock.c
sys/kern/kern_synch.c
sys/kern/kern_sysctl.c
sys/kern/kern_time.c
sys/kern/kern_usched.c
sys/kern/kern_varsym.c
sys/kern/subr_firmware.c
sys/kern/subr_prf.c
sys/kern/subr_sleepqueue.c
sys/kern/sys_mqueue.c
sys/kern/sys_process.c
sys/kern/syscalls.c
sys/kern/syscalls.master
sys/kern/sysv_ipc.c
sys/kern/sysv_msg.c
sys/kern/tty.c
sys/kern/tty_cons.c
sys/kern/tty_pty.c
sys/kern/vfs_helper.c
sys/kern/vfs_subr.c
sys/kern/vfs_syscalls.c
sys/kern/vfs_vnops.c
sys/net/bridge/if_bridge.c
sys/net/gre/if_gre.c
sys/net/if.c
sys/net/lagg/if_lagg.c
sys/net/pf/if_pfsync.c
sys/net/raw_usrreq.c
sys/net/rtsock.c
sys/net/sl/if_sl.c
sys/net/tap/if_tap.c
sys/net/tun/if_tun.c
sys/netbt/hci_ioctl.c
sys/netbt/hci_socket.c
sys/netgraph/socket/ng_socket.c
sys/netgraph/tty/ng_tty.c
sys/netgraph7/bluetooth/drivers/h4/ng_h4.c
sys/netgraph7/bluetooth/drivers/ubt/ng_ubt.c
sys/netgraph7/bluetooth/drivers/ubtbcmfw/ubtbcmfw.c
sys/netgraph7/bluetooth/socket/ng_btsocket_hci_raw.c
sys/netgraph7/bluetooth/socket/ng_btsocket_l2cap_raw.c
sys/netgraph7/socket/ng_socket.c
sys/netgraph7/tty/ng_tty.c
sys/netinet/in.c
sys/netinet/in_pcb.c
sys/netinet/ip_carp.c
sys/netinet/ip_divert.c
sys/netinet/ip_output.c
sys/netinet/raw_ip.c
sys/netinet/tcp_subr.c
sys/netinet/udp_usrreq.c
sys/netinet6/in6.c
sys/netinet6/in6_pcb.c
sys/netinet6/in6_src.c
sys/netinet6/ip6_input.c
sys/netinet6/ip6_output.c
sys/netinet6/raw_ip6.c
sys/netinet6/udp6_output.c
sys/netinet6/udp6_usrreq.c
sys/netproto/802_11/wlan/ieee80211_ioctl.c
sys/netproto/smb/smb_conn.c
sys/netproto/smb/smb_subr.h
sys/platform/pc64/x86_64/machdep.c
sys/platform/pc64/x86_64/mp_flame.c
sys/sys/caps.h [new file with mode: 0644]
sys/sys/kinfo.h
sys/sys/priv.h [deleted file]
sys/sys/proc.h
sys/sys/syscall.h
sys/sys/syscall.mk
sys/sys/sysproto.h
sys/sys/sysunion.h
sys/sys/ucred.h
sys/vfs/devfs/devfs_vnops.c
sys/vfs/ext2fs/ext2_vfsops.c
sys/vfs/ext2fs/ext2_vnops.c
sys/vfs/fuse/fuse_vfsops.c
sys/vfs/hammer/hammer.h
sys/vfs/hammer/hammer_ioctl.c
sys/vfs/hammer2/hammer2.h
sys/vfs/hammer2/hammer2_ioctl.c
sys/vfs/hpfs/hpfs_vnops.c
sys/vfs/isofs/cd9660/cd9660_vfsops.c
sys/vfs/msdosfs/msdosfs_vnops.c
sys/vfs/nfs/nfs_serv.c
sys/vfs/nfs/nfs_subs.c
sys/vfs/nfs/nfs_syscalls.c
sys/vfs/procfs/procfs.h
sys/vfs/procfs/procfs_ctl.c
sys/vfs/procfs/procfs_dbregs.c
sys/vfs/procfs/procfs_fpregs.c
sys/vfs/procfs/procfs_mem.c
sys/vfs/procfs/procfs_regs.c
sys/vfs/procfs/procfs_status.c
sys/vfs/procfs/procfs_vnops.c
sys/vfs/smbfs/smbfs_vnops.c
sys/vfs/tmpfs/tmpfs_subr.c
sys/vfs/tmpfs/tmpfs_vnops.c
sys/vfs/udf/udf_vfsops.c
sys/vfs/ufs/ufs_vfsops.c
sys/vfs/ufs/ufs_vnops.c
sys/vm/vm_mmap.c
sys/vm/vm_swap.c
tools/tools/netrate/pktgen/pktgen.c
usr.bin/Makefile
usr.bin/dsynth/build.c
usr.bin/dsynth/dsynth.c
usr.bin/dsynth/dsynth.h
usr.bin/dsynth/subs.c
usr.bin/setcaps/Makefile [new file with mode: 0644]
usr.bin/setcaps/setcaps.1 [new file with mode: 0644]
usr.bin/setcaps/setcaps.c [new file with mode: 0644]
usr.bin/w/w.c
usr.sbin/makefs/hammer2/hammer2.h