mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
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:
@@ -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(),
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user