Use proto structs for seccheck points

Given that in most cases points are serialized to another process,
point data is now created diretly into protos.

As part of this change, infrastructure to track optional and context
fields was created to facilitate addition of lots of Points which is
needed for upcomming of changes.

Updates #4805

Currently the SST code is converting seccheck protos into SST protos
in the sentry before sending it to the API. After this change, SST
checker will be changed to send seccheck protos to the API and the
API then converts these into SST on the way to pubsub.

PiperOrigin-RevId: 442688320
This commit is contained in:
Fabricio Voznika
2022-04-18 19:03:15 -07:00
committed by gVisor bot
parent 59c7cd5ddf
commit 8a24f200e9
18 changed files with 528 additions and 316 deletions
+2
View File
@@ -65,6 +65,8 @@ go_library(
"//pkg/context",
"//pkg/errors/linuxerr",
"//pkg/log",
"//pkg/sentry/seccheck",
"//pkg/sentry/seccheck/points:points_go_proto",
"//pkg/sync",
],
)
+16
View File
@@ -17,6 +17,8 @@ package auth
import (
"gvisor.dev/gvisor/pkg/abi/linux"
"gvisor.dev/gvisor/pkg/errors/linuxerr"
"gvisor.dev/gvisor/pkg/sentry/seccheck"
pb "gvisor.dev/gvisor/pkg/sentry/seccheck/points/points_go_proto"
)
// Credentials contains information required to authorize privileged operations
@@ -260,3 +262,17 @@ func (c *Credentials) SetGID(gid GID) error {
c.SavedKGID = kgid
return nil
}
// LoadSeccheckData sets credential data based on mask.
func (c *Credentials) LoadSeccheckData(mask seccheck.FieldMask, info *pb.ContextData) {
if mask.Contains(seccheck.FieldCtxtCredentials) {
info.Credentials = &pb.Credentials{
RealUid: uint32(c.RealKUID),
EffectiveUid: uint32(c.EffectiveKUID),
SavedUid: uint32(c.SavedKUID),
RealGid: uint32(c.RealKGID),
EffectiveGid: uint32(c.EffectiveKGID),
SavedGid: uint32(c.SavedKGID),
}
}
}