gvisor: don't allocate a new credential object on fork

A credential object is immutable, so we don't need to copy it for a new
task.

PiperOrigin-RevId: 239519266
Change-Id: I0632f641fdea9554779ac25d84bee4231d0d18f2
This commit is contained in:
Andrei Vagin
2019-03-20 18:41:00 -07:00
committed by Shentubot
parent 81f4829d11
commit 064fda1a75
2 changed files with 2 additions and 1 deletions
+1 -1
View File
@@ -252,7 +252,7 @@ func (t *Task) Clone(opts *CloneOptions) (ThreadID, *SyscallControl, error) {
TaskContext: tc,
FSContext: fsc,
FDMap: fds,
Credentials: creds.Fork(),
Credentials: creds,
Niceness: t.Niceness(),
NetworkNamespaced: t.netns,
AllowedCPUMask: t.CPUMask(),
+1
View File
@@ -372,6 +372,7 @@ func (t *Task) DropBoundingCapability(cp linux.Capability) error {
if !t.creds.HasCapability(linux.CAP_SETPCAP) {
return syserror.EPERM
}
t.creds = t.creds.Fork() // See doc for creds.
t.creds.BoundingCaps &^= auth.CapabilitySetOf(cp)
return nil
}