diff options
author | gVisor bot <gvisor-bot@google.com> | 2019-07-31 19:08:43 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2019-07-31 19:08:43 +0000 |
commit | 11317b6e4187522dc50d6a606ba316a6abca436f (patch) | |
tree | 484e09cea11a0edd596a4ae7b53f163882f0fced /pkg | |
parent | 4d526c4ba1151a539b9eb8d3311a5dfc83daf5ec (diff) | |
parent | cf2b2d97d512a91261f72abe40b163c61d52705f (diff) |
Merge cf2b2d97 (automated)
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/sentry/kernel/kernel.go | 10 | ||||
-rwxr-xr-x | pkg/sentry/platform/ring0/defs_impl.go | 4 |
2 files changed, 9 insertions, 5 deletions
diff --git a/pkg/sentry/kernel/kernel.go b/pkg/sentry/kernel/kernel.go index 55a9d3d29..53c25e49e 100644 --- a/pkg/sentry/kernel/kernel.go +++ b/pkg/sentry/kernel/kernel.go @@ -198,6 +198,10 @@ type Kernel struct { // the limiter. It may be nil if disabled. DirentCacheLimiter *fs.DirentCacheLimiter + // unimplementedSyscallEmitterOnce is used in the initialization of + // unimplementedSyscallEmitter. + unimplementedSyscallEmitterOnce sync.Once `state:"nosave"` + // unimplementedSyscallEmitter is used to emit unimplemented syscall // events. This is initialized lazily on the first unimplemented // syscall. @@ -1283,7 +1287,7 @@ func (ctx supervisorContext) Value(key interface{}) interface{} { } } -// Rate limits for the number of unimplemented syscall evants. +// Rate limits for the number of unimplemented syscall events. const ( unimplementedSyscallsMaxRate = 100 // events per second unimplementedSyscallBurst = 1000 // events @@ -1292,9 +1296,9 @@ const ( // EmitUnimplementedEvent emits an UnimplementedSyscall event via the event // channel. func (k *Kernel) EmitUnimplementedEvent(ctx context.Context) { - if k.unimplementedSyscallEmitter == nil { + k.unimplementedSyscallEmitterOnce.Do(func() { k.unimplementedSyscallEmitter = eventchannel.RateLimitedEmitterFrom(eventchannel.DefaultEmitter, unimplementedSyscallsMaxRate, unimplementedSyscallBurst) - } + }) t := TaskFromContext(ctx) k.unimplementedSyscallEmitter.Emit(&uspb.UnimplementedSyscall{ diff --git a/pkg/sentry/platform/ring0/defs_impl.go b/pkg/sentry/platform/ring0/defs_impl.go index 8efc3825f..a30a9dd4a 100755 --- a/pkg/sentry/platform/ring0/defs_impl.go +++ b/pkg/sentry/platform/ring0/defs_impl.go @@ -1,13 +1,13 @@ package ring0 import ( - "fmt" "gvisor.dev/gvisor/pkg/cpuid" - "gvisor.dev/gvisor/pkg/sentry/platform/ring0/pagetables" "io" "reflect" "syscall" + "fmt" + "gvisor.dev/gvisor/pkg/sentry/platform/ring0/pagetables" "gvisor.dev/gvisor/pkg/sentry/usermem" ) |