Remove existing nogo exceptions.

PiperOrigin-RevId: 347047550
This commit is contained in:
Adin Scannell
2020-12-11 12:06:49 -08:00
committed by gVisor bot
parent 76c2f21cec
commit 4cba3904f4
46 changed files with 231 additions and 249 deletions
+21 -117
View File
@@ -56,123 +56,8 @@ global:
- "should not use ALL_CAPS in Go names"
- "should not use underscores in Go names"
exclude:
# A variety of staticcheck and stylecheck
# rules apply here. These should be fixed
# and removed from here, and the global
# rules should be used sparingly.
- pkg/abi/linux/fuse.go:22
- pkg/abi/linux/fuse.go:25
- pkg/abi/linux/socket.go:113
- pkg/abi/linux/tty.go:73
- pkg/cpuid/cpuid_x86.go:675
- pkg/gohacks/gohacks_unsafe.go:33
- pkg/log/json.go:30
- pkg/log/log.go:359
- pkg/metric/metric_test.go:20
- pkg/p9/p9test/client_test.go:687
- pkg/p9/transport_test.go:196
- pkg/pool/pool.go:15
- pkg/refs/refcounter.go:510
- pkg/refs/refcounter_test.go:169
- pkg/safemem/block_unsafe.go:89
- pkg/seccomp/seccomp.go:82
- pkg/segment/test/set_functions.go:15
- pkg/sentry/arch/signal.go:166
- pkg/sentry/arch/signal.go:171
- pkg/sentry/control/pprof.go:196
- pkg/sentry/devices/memdev/full.go:58
- pkg/sentry/devices/memdev/null.go:59
- pkg/sentry/devices/memdev/random.go:68
- pkg/sentry/devices/memdev/zero.go:86
- pkg/sentry/fdimport/fdimport.go:15
- pkg/sentry/fs/attr.go:257
- pkg/sentry/fsbridge/fs.go:116
- pkg/sentry/fsbridge/vfs.go:124
- pkg/sentry/fsbridge/vfs.go:70
- pkg/sentry/fs/copy_up.go:365
- pkg/sentry/fs/copy_up_test.go:65
- pkg/sentry/fs/dev/net_tun.go:161
- pkg/sentry/fs/dev/net_tun.go:63
- pkg/sentry/fs/dev/null.go:97
- pkg/sentry/fs/dirent_cache.go:64
- pkg/sentry/fs/fdpipe/pipe_opener_test.go:366
- pkg/sentry/fs/file_overlay.go:327
- pkg/sentry/fs/file_overlay.go:524
- pkg/sentry/fs/filetest/filetest.go:55
- pkg/sentry/fs/filetest/filetest.go:60
- pkg/sentry/fs/fs.go:77
- pkg/sentry/fs/fsutil/file.go:290
- pkg/sentry/fs/fsutil/file.go:346
- pkg/sentry/fs/fsutil/host_file_mapper.go:105
- pkg/sentry/fs/fsutil/inode_cached.go:676
- pkg/sentry/fs/fsutil/inode_cached.go:772
- pkg/sentry/fs/gofer/attr.go:120
- pkg/sentry/fs/gofer/fifo.go:33
- pkg/sentry/fs/gofer/inode.go:410
- pkg/sentry/fsimpl/ext/disklayout/superblock_64.go:97
- pkg/sentry/fsimpl/ext/disklayout/superblock_old.go:92
- pkg/sentry/fsimpl/ext/disklayout/block_group_32.go:44
- pkg/sentry/fsimpl/ext/disklayout/inode_new.go:91
- pkg/sentry/fsimpl/ext/disklayout/inode_old.go:93
- pkg/sentry/fsimpl/ext/disklayout/superblock_32.go:66
- pkg/sentry/fsimpl/ext/disklayout/block_group_64.go:53
- pkg/sentry/fsimpl/fuse/request_response.go:71
- pkg/sentry/fsimpl/signalfd/signalfd.go:15
- pkg/sentry/memmap/memmap.go:103
- pkg/sentry/memmap/memmap.go:163
- pkg/sentry/mm/aio_context.go:208
- pkg/sentry/mm/pma.go:683
- pkg/sentry/usage/cpu.go:42
- pkg/shim/runsc/runsc.go:16
- pkg/shim/runsc/utils.go:16
- pkg/shim/v1/proc/deleted_state.go:16
- pkg/shim/v1/proc/exec.go:16
- pkg/shim/v1/proc/exec_state.go:16
- pkg/shim/v1/proc/init.go:16
- pkg/shim/v1/proc/init_state.go:16
- pkg/shim/v1/proc/io.go:16
- pkg/shim/v1/proc/process.go:16
- pkg/shim/v1/proc/types.go:16
- pkg/shim/v1/proc/utils.go:16
- pkg/shim/v1/shim/api.go:16
- pkg/shim/v1/shim/platform.go:16
- pkg/shim/v1/shim/service.go:16
- pkg/shim/v1/utils/annotations.go:15
- pkg/shim/v1/utils/utils.go:15
- pkg/shim/v1/utils/volumes.go:15
- pkg/shim/v2/api.go:16
- pkg/shim/v2/epoll.go:18
- pkg/shim/v2/options/options.go:15
- pkg/shim/v2/options/options.go:24
- pkg/shim/v2/options/options.go:26
- pkg/shim/v2/runtimeoptions/runtimeoptions.go:16
- pkg/shim/v2/runtimeoptions/runtimeoptions_cri.go # Generated: exempt all.
- pkg/shim/v2/runtimeoptions/runtimeoptions_test.go:22
- pkg/shim/v2/service.go:15
- pkg/shim/v2/service_linux.go:18
- pkg/state/tests/integer_test.go:23
- pkg/state/tests/integer_test.go:28
- pkg/sync/rwmutex_test.go:105
- pkg/syserr/host_linux.go:35
- pkg/usermem/addr.go:34
- pkg/usermem/usermem.go:171
- pkg/usermem/usermem.go:170
- runsc/boot/compat.go:56
- test/cmd/test_app/fds.go:171
- test/iptables/filter_output.go:251
- test/packetimpact/testbench/connections.go:77
- tools/bigquery/bigquery.go:106
- tools/checkescape/test1/test1.go:108
- tools/checkescape/test1/test1.go:122
- tools/checkescape/test1/test1.go:137
- tools/checkescape/test1/test1.go:151
- tools/checkescape/test1/test1.go:170
- tools/checkescape/test1/test1.go:39
- tools/checkescape/test1/test1.go:45
- tools/checkescape/test1/test1.go:50
- tools/checkescape/test1/test1.go:64
- tools/checkescape/test1/test1.go:80
- tools/checkescape/test1/test1.go:94
# Generated: exempt all.
- pkg/shim/v2/runtimeoptions/runtimeoptions_cri.go
analyzers:
asmdecl:
external: # Enabled.
@@ -252,3 +137,22 @@ analyzers:
external: # Enabled.
checkescape:
external: # Enabled.
SA4016:
internal:
exclude:
- pkg/gohacks/gohacks_unsafe.go # x ^ 0 always equals x.
SA2001:
internal:
exclude:
- pkg/sentry/fs/fs.go # Intentional.
- pkg/sentry/fs/gofer/inode.go # Intentional.
- pkg/refs/refcounter_test.go # Intentional.
ST1021:
internal:
suppress:
- "comment on exported type Translation" # Intentional.
- "comment on exported type PinnedRange" # Intentional.
SA5011:
internal:
exclude:
- pkg/sentry/fs/fdpipe/pipe_opener_test.go # False positive.
+7 -1
View File
@@ -19,16 +19,22 @@ import (
"gvisor.dev/gvisor/pkg/marshal/primitive"
)
// FUSEOpcode is a FUSE operation code.
//
// +marshal
type FUSEOpcode uint32
// FUSEOpID is a FUSE operation ID.
//
// +marshal
type FUSEOpID uint64
// FUSE_ROOT_ID is the id of root inode.
const FUSE_ROOT_ID = 1
// Opcodes for FUSE operations. Analogous to the opcodes in include/linux/fuse.h.
// Opcodes for FUSE operations.
//
// Analogous to the opcodes in include/linux/fuse.h.
const (
FUSE_LOOKUP FUSEOpcode = 1
FUSE_FORGET = 2 /* no reply */
+6 -6
View File
@@ -111,12 +111,12 @@ type SockType int
// Socket types, from linux/net.h.
const (
SOCK_STREAM SockType = 1
SOCK_DGRAM = 2
SOCK_RAW = 3
SOCK_RDM = 4
SOCK_SEQPACKET = 5
SOCK_DCCP = 6
SOCK_PACKET = 10
SOCK_DGRAM SockType = 2
SOCK_RAW SockType = 3
SOCK_RDM SockType = 4
SOCK_SEQPACKET SockType = 5
SOCK_DCCP SockType = 6
SOCK_PACKET SockType = 10
)
// SOCK_TYPE_MASK covers all of the above socket types. The remaining bits are
+7 -7
View File
@@ -27,8 +27,8 @@ type jsonLog struct {
}
// MarshalJSON implements json.Marshaler.MarashalJSON.
func (lv Level) MarshalJSON() ([]byte, error) {
switch lv {
func (l Level) MarshalJSON() ([]byte, error) {
switch l {
case Warning:
return []byte(`"warning"`), nil
case Info:
@@ -36,20 +36,20 @@ func (lv Level) MarshalJSON() ([]byte, error) {
case Debug:
return []byte(`"debug"`), nil
default:
return nil, fmt.Errorf("unknown level %v", lv)
return nil, fmt.Errorf("unknown level %v", l)
}
}
// UnmarshalJSON implements json.Unmarshaler.UnmarshalJSON. It can unmarshal
// from both string names and integers.
func (lv *Level) UnmarshalJSON(b []byte) error {
func (l *Level) UnmarshalJSON(b []byte) error {
switch s := string(b); s {
case "0", `"warning"`:
*lv = Warning
*l = Warning
case "1", `"info"`:
*lv = Info
*l = Info
case "2", `"debug"`:
*lv = Debug
*l = Debug
default:
return fmt.Errorf("unknown level %q", s)
}
+1 -1
View File
@@ -356,7 +356,7 @@ func CopyStandardLogTo(l Level) error {
case Warning:
f = Warningf
default:
return fmt.Errorf("Unknown log level %v", l)
return fmt.Errorf("unknown log level %v", l)
}
stdlog.SetOutput(linewriter.NewWriter(func(p []byte) {
+7 -8
View File
@@ -678,16 +678,15 @@ func renameHelper(h *Harness, root p9.File, srcNames []string, dstNames []string
// case.
defer checkDeleted(h, dst)
} else {
// If the type is different than the destination, then
// we expect the rename to fail. We expect that this
// is returned.
//
// If the file being renamed to itself, this is
// technically allowed and a no-op, but all the
// triggers will fire.
if !selfRename {
// If the type is different than the
// destination, then we expect the rename to
// fail. We expect ensure that this is
// returned.
expectedErr = syscall.EINVAL
} else {
// This is the file being renamed to itself.
// This is technically allowed and a no-op, but
// all the triggers will fire.
}
dst.Close()
}
+8 -8
View File
@@ -197,33 +197,33 @@ func BenchmarkSendRecv(b *testing.B) {
for i := 0; i < b.N; i++ {
tag, m, err := recv(server, maximumLength, msgRegistry.get)
if err != nil {
b.Fatalf("recv got err %v expected nil", err)
b.Errorf("recv got err %v expected nil", err)
}
if tag != Tag(1) {
b.Fatalf("got tag %v expected 1", tag)
b.Errorf("got tag %v expected 1", tag)
}
if _, ok := m.(*Rflush); !ok {
b.Fatalf("got message %T expected *Rflush", m)
b.Errorf("got message %T expected *Rflush", m)
}
if err := send(server, Tag(2), &Rflush{}); err != nil {
b.Fatalf("send got err %v expected nil", err)
b.Errorf("send got err %v expected nil", err)
}
}
}()
b.ResetTimer()
for i := 0; i < b.N; i++ {
if err := send(client, Tag(1), &Rflush{}); err != nil {
b.Fatalf("send got err %v expected nil", err)
b.Errorf("send got err %v expected nil", err)
}
tag, m, err := recv(client, maximumLength, msgRegistry.get)
if err != nil {
b.Fatalf("recv got err %v expected nil", err)
b.Errorf("recv got err %v expected nil", err)
}
if tag != Tag(2) {
b.Fatalf("got tag %v expected 2", tag)
b.Errorf("got tag %v expected 2", tag)
}
if _, ok := m.(*Rflush); !ok {
b.Fatalf("got message %v expected *Rflush", m)
b.Errorf("got message %v expected *Rflush", m)
}
}
}
+1
View File
@@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// Package pool provides a trivial integer pool.
package pool
import (
+10 -10
View File
@@ -68,29 +68,29 @@ func blockFromSlice(slice []byte, needSafecopy bool) Block {
}
}
// BlockFromSafePointer returns a Block equivalent to [ptr, ptr+len), which is
// BlockFromSafePointer returns a Block equivalent to [ptr, ptr+length), which is
// safe to access without safecopy.
//
// Preconditions: ptr+len does not overflow.
func BlockFromSafePointer(ptr unsafe.Pointer, len int) Block {
return blockFromPointer(ptr, len, false)
// Preconditions: ptr+length does not overflow.
func BlockFromSafePointer(ptr unsafe.Pointer, length int) Block {
return blockFromPointer(ptr, length, false)
}
// BlockFromUnsafePointer returns a Block equivalent to [ptr, ptr+len), which
// is not safe to access without safecopy.
//
// Preconditions: ptr+len does not overflow.
func BlockFromUnsafePointer(ptr unsafe.Pointer, len int) Block {
return blockFromPointer(ptr, len, true)
func BlockFromUnsafePointer(ptr unsafe.Pointer, length int) Block {
return blockFromPointer(ptr, length, true)
}
func blockFromPointer(ptr unsafe.Pointer, len int, needSafecopy bool) Block {
if uptr := uintptr(ptr); uptr+uintptr(len) < uptr {
panic(fmt.Sprintf("ptr %#x + len %#x overflows", ptr, len))
func blockFromPointer(ptr unsafe.Pointer, length int, needSafecopy bool) Block {
if uptr := uintptr(ptr); uptr+uintptr(length) < uptr {
panic(fmt.Sprintf("ptr %#x + len %#x overflows", uptr, length))
}
return Block{
start: ptr,
length: len,
length: length,
needSafecopy: needSafecopy,
}
}
+1 -1
View File
@@ -79,7 +79,7 @@ func Install(rules SyscallRules) error {
// Perform the actual installation.
if errno := SetFilter(instrs); errno != 0 {
return fmt.Errorf("Failed to set filter: %v", errno)
return fmt.Errorf("failed to set filter: %v", errno)
}
log.Infof("Seccomp filters installed.")
+1
View File
@@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// Package segment is a test package.
package segment
type setFunctions struct{}
+8 -8
View File
@@ -152,23 +152,23 @@ func (s *SignalInfo) FixSignalCodeForUser() {
}
}
// Pid returns the si_pid field.
func (s *SignalInfo) Pid() int32 {
// PID returns the si_pid field.
func (s *SignalInfo) PID() int32 {
return int32(usermem.ByteOrder.Uint32(s.Fields[0:4]))
}
// SetPid mutates the si_pid field.
func (s *SignalInfo) SetPid(val int32) {
// SetPID mutates the si_pid field.
func (s *SignalInfo) SetPID(val int32) {
usermem.ByteOrder.PutUint32(s.Fields[0:4], uint32(val))
}
// Uid returns the si_uid field.
func (s *SignalInfo) Uid() int32 {
// UID returns the si_uid field.
func (s *SignalInfo) UID() int32 {
return int32(usermem.ByteOrder.Uint32(s.Fields[4:8]))
}
// SetUid mutates the si_uid field.
func (s *SignalInfo) SetUid(val int32) {
// SetUID mutates the si_uid field.
func (s *SignalInfo) SetUID(val int32) {
usermem.ByteOrder.PutUint32(s.Fields[4:8], uint32(val))
}
+1 -1
View File
@@ -193,7 +193,7 @@ func (p *Profile) StopTrace(_, _ *struct{}) error {
defer p.mu.Unlock()
if p.traceFile == nil {
return errors.New("Execution tracing not started")
return errors.New("execution tracing not started")
}
// Similarly to the case above, if tasks have not ended traces, we will
+1
View File
@@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// Package fdimport provides the Import function.
package fdimport
import (
+9 -4
View File
@@ -336,7 +336,12 @@ func cleanupUpper(ctx context.Context, parent *Inode, name string, copyUpErr err
// copyUpBuffers is a buffer pool for copying file content. The buffer
// size is the same used by io.Copy.
var copyUpBuffers = sync.Pool{New: func() interface{} { return make([]byte, 8*usermem.PageSize) }}
var copyUpBuffers = sync.Pool{
New: func() interface{} {
b := make([]byte, 8*usermem.PageSize)
return &b
},
}
// copyContentsLocked copies the contents of lower to upper. It panics if
// less than size bytes can be copied.
@@ -361,7 +366,7 @@ func copyContentsLocked(ctx context.Context, upper *Inode, lower *Inode, size in
defer lowerFile.DecRef(ctx)
// Use a buffer pool to minimize allocations.
buf := copyUpBuffers.Get().([]byte)
buf := copyUpBuffers.Get().(*[]byte)
defer copyUpBuffers.Put(buf)
// Transfer the contents.
@@ -371,7 +376,7 @@ func copyContentsLocked(ctx context.Context, upper *Inode, lower *Inode, size in
// optimizations could be self-defeating. So we leave this as simple as possible.
var offset int64
for {
nr, err := lowerFile.FileOperations.Read(ctx, lowerFile, usermem.BytesIOSequence(buf), offset)
nr, err := lowerFile.FileOperations.Read(ctx, lowerFile, usermem.BytesIOSequence(*buf), offset)
if err != nil && err != io.EOF {
return err
}
@@ -383,7 +388,7 @@ func copyContentsLocked(ctx context.Context, upper *Inode, lower *Inode, size in
}
return nil
}
nw, err := upperFile.FileOperations.Write(ctx, upperFile, usermem.BytesIOSequence(buf[:nr]), offset)
nw, err := upperFile.FileOperations.Write(ctx, upperFile, usermem.BytesIOSequence((*buf)[:nr]), offset)
if err != nil {
return err
}
+1 -1
View File
@@ -64,7 +64,7 @@ func TestConcurrentCopyUp(t *testing.T) {
wg.Add(1)
go func(o *overlayTestFile) {
if err := o.File.Dirent.Inode.Truncate(ctx, o.File.Dirent, truncateFileSize); err != nil {
t.Fatalf("failed to copy up: %v", err)
t.Errorf("failed to copy up: %v", err)
}
wg.Done()
}(file)
+2 -2
View File
@@ -52,10 +52,10 @@ func NewTestFile(tb testing.TB) *fs.File {
// Read just fails the request.
func (*TestFileOperations) Read(context.Context, *fs.File, usermem.IOSequence, int64) (int64, error) {
return 0, fmt.Errorf("Readv not implemented")
return 0, fmt.Errorf("TestFileOperations.Read not implemented")
}
// Write just fails the request.
func (*TestFileOperations) Write(context.Context, *fs.File, usermem.IOSequence, int64) (int64, error) {
return 0, fmt.Errorf("Writev not implemented")
return 0, fmt.Errorf("TestFileOperations.Write not implemented")
}
-2
View File
@@ -117,8 +117,6 @@ func ntype(pattr p9.Attr) fs.InodeType {
return fs.BlockDevice
case pattr.Mode.IsSocket():
return fs.Socket
case pattr.Mode.IsRegular():
fallthrough
default:
return fs.RegularFile
}
@@ -70,6 +70,7 @@ func (r *fuseInitRes) UnmarshalBytes(src []byte) {
out.MaxPages = uint16(usermem.ByteOrder.Uint16(src[:2]))
src = src[2:]
}
_ = src // Remove unused warning.
}
// SizeBytes is the size of the payload of the FUSE_INIT response.
+3 -2
View File
@@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// Package signalfd provides basic signalfd file implementations.
package signalfd
import (
@@ -98,8 +99,8 @@ func (sfd *SignalFileDescription) Read(ctx context.Context, dst usermem.IOSequen
Signo: uint32(info.Signo),
Errno: info.Errno,
Code: info.Code,
PID: uint32(info.Pid()),
UID: uint32(info.Uid()),
PID: uint32(info.PID()),
UID: uint32(info.UID()),
Status: info.Status(),
Overrun: uint32(info.Overrun()),
Addr: info.Addr(),

Some files were not shown because too many files have changed in this diff Show More