github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/sys/openbsd/init_test.go (about)

     1  // Copyright 2019 syzkaller project authors. All rights reserved.
     2  // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
     3  
     4  package openbsd_test
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/google/syzkaller/prog"
    10  	_ "github.com/google/syzkaller/sys/openbsd/gen"
    11  	"github.com/google/syzkaller/sys/targets"
    12  )
    13  
    14  func TestNeutralize(t *testing.T) {
    15  	prog.TestDeserializeHelper(t, targets.OpenBSD, targets.AMD64, nil, []prog.DeserializeTest{
    16  		{
    17  			In:  `chflagsat(0x0, 0x0, 0x60004, 0x0)`,
    18  			Out: `chflagsat(0x0, 0x0, 0x0, 0x0)`,
    19  		},
    20  		{
    21  			In:  `fchflags(0x0, 0x60004)`,
    22  			Out: `fchflags(0x0, 0x0)`,
    23  		},
    24  		// Note, a random ioctl description used since only the command
    25  		// is of importance.
    26  		{
    27  			In:  `ioctl$BIOCSDIRFILT(0x0, 0xc0e04429, 0x0)`,
    28  			Out: `ioctl$BIOCSDIRFILT(0x0, 0x0, 0x0)`,
    29  		},
    30  		{
    31  			In:  `ioctl$BIOCSDIRFILT(0x0, 0xc0e04412, 0x0)`,
    32  			Out: `ioctl$BIOCSDIRFILT(0x0, 0x0, 0x0)`,
    33  		},
    34  		{
    35  			// major=22, minor=232
    36  			In:  `mknodat(0x0, 0x0, 0x0, 0x16e8)`,
    37  			Out: `mknodat(0x0, 0x0, 0x0, 0x202)`,
    38  		},
    39  		{
    40  			// major=22, minor=232
    41  			In:  `mknod(0x0, 0x0, 0x16e8)`,
    42  			Out: `mknod(0x0, 0x0, 0x202)`,
    43  		},
    44  		{
    45  			// major=22, minor=0
    46  			In: `mknod(0x0, 0x0, 0x1600)`,
    47  		},
    48  		{
    49  			// major=4, minor=0
    50  			In: `mknod(0x0, 0x0, 0x400)`,
    51  		},
    52  		{
    53  			// major=4, minor=1
    54  			In:  `mknod(0x0, 0x0, 0x401)`,
    55  			Out: `mknod(0x0, 0x0, 0x202)`,
    56  		},
    57  		{
    58  			// major=4, minor=2
    59  			In:  `mknod(0x0, 0x0, 0x402)`,
    60  			Out: `mknod(0x0, 0x0, 0x202)`,
    61  		},
    62  		{
    63  			// MCL_CURRENT | MCL_FUTURE
    64  			In:  `mlockall(0x3)`,
    65  			Out: `mlockall(0x1)`,
    66  		},
    67  		{
    68  			// RLIMIT_DATA
    69  			In:  `setrlimit(0x2, &(0x7f0000cc0ff0)={0x0, 0x80000000})`,
    70  			Out: `setrlimit(0x2, &(0x7f0000cc0ff0)={0x60000000, 0x80000000})`,
    71  		},
    72  		{
    73  			// RLIMIT_DATA
    74  			In:  `setrlimit(0x10000000000002, &(0x7f0000cc0ff0)={0x0, 0x80000000})`,
    75  			Out: `setrlimit(0x10000000000002, &(0x7f0000cc0ff0)={0x60000000, 0x80000000})`,
    76  		},
    77  		{
    78  			// RLIMIT_STACK
    79  			In:  `setrlimit(0x3, &(0x7f0000cc0ff0)={0x1000000000, 0x1000000000})`,
    80  			Out: `setrlimit(0x3, &(0x7f0000cc0ff0)={0x100000, 0x100000})`,
    81  		},
    82  		{
    83  			// RLIMIT_CPU
    84  			In: `setrlimit(0x0, &(0x7f0000cc0ff0)={0x1, 0x1})`,
    85  		},
    86  		{
    87  			// Test for sysctl kern.maxclusters.
    88  			In:  `sysctl$kern(&(0x7f0000cc0ff0)={0x1, 0x43}, 0x2, 0x0, 0x0, &(0x7f0000000180), 0x0)`,
    89  			Out: `sysctl$kern(&(0x7f0000cc0ff0)={0x0}, 0x0, 0x0, 0x0, &(0x7f0000000180), 0x0)`,
    90  		},
    91  		{
    92  			// Test for sysctl kern.maxproc.
    93  			In:  `sysctl$kern(&(0x7f0000000300)={0x1, 0x6}, 0x2, 0x0, 0x0, &(0x7f0000000300)="ff0380c5", 0x4)`,
    94  			Out: `sysctl$kern(&(0x7f0000000300)={0x0}, 0x0, 0x0, 0x0, &(0x7f0000000300)="ff0380c5", 0x4)`,
    95  		},
    96  		{
    97  			// Test for sysctl kern.maxfiles.
    98  			In:  `sysctl$kern(&(0x7f0000000300)={0x1, 0x7}, 0x2, 0x0, 0x0, &(0x7f0000000300)="ff0380c5", 0x4)`,
    99  			Out: `sysctl$kern(&(0x7f0000000300)={0x0}, 0x0, 0x0, 0x0, &(0x7f0000000300)="ff0380c5", 0x4)`,
   100  		},
   101  		{
   102  			// Test for sysctl kern.maxthread.
   103  			In:  `sysctl$kern(&(0x7f0000000300)={0x1, 0x19}, 0x2, 0x0, 0x0, &(0x7f0000000300)="ff0380c5", 0x4)`,
   104  			Out: `sysctl$kern(&(0x7f0000000300)={0x0}, 0x0, 0x0, 0x0, &(0x7f0000000300)="ff0380c5", 0x4)`,
   105  		},
   106  		{
   107  			// Test for sysctl kern.witness.
   108  			In:  `sysctl$kern(&(0x7f0000000300)={0x1, 0x3c}, 0x2, 0x0, 0x0, &(0x7f0000000300)="ff0380c5", 0x4)`,
   109  			Out: `sysctl$kern(&(0x7f0000000300)={0x0}, 0x0, 0x0, 0x0, &(0x7f0000000300)="ff0380c5", 0x4)`,
   110  		},
   111  		{
   112  			In:  `clock_settime(0x0, &(0x7f0000cc0ff0)={0x0, 0x0})`,
   113  			Out: `clock_settime(0xffffffffffffffff, &(0x7f0000cc0ff0))`,
   114  		},
   115  	})
   116  }