github.com/google/syzkaller@v0.0.0-20251211124644-a066d2bc4b02/tools/syz-declextract/testdata/scopes.c (about)

     1  // Copyright 2024 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  #include "include/fs.h"
     5  #include "include/syscall.h"
     6  #include "include/uapi/file_operations.h"
     7  
     8  #define LARGE_UINT (1ull<<63) // this is supposed to overflow int64
     9  #define LARGE_SINT (20ll<<63) // this is supposed to overflow uint64
    10  
    11  static int scopes_helper(long cmd, long aux) {
    12  	switch (cmd) {
    13  	case FOO_IOCTL7:
    14  		return alloc_fd();
    15  	case FOO_IOCTL8:
    16  		__fget_light(aux);
    17  		break;
    18  	case LARGE_UINT:
    19  	case LARGE_SINT:
    20  		break;
    21  	}
    22  	return 0;
    23  }
    24  
    25  SYSCALL_DEFINE1(scopes0, int x, long cmd, long aux) {
    26  	int tmp = 0;
    27  	__fget_light(aux);
    28  	switch (cmd) {
    29  	case FOO_IOCTL1:
    30  		__fget_light(x);
    31  		break;
    32  	case FOO_IOCTL2:
    33  	case FOO_IOCTL3:
    34  		tmp = alloc_fd();
    35  		return tmp;
    36  	case FOO_IOCTL4 ... FOO_IOCTL4 + 2:
    37  		tmp++;
    38  		break;
    39  	case FOO_IOCTL7:
    40  	case FOO_IOCTL8:
    41  		tmp = scopes_helper(cmd, x);
    42  		break;
    43  	case 100 ... 102:
    44  		tmp++;
    45  		break;
    46  	default:
    47  		tmp = cmd;
    48  		break;
    49  	}
    50  	return tmp;
    51  }