Merge pull request #6262 from sudo-sturbia:msgqueue/syscalls3

PiperOrigin-RevId: 391416650
This commit is contained in:
gVisor bot
2021-08-17 17:44:26 -07:00
9 changed files with 386 additions and 47 deletions
+2 -17
View File
@@ -618,25 +618,10 @@ func (s *Shm) Set(ctx context.Context, ds *linux.ShmidDS) error {
s.mu.Lock()
defer s.mu.Unlock()
creds := auth.CredentialsFromContext(ctx)
if !s.obj.CheckOwnership(creds) {
return linuxerr.EPERM
if err := s.obj.Set(ctx, &ds.ShmPerm); err != nil {
return err
}
uid := creds.UserNamespace.MapToKUID(auth.UID(ds.ShmPerm.UID))
gid := creds.UserNamespace.MapToKGID(auth.GID(ds.ShmPerm.GID))
if !uid.Ok() || !gid.Ok() {
return linuxerr.EINVAL
}
// User may only modify the lower 9 bits of the mode. All the other bits are
// always 0 for the underlying inode.
mode := linux.FileMode(ds.ShmPerm.Mode & 0x1ff)
s.obj.Perms = fs.FilePermsFromMode(mode)
s.obj.Owner.UID = uid
s.obj.Owner.GID = gid
s.changeTime = ktime.NowFromContext(ctx)
return nil
}