fst: include syscall filter configuration
All checks were successful
Build / Create distribution (push) Successful in 3m0s
Test / Run NixOS test (push) Successful in 5m19s

This value is passed through to shim.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
Ophestra 2025-01-20 21:12:39 +09:00
parent 2cf1f46ea2
commit 27f5922d5c
Signed by: cat
SSH Key Fingerprint: SHA256:gQ67O0enBZ7UdZypgtspB2FDM1g3GVw8nX0XSdcFw8Q
4 changed files with 31 additions and 6 deletions

View File

@ -31,6 +31,8 @@ type ConfinementConfig struct {
Outer string `json:"home"` Outer string `json:"home"`
// bwrap sandbox confinement configuration // bwrap sandbox confinement configuration
Sandbox *SandboxConfig `json:"sandbox"` Sandbox *SandboxConfig `json:"sandbox"`
// seccomp syscall filter configuration
Syscall *SyscallConfig `json:"syscall"`
// extra acl entries to append // extra acl entries to append
ExtraPerms []*ExtraPermConfig `json:"extra_perms,omitempty"` ExtraPerms []*ExtraPermConfig `json:"extra_perms,omitempty"`
@ -45,6 +47,14 @@ type ConfinementConfig struct {
Enablements system.Enablements `json:"enablements"` Enablements system.Enablements `json:"enablements"`
} }
type SyscallConfig struct {
DenyDevel bool `json:"deny_devel"`
Multiarch bool `json:"multiarch"`
Linux32 bool `json:"linux32"`
Can bool `json:"can"`
Bluetooth bool `json:"bluetooth"`
}
type ExtraPermConfig struct { type ExtraPermConfig struct {
Ensure bool `json:"ensure,omitempty"` Ensure bool `json:"ensure,omitempty"`
Path string `json:"path"` Path string `json:"path"`

View File

@ -47,6 +47,8 @@ type appSeal struct {
// pass-through enablement tracking from config // pass-through enablement tracking from config
et system.Enablements et system.Enablements
// pass-through seccomp config from config
scmp *fst.SyscallConfig
// wayland socket direct access // wayland socket direct access
directWayland bool directWayland bool
// extra UpdatePerm ops // extra UpdatePerm ops
@ -218,6 +220,12 @@ func (a *app) Seal(config *fst.Config) error {
conf.Filesystem = append(conf.Filesystem, &fst.FilesystemConfig{Src: "/dev/kvm", Device: true}) conf.Filesystem = append(conf.Filesystem, &fst.FilesystemConfig{Src: "/dev/kvm", Device: true})
config.Confinement.Sandbox = conf config.Confinement.Sandbox = conf
// ensure syscall filter
if config.Confinement.Syscall == nil {
config.Confinement.Syscall = new(fst.SyscallConfig)
config.Confinement.Syscall.Multiarch = true
}
} }
seal.directWayland = config.Confinement.Sandbox.DirectWayland seal.directWayland = config.Confinement.Sandbox.DirectWayland
if b, err := config.Confinement.Sandbox.Bwrap(a.os); err != nil { if b, err := config.Confinement.Sandbox.Bwrap(a.os); err != nil {
@ -238,8 +246,9 @@ func (a *app) Seal(config *fst.Config) error {
// initialise system interface with full uid // initialise system interface with full uid
seal.sys.I = system.New(seal.sys.user.uid) seal.sys.I = system.New(seal.sys.user.uid)
// pass through enablements // pass through enablements and seccomp
seal.et = config.Confinement.Enablements seal.et = config.Confinement.Enablements
seal.scmp = config.Confinement.Syscall
// this method calls all share methods in sequence // this method calls all share methods in sequence
if err := seal.setupShares([2]*dbus.Config{config.Confinement.SessionBus, config.Confinement.SystemBus}, a.os); err != nil { if err := seal.setupShares([2]*dbus.Config{config.Confinement.SessionBus, config.Confinement.SystemBus}, a.os); err != nil {

View File

@ -76,10 +76,11 @@ func (a *app) Run(ctx context.Context, rs *RunState) error {
// send payload // send payload
if err = a.shim.Serve(shimSetupCtx, &shim.Payload{ if err = a.shim.Serve(shimSetupCtx, &shim.Payload{
Argv: a.seal.command, Argv: a.seal.command,
Exec: shimExec, Exec: shimExec,
Bwrap: a.seal.sys.bwrap, Bwrap: a.seal.sys.bwrap,
Home: a.seal.sys.user.data, Home: a.seal.sys.user.data,
Syscall: a.seal.scmp,
Verbose: fmsg.Verbose(), Verbose: fmsg.Verbose(),
}); err != nil { }); err != nil {

View File

@ -1,6 +1,9 @@
package shim package shim
import "git.gensokyo.uk/security/fortify/helper/bwrap" import (
"git.gensokyo.uk/security/fortify/fst"
"git.gensokyo.uk/security/fortify/helper/bwrap"
)
const Env = "FORTIFY_SHIM" const Env = "FORTIFY_SHIM"
@ -15,6 +18,8 @@ type Payload struct {
Home string Home string
// sync fd // sync fd
Sync *uintptr Sync *uintptr
// seccomp opts pass through
Syscall *fst.SyscallConfig
// verbosity pass through // verbosity pass through
Verbose bool Verbose bool