Pick up fix for CVE-2019-16884 in opencontainers/selinux
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
This commit is contained in:
parent
c2ad9dc12d
commit
faf03c3d23
@ -66,7 +66,7 @@ github.com/google/gofuzz f140a6486e521aad38f5917de355
|
|||||||
github.com/json-iterator/go 27518f6661eba504be5a7a9a9f6d9460d892ade3 # v1.1.7
|
github.com/json-iterator/go 27518f6661eba504be5a7a9a9f6d9460d892ade3 # v1.1.7
|
||||||
github.com/modern-go/concurrent bacd9c7ef1dd9b15be4a9909b8ac7a4e313eec94 # 1.0.3
|
github.com/modern-go/concurrent bacd9c7ef1dd9b15be4a9909b8ac7a4e313eec94 # 1.0.3
|
||||||
github.com/modern-go/reflect2 4b7aa43c6742a2c18fdef89dd197aaae7dac7ccd # 1.0.1
|
github.com/modern-go/reflect2 4b7aa43c6742a2c18fdef89dd197aaae7dac7ccd # 1.0.1
|
||||||
github.com/opencontainers/selinux 3a1f366feb7aecbf7a0e71ac4cea88b31597de9e # v1.2.2
|
github.com/opencontainers/selinux 5215b1806f52b1fcc2070a8826c542c9d33cd3cf
|
||||||
github.com/seccomp/libseccomp-golang 689e3c1541a84461afc49c1c87352a6cedf72e9c # v0.9.1
|
github.com/seccomp/libseccomp-golang 689e3c1541a84461afc49c1c87352a6cedf72e9c # v0.9.1
|
||||||
github.com/tchap/go-patricia 666120de432aea38ab06bd5c818f04f4129882c9 # v2.2.6
|
github.com/tchap/go-patricia 666120de432aea38ab06bd5c818f04f4129882c9 # v2.2.6
|
||||||
golang.org/x/crypto 5c40567a22f818bd14a1ea7245dad9f8ef0691aa
|
golang.org/x/crypto 5c40567a22f818bd14a1ea7245dad9f8ef0691aa
|
||||||
|
18
vendor/github.com/opencontainers/selinux/go-selinux/label/label_selinux.go
generated
vendored
18
vendor/github.com/opencontainers/selinux/go-selinux/label/label_selinux.go
generated
vendored
@ -13,11 +13,12 @@ import (
|
|||||||
|
|
||||||
// Valid Label Options
|
// Valid Label Options
|
||||||
var validOptions = map[string]bool{
|
var validOptions = map[string]bool{
|
||||||
"disable": true,
|
"disable": true,
|
||||||
"type": true,
|
"type": true,
|
||||||
"user": true,
|
"filetype": true,
|
||||||
"role": true,
|
"user": true,
|
||||||
"level": true,
|
"role": true,
|
||||||
|
"level": true,
|
||||||
}
|
}
|
||||||
|
|
||||||
var ErrIncompatibleLabel = fmt.Errorf("Bad SELinux option z and Z can not be used together")
|
var ErrIncompatibleLabel = fmt.Errorf("Bad SELinux option z and Z can not be used together")
|
||||||
@ -51,13 +52,16 @@ func InitLabels(options []string) (plabel string, mlabel string, Err error) {
|
|||||||
return "", mountLabel, nil
|
return "", mountLabel, nil
|
||||||
}
|
}
|
||||||
if i := strings.Index(opt, ":"); i == -1 {
|
if i := strings.Index(opt, ":"); i == -1 {
|
||||||
return "", "", fmt.Errorf("Bad label option %q, valid options 'disable' or \n'user, role, level, type' followed by ':' and a value", opt)
|
return "", "", fmt.Errorf("Bad label option %q, valid options 'disable' or \n'user, role, level, type, filetype' followed by ':' and a value", opt)
|
||||||
}
|
}
|
||||||
con := strings.SplitN(opt, ":", 2)
|
con := strings.SplitN(opt, ":", 2)
|
||||||
if !validOptions[con[0]] {
|
if !validOptions[con[0]] {
|
||||||
return "", "", fmt.Errorf("Bad label option %q, valid options 'disable, user, role, level, type'", con[0])
|
return "", "", fmt.Errorf("Bad label option %q, valid options 'disable, user, role, level, type, filetype'", con[0])
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if con[0] == "filetype" {
|
||||||
|
mcon["type"] = con[1]
|
||||||
|
}
|
||||||
pcon[con[0]] = con[1]
|
pcon[con[0]] = con[1]
|
||||||
if con[0] == "level" || con[0] == "user" {
|
if con[0] == "level" || con[0] == "user" {
|
||||||
mcon[con[0]] = con[1]
|
mcon[con[0]] = con[1]
|
||||||
|
33
vendor/github.com/opencontainers/selinux/go-selinux/selinux_linux.go
generated
vendored
33
vendor/github.com/opencontainers/selinux/go-selinux/selinux_linux.go
generated
vendored
@ -18,6 +18,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -252,6 +254,12 @@ func getSELinuxPolicyRoot() string {
|
|||||||
return filepath.Join(selinuxDir, readConfig(selinuxTypeTag))
|
return filepath.Join(selinuxDir, readConfig(selinuxTypeTag))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isProcHandle(fh *os.File) (bool, error) {
|
||||||
|
var buf unix.Statfs_t
|
||||||
|
err := unix.Fstatfs(int(fh.Fd()), &buf)
|
||||||
|
return buf.Type == unix.PROC_SUPER_MAGIC, err
|
||||||
|
}
|
||||||
|
|
||||||
func readCon(fpath string) (string, error) {
|
func readCon(fpath string) (string, error) {
|
||||||
if fpath == "" {
|
if fpath == "" {
|
||||||
return "", ErrEmptyPath
|
return "", ErrEmptyPath
|
||||||
@ -263,6 +271,12 @@ func readCon(fpath string) (string, error) {
|
|||||||
}
|
}
|
||||||
defer in.Close()
|
defer in.Close()
|
||||||
|
|
||||||
|
if ok, err := isProcHandle(in); err != nil {
|
||||||
|
return "", err
|
||||||
|
} else if !ok {
|
||||||
|
return "", fmt.Errorf("%s not on procfs", fpath)
|
||||||
|
}
|
||||||
|
|
||||||
var retval string
|
var retval string
|
||||||
if _, err := fmt.Fscanf(in, "%s", &retval); err != nil {
|
if _, err := fmt.Fscanf(in, "%s", &retval); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@ -345,6 +359,12 @@ func writeCon(fpath string, val string) error {
|
|||||||
}
|
}
|
||||||
defer out.Close()
|
defer out.Close()
|
||||||
|
|
||||||
|
if ok, err := isProcHandle(out); err != nil {
|
||||||
|
return err
|
||||||
|
} else if !ok {
|
||||||
|
return fmt.Errorf("%s not on procfs", fpath)
|
||||||
|
}
|
||||||
|
|
||||||
if val != "" {
|
if val != "" {
|
||||||
_, err = out.Write([]byte(val))
|
_, err = out.Write([]byte(val))
|
||||||
} else {
|
} else {
|
||||||
@ -392,6 +412,14 @@ func SetExecLabel(label string) error {
|
|||||||
return writeCon(fmt.Sprintf("/proc/self/task/%d/attr/exec", syscall.Gettid()), label)
|
return writeCon(fmt.Sprintf("/proc/self/task/%d/attr/exec", syscall.Gettid()), label)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
SetTaskLabel sets the SELinux label for the current thread, or an error.
|
||||||
|
This requires the dyntransition permission.
|
||||||
|
*/
|
||||||
|
func SetTaskLabel(label string) error {
|
||||||
|
return writeCon(fmt.Sprintf("/proc/self/task/%d/attr/current", syscall.Gettid()), label)
|
||||||
|
}
|
||||||
|
|
||||||
// SetSocketLabel takes a process label and tells the kernel to assign the
|
// SetSocketLabel takes a process label and tells the kernel to assign the
|
||||||
// label to the next socket that gets created
|
// label to the next socket that gets created
|
||||||
func SetSocketLabel(label string) error {
|
func SetSocketLabel(label string) error {
|
||||||
@ -403,6 +431,11 @@ func SocketLabel() (string, error) {
|
|||||||
return readCon(fmt.Sprintf("/proc/self/task/%d/attr/sockcreate", syscall.Gettid()))
|
return readCon(fmt.Sprintf("/proc/self/task/%d/attr/sockcreate", syscall.Gettid()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PeerLabel retrieves the label of the client on the other side of a socket
|
||||||
|
func PeerLabel(fd uintptr) (string, error) {
|
||||||
|
return unix.GetsockoptString(int(fd), syscall.SOL_SOCKET, syscall.SO_PEERSEC)
|
||||||
|
}
|
||||||
|
|
||||||
// SetKeyLabel takes a process label and tells the kernel to assign the
|
// SetKeyLabel takes a process label and tells the kernel to assign the
|
||||||
// label to the next kernel keyring that gets created
|
// label to the next kernel keyring that gets created
|
||||||
func SetKeyLabel(label string) error {
|
func SetKeyLabel(label string) error {
|
||||||
|
13
vendor/github.com/opencontainers/selinux/go-selinux/selinux_stub.go
generated
vendored
13
vendor/github.com/opencontainers/selinux/go-selinux/selinux_stub.go
generated
vendored
@ -96,6 +96,14 @@ func SetExecLabel(label string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
SetTaskLabel sets the SELinux label for the current thread, or an error.
|
||||||
|
This requires the dyntransition permission.
|
||||||
|
*/
|
||||||
|
func SetTaskLabel(label string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
SetSocketLabel sets the SELinux label that the kernel will use for any programs
|
SetSocketLabel sets the SELinux label that the kernel will use for any programs
|
||||||
that are executed by the current process thread, or an error.
|
that are executed by the current process thread, or an error.
|
||||||
@ -109,6 +117,11 @@ func SocketLabel() (string, error) {
|
|||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PeerLabel retrieves the label of the client on the other side of a socket
|
||||||
|
func PeerLabel(fd uintptr) (string, error) {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
|
||||||
// SetKeyLabel takes a process label and tells the kernel to assign the
|
// SetKeyLabel takes a process label and tells the kernel to assign the
|
||||||
// label to the next kernel keyring that gets created
|
// label to the next kernel keyring that gets created
|
||||||
func SetKeyLabel(label string) error {
|
func SetKeyLabel(label string) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user