mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Merge pull request #6262 from sudo-sturbia:msgqueue/syscalls3
PiperOrigin-RevId: 391416650
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user