diff options
Diffstat (limited to 'pkg/sentry')
-rw-r--r-- | pkg/sentry/fs/dirent_cache.go | 2 | ||||
-rwxr-xr-x | pkg/sentry/fs/dirent_list.go | 8 | ||||
-rwxr-xr-x | pkg/sentry/fs/event_list.go | 8 | ||||
-rw-r--r-- | pkg/sentry/fs/inotify.go | 5 | ||||
-rwxr-xr-x | pkg/sentry/kernel/epoll/epoll_list.go | 8 | ||||
-rw-r--r-- | pkg/sentry/kernel/epoll/epoll_state.go | 13 | ||||
-rwxr-xr-x | pkg/sentry/kernel/futex/waiter_list.go | 8 | ||||
-rwxr-xr-x | pkg/sentry/kernel/pending_signals_list.go | 8 | ||||
-rwxr-xr-x | pkg/sentry/kernel/process_group_list.go | 8 | ||||
-rwxr-xr-x | pkg/sentry/kernel/semaphore/waiter_list.go | 8 | ||||
-rwxr-xr-x | pkg/sentry/kernel/session_list.go | 8 | ||||
-rwxr-xr-x | pkg/sentry/kernel/socket_list.go | 8 | ||||
-rwxr-xr-x | pkg/sentry/kernel/task_list.go | 8 | ||||
-rwxr-xr-x | pkg/sentry/mm/io_list.go | 8 | ||||
-rwxr-xr-x | pkg/sentry/socket/unix/transport/transport_message_list.go | 8 | ||||
-rwxr-xr-x | pkg/sentry/vfs/epoll_interest_list.go | 8 |
16 files changed, 90 insertions, 34 deletions
diff --git a/pkg/sentry/fs/dirent_cache.go b/pkg/sentry/fs/dirent_cache.go index 25514ace4..33de32c69 100644 --- a/pkg/sentry/fs/dirent_cache.go +++ b/pkg/sentry/fs/dirent_cache.go @@ -101,8 +101,6 @@ func (c *DirentCache) remove(d *Dirent) { panic(fmt.Sprintf("trying to remove %v, which is not in the dirent cache", d)) } c.list.Remove(d) - d.SetPrev(nil) - d.SetNext(nil) d.DecRef() c.currentSize-- if c.limit != nil { diff --git a/pkg/sentry/fs/dirent_list.go b/pkg/sentry/fs/dirent_list.go index 49d25da6c..acdce100c 100755 --- a/pkg/sentry/fs/dirent_list.go +++ b/pkg/sentry/fs/dirent_list.go @@ -135,8 +135,9 @@ func (l *direntList) InsertBefore(a, e *Dirent) { // Remove removes e from l. func (l *direntList) Remove(e *Dirent) { - prev := direntElementMapper{}.linkerFor(e).Prev() - next := direntElementMapper{}.linkerFor(e).Next() + linker := direntElementMapper{}.linkerFor(e) + prev := linker.Prev() + next := linker.Next() if prev != nil { direntElementMapper{}.linkerFor(prev).SetNext(next) @@ -149,6 +150,9 @@ func (l *direntList) Remove(e *Dirent) { } else { l.tail = prev } + + linker.SetNext(nil) + linker.SetPrev(nil) } // Entry is a default implementation of Linker. Users can add anonymous fields diff --git a/pkg/sentry/fs/event_list.go b/pkg/sentry/fs/event_list.go index 786686592..0274f41a2 100755 --- a/pkg/sentry/fs/event_list.go +++ b/pkg/sentry/fs/event_list.go @@ -135,8 +135,9 @@ func (l *eventList) InsertBefore(a, e *Event) { // Remove removes e from l. func (l *eventList) Remove(e *Event) { - prev := eventElementMapper{}.linkerFor(e).Prev() - next := eventElementMapper{}.linkerFor(e).Next() + linker := eventElementMapper{}.linkerFor(e) + prev := linker.Prev() + next := linker.Next() if prev != nil { eventElementMapper{}.linkerFor(prev).SetNext(next) @@ -149,6 +150,9 @@ func (l *eventList) Remove(e *Event) { } else { l.tail = prev } + + linker.SetNext(nil) + linker.SetPrev(nil) } // Entry is a default implementation of Linker. Users can add anonymous fields diff --git a/pkg/sentry/fs/inotify.go b/pkg/sentry/fs/inotify.go index 928c90aa0..e3a715c1f 100644 --- a/pkg/sentry/fs/inotify.go +++ b/pkg/sentry/fs/inotify.go @@ -143,7 +143,10 @@ func (i *Inotify) Read(ctx context.Context, _ *File, dst usermem.IOSequence, _ i } var writeLen int64 - for event := i.events.Front(); event != nil; event = event.Next() { + for it := i.events.Front(); it != nil; { + event := it + it = it.Next() + // Does the buffer have enough remaining space to hold the event we're // about to write out? if dst.NumBytes() < int64(event.sizeOf()) { diff --git a/pkg/sentry/kernel/epoll/epoll_list.go b/pkg/sentry/kernel/epoll/epoll_list.go index 5ac854e38..37f757fa8 100755 --- a/pkg/sentry/kernel/epoll/epoll_list.go +++ b/pkg/sentry/kernel/epoll/epoll_list.go @@ -135,8 +135,9 @@ func (l *pollEntryList) InsertBefore(a, e *pollEntry) { // Remove removes e from l. func (l *pollEntryList) Remove(e *pollEntry) { - prev := pollEntryElementMapper{}.linkerFor(e).Prev() - next := pollEntryElementMapper{}.linkerFor(e).Next() + linker := pollEntryElementMapper{}.linkerFor(e) + prev := linker.Prev() + next := linker.Next() if prev != nil { pollEntryElementMapper{}.linkerFor(prev).SetNext(next) @@ -149,6 +150,9 @@ func (l *pollEntryList) Remove(e *pollEntry) { } else { l.tail = prev } + + linker.SetNext(nil) + linker.SetPrev(nil) } // Entry is a default implementation of Linker. Users can add anonymous fields diff --git a/pkg/sentry/kernel/epoll/epoll_state.go b/pkg/sentry/kernel/epoll/epoll_state.go index a0d35d350..8e9f200d0 100644 --- a/pkg/sentry/kernel/epoll/epoll_state.go +++ b/pkg/sentry/kernel/epoll/epoll_state.go @@ -38,11 +38,14 @@ func (e *EventPoll) afterLoad() { } } - for it := e.waitingList.Front(); it != nil; it = it.Next() { - if it.id.File.Readiness(it.mask) != 0 { - e.waitingList.Remove(it) - e.readyList.PushBack(it) - it.curList = &e.readyList + for it := e.waitingList.Front(); it != nil; { + entry := it + it = it.Next() + + if entry.id.File.Readiness(entry.mask) != 0 { + e.waitingList.Remove(entry) + e.readyList.PushBack(entry) + entry.curList = &e.readyList e.Notify(waiter.EventIn) } } diff --git a/pkg/sentry/kernel/futex/waiter_list.go b/pkg/sentry/kernel/futex/waiter_list.go index b6baa1b5b..204eededf 100755 --- a/pkg/sentry/kernel/futex/waiter_list.go +++ b/pkg/sentry/kernel/futex/waiter_list.go @@ -135,8 +135,9 @@ func (l *waiterList) InsertBefore(a, e *Waiter) { // Remove removes e from l. func (l *waiterList) Remove(e *Waiter) { - prev := waiterElementMapper{}.linkerFor(e).Prev() - next := waiterElementMapper{}.linkerFor(e).Next() + linker := waiterElementMapper{}.linkerFor(e) + prev := linker.Prev() + next := linker.Next() if prev != nil { waiterElementMapper{}.linkerFor(prev).SetNext(next) @@ -149,6 +150,9 @@ func (l *waiterList) Remove(e *Waiter) { } else { l.tail = prev } + + linker.SetNext(nil) + linker.SetPrev(nil) } // Entry is a default implementation of Linker. Users can add anonymous fields diff --git a/pkg/sentry/kernel/pending_signals_list.go b/pkg/sentry/kernel/pending_signals_list.go index 26b9ffd98..8eb40ac2c 100755 --- a/pkg/sentry/kernel/pending_signals_list.go +++ b/pkg/sentry/kernel/pending_signals_list.go @@ -135,8 +135,9 @@ func (l *pendingSignalList) InsertBefore(a, e *pendingSignal) { // Remove removes e from l. func (l *pendingSignalList) Remove(e *pendingSignal) { - prev := pendingSignalElementMapper{}.linkerFor(e).Prev() - next := pendingSignalElementMapper{}.linkerFor(e).Next() + linker := pendingSignalElementMapper{}.linkerFor(e) + prev := linker.Prev() + next := linker.Next() if prev != nil { pendingSignalElementMapper{}.linkerFor(prev).SetNext(next) @@ -149,6 +150,9 @@ func (l *pendingSignalList) Remove(e *pendingSignal) { } else { l.tail = prev } + + linker.SetNext(nil) + linker.SetPrev(nil) } // Entry is a default implementation of Linker. Users can add anonymous fields diff --git a/pkg/sentry/kernel/process_group_list.go b/pkg/sentry/kernel/process_group_list.go index 2c5363c69..40c1a13a4 100755 --- a/pkg/sentry/kernel/process_group_list.go +++ b/pkg/sentry/kernel/process_group_list.go @@ -135,8 +135,9 @@ func (l *processGroupList) InsertBefore(a, e *ProcessGroup) { // Remove removes e from l. func (l *processGroupList) Remove(e *ProcessGroup) { - prev := processGroupElementMapper{}.linkerFor(e).Prev() - next := processGroupElementMapper{}.linkerFor(e).Next() + linker := processGroupElementMapper{}.linkerFor(e) + prev := linker.Prev() + next := linker.Next() if prev != nil { processGroupElementMapper{}.linkerFor(prev).SetNext(next) @@ -149,6 +150,9 @@ func (l *processGroupList) Remove(e *ProcessGroup) { } else { l.tail = prev } + + linker.SetNext(nil) + linker.SetPrev(nil) } // Entry is a default implementation of Linker. Users can add anonymous fields diff --git a/pkg/sentry/kernel/semaphore/waiter_list.go b/pkg/sentry/kernel/semaphore/waiter_list.go index 78d86900a..27120afe3 100755 --- a/pkg/sentry/kernel/semaphore/waiter_list.go +++ b/pkg/sentry/kernel/semaphore/waiter_list.go @@ -135,8 +135,9 @@ func (l *waiterList) InsertBefore(a, e *waiter) { // Remove removes e from l. func (l *waiterList) Remove(e *waiter) { - prev := waiterElementMapper{}.linkerFor(e).Prev() - next := waiterElementMapper{}.linkerFor(e).Next() + linker := waiterElementMapper{}.linkerFor(e) + prev := linker.Prev() + next := linker.Next() if prev != nil { waiterElementMapper{}.linkerFor(prev).SetNext(next) @@ -149,6 +150,9 @@ func (l *waiterList) Remove(e *waiter) { } else { l.tail = prev } + + linker.SetNext(nil) + linker.SetPrev(nil) } // Entry is a default implementation of Linker. Users can add anonymous fields diff --git a/pkg/sentry/kernel/session_list.go b/pkg/sentry/kernel/session_list.go index e65688f53..8174f413d 100755 --- a/pkg/sentry/kernel/session_list.go +++ b/pkg/sentry/kernel/session_list.go @@ -135,8 +135,9 @@ func (l *sessionList) InsertBefore(a, e *Session) { // Remove removes e from l. func (l *sessionList) Remove(e *Session) { - prev := sessionElementMapper{}.linkerFor(e).Prev() - next := sessionElementMapper{}.linkerFor(e).Next() + linker := sessionElementMapper{}.linkerFor(e) + prev := linker.Prev() + next := linker.Next() if prev != nil { sessionElementMapper{}.linkerFor(prev).SetNext(next) @@ -149,6 +150,9 @@ func (l *sessionList) Remove(e *Session) { } else { l.tail = prev } + + linker.SetNext(nil) + linker.SetPrev(nil) } // Entry is a default implementation of Linker. Users can add anonymous fields diff --git a/pkg/sentry/kernel/socket_list.go b/pkg/sentry/kernel/socket_list.go index a3d47e381..ac93e2365 100755 --- a/pkg/sentry/kernel/socket_list.go +++ b/pkg/sentry/kernel/socket_list.go @@ -135,8 +135,9 @@ func (l *socketList) InsertBefore(a, e *SocketEntry) { // Remove removes e from l. func (l *socketList) Remove(e *SocketEntry) { - prev := socketElementMapper{}.linkerFor(e).Prev() - next := socketElementMapper{}.linkerFor(e).Next() + linker := socketElementMapper{}.linkerFor(e) + prev := linker.Prev() + next := linker.Next() if prev != nil { socketElementMapper{}.linkerFor(prev).SetNext(next) @@ -149,6 +150,9 @@ func (l *socketList) Remove(e *SocketEntry) { } else { l.tail = prev } + + linker.SetNext(nil) + linker.SetPrev(nil) } // Entry is a default implementation of Linker. Users can add anonymous fields diff --git a/pkg/sentry/kernel/task_list.go b/pkg/sentry/kernel/task_list.go index 9b8f07b46..4dfcdbf2c 100755 --- a/pkg/sentry/kernel/task_list.go +++ b/pkg/sentry/kernel/task_list.go @@ -135,8 +135,9 @@ func (l *taskList) InsertBefore(a, e *Task) { // Remove removes e from l. func (l *taskList) Remove(e *Task) { - prev := taskElementMapper{}.linkerFor(e).Prev() - next := taskElementMapper{}.linkerFor(e).Next() + linker := taskElementMapper{}.linkerFor(e) + prev := linker.Prev() + next := linker.Next() if prev != nil { taskElementMapper{}.linkerFor(prev).SetNext(next) @@ -149,6 +150,9 @@ func (l *taskList) Remove(e *Task) { } else { l.tail = prev } + + linker.SetNext(nil) + linker.SetPrev(nil) } // Entry is a default implementation of Linker. Users can add anonymous fields diff --git a/pkg/sentry/mm/io_list.go b/pkg/sentry/mm/io_list.go index ecb9d4b04..287e4305c 100755 --- a/pkg/sentry/mm/io_list.go +++ b/pkg/sentry/mm/io_list.go @@ -135,8 +135,9 @@ func (l *ioList) InsertBefore(a, e *ioResult) { // Remove removes e from l. func (l *ioList) Remove(e *ioResult) { - prev := ioElementMapper{}.linkerFor(e).Prev() - next := ioElementMapper{}.linkerFor(e).Next() + linker := ioElementMapper{}.linkerFor(e) + prev := linker.Prev() + next := linker.Next() if prev != nil { ioElementMapper{}.linkerFor(prev).SetNext(next) @@ -149,6 +150,9 @@ func (l *ioList) Remove(e *ioResult) { } else { l.tail = prev } + + linker.SetNext(nil) + linker.SetPrev(nil) } // Entry is a default implementation of Linker. Users can add anonymous fields diff --git a/pkg/sentry/socket/unix/transport/transport_message_list.go b/pkg/sentry/socket/unix/transport/transport_message_list.go index 565a821bd..9edc731b4 100755 --- a/pkg/sentry/socket/unix/transport/transport_message_list.go +++ b/pkg/sentry/socket/unix/transport/transport_message_list.go @@ -135,8 +135,9 @@ func (l *messageList) InsertBefore(a, e *message) { // Remove removes e from l. func (l *messageList) Remove(e *message) { - prev := messageElementMapper{}.linkerFor(e).Prev() - next := messageElementMapper{}.linkerFor(e).Next() + linker := messageElementMapper{}.linkerFor(e) + prev := linker.Prev() + next := linker.Next() if prev != nil { messageElementMapper{}.linkerFor(prev).SetNext(next) @@ -149,6 +150,9 @@ func (l *messageList) Remove(e *message) { } else { l.tail = prev } + + linker.SetNext(nil) + linker.SetPrev(nil) } // Entry is a default implementation of Linker. Users can add anonymous fields diff --git a/pkg/sentry/vfs/epoll_interest_list.go b/pkg/sentry/vfs/epoll_interest_list.go index 011373f0f..1bd41f400 100755 --- a/pkg/sentry/vfs/epoll_interest_list.go +++ b/pkg/sentry/vfs/epoll_interest_list.go @@ -135,8 +135,9 @@ func (l *epollInterestList) InsertBefore(a, e *epollInterest) { // Remove removes e from l. func (l *epollInterestList) Remove(e *epollInterest) { - prev := epollInterestElementMapper{}.linkerFor(e).Prev() - next := epollInterestElementMapper{}.linkerFor(e).Next() + linker := epollInterestElementMapper{}.linkerFor(e) + prev := linker.Prev() + next := linker.Next() if prev != nil { epollInterestElementMapper{}.linkerFor(prev).SetNext(next) @@ -149,6 +150,9 @@ func (l *epollInterestList) Remove(e *epollInterest) { } else { l.tail = prev } + + linker.SetNext(nil) + linker.SetPrev(nil) } // Entry is a default implementation of Linker. Users can add anonymous fields |