diff options
author | gVisor bot <gvisor-bot@google.com> | 2021-09-15 00:24:24 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-09-15 00:24:24 +0000 |
commit | 5c6c455f62840d44b88a4f473a7070e497297bd7 (patch) | |
tree | 8d09955414568720612cf0ef5eff20c7c1353c9a /pkg/sentry/kernel/msgqueue | |
parent | 0b41b6b22dce67a32d16db90dd25a419ec36e690 (diff) | |
parent | 39470428dd3c5fef966cee138ae00ab8b9059983 (diff) |
Merge release-20210906.0-22-g39470428d (automated)
Diffstat (limited to 'pkg/sentry/kernel/msgqueue')
-rw-r--r-- | pkg/sentry/kernel/msgqueue/msgqueue.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/pkg/sentry/kernel/msgqueue/msgqueue.go b/pkg/sentry/kernel/msgqueue/msgqueue.go index 7c459d076..c7c5e41fb 100644 --- a/pkg/sentry/kernel/msgqueue/msgqueue.go +++ b/pkg/sentry/kernel/msgqueue/msgqueue.go @@ -129,6 +129,16 @@ type Message struct { Size uint64 } +func (m *Message) makeCopy() *Message { + new := &Message{ + Type: m.Type, + Size: m.Size, + } + new.Text = make([]byte, len(m.Text)) + copy(new.Text, m.Text) + return new +} + // Blocker is used for blocking Queue.Send, and Queue.Receive calls that serves // as an abstracted version of kernel.Task. kernel.Task is not directly used to // prevent circular dependencies. @@ -455,7 +465,7 @@ func (q *Queue) Copy(mType int64) (*Message, error) { if msg == nil { return nil, linuxerr.ENOMSG } - return msg, nil + return msg.makeCopy(), nil } // msgOfType returns the first message with the specified type, nil if no |