• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * SPDX-License-Identifier: GPL-2.0
4  *
5  * Legacy blkg rwstat helpers enabled by CONFIG_BLK_CGROUP_RWSTAT.
6  * Do not use in new code.
7  *
8  * Unless required by applicable law or agreed to in writing, software
9  * distributed under the License is distributed on an "AS IS" BASIS,
10  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11  * See the License for the specific language governing permissions and
12  * limitations under the License.
13  */
14 
15 #ifndef ACCESSTOKENIDCOMMON_H
16 #define ACCESSTOKENIDCOMMON_H
17 #include <cstddef>
18 #include <cstdint>
19 
20 #define FUZZ_PROJECT_NAME "accesstokenidcommon"
21 
22 namespace OHOS {
23 namespace Kernel {
24 namespace AccessToken {
25 #define ACCESS_TOKEN_ID_IOCTL_BASE    'A'
26 
27 #ifdef CMDERROR
28 #define GET_TOKEN_ID    0
29 #define SET_TOKEN_ID    0
30 #define GET_GTOKEN_ID   0
31 #define SET_GTOKEN_ID   0
32 #else
33 #define GET_TOKEN_ID    1
34 #define SET_TOKEN_ID    2
35 #define GET_GTOKEN_ID   3
36 #define SET_GTOKEN_ID   4
37 #endif
38 
39 #define ACCESS_TOKENID_GET_TOKENID \
40         _IOR(ACCESS_TOKEN_ID_IOCTL_BASE, GET_TOKEN_ID, unsigned long long)
41 #define ACCESS_TOKENID_SET_TOKENID \
42         _IOW(ACCESS_TOKEN_ID_IOCTL_BASE, SET_TOKEN_ID, unsigned long long)
43 #define ACCESS_TOKENID_GET_FTOKENID \
44         _IOR(ACCESS_TOKEN_ID_IOCTL_BASE, GET_GTOKEN_ID, unsigned long long)
45 #define ACCESS_TOKENID_SET_FTOKENID \
46         _IOW(ACCESS_TOKEN_ID_IOCTL_BASE, SET_GTOKEN_ID, unsigned long long)
47 
48 #define LIST_NUM_1    1
49 #define LIST_NUM_2    2
50 #define TEST_VALUE    123
51 #define CHILDREN_NUM    3
52 #define WAIT_FOR_SHELL_OP_TIME    1
53 #define FATHER_WAIT_TIME    (WAIT_FOR_SHELL_OP_TIME * (CHILDREN_NUM + 1))
54 
55 #define ACCESS_TOKEN_UID    3020
56 #define ACCESS_TOKEN_GRPID  3020
57 
58 #define ACCESS_TOKEN_OTHER_UID      1234
59 #define ACCESS_TOKEN_OTHER_GRPID    1234
60 
61 #define INVAL_TOKEN    0xffffffffffffffff
62 
63 int GetTokenid(unsigned long long *token);
64 int SetTokenid(unsigned long long *token);
65 int GetfTokenid(unsigned long long *ftoken);
66 int SetfTokenid(unsigned long long *ftoken);
67 
68 void SetUidAndGrp();
69 void SetUidAndGrpOther();
70 void GetCurToken(unsigned long long *token);
71 void SetRandTokenAndCheck(unsigned long long *dataToken);
72 void TokenTest(unsigned long long *dataToken);
73 void ThreadTest(unsigned long long *dataToken);
74 int AccessTokenidThreadTest(uint8_t *dataToken);
75 int AccessTokenidGrpTest(uint8_t *dataToken);
76 int AccessTokenidGrpTestOther(uint8_t *dataToken);
77 
78 void GetCurfToken(unsigned long long *ftoken);
79 void SetRandfTokenAndCheck(unsigned long long *dataFtoken);
80 void FTokenTest(unsigned long long *dataFtoken);
81 void ThreadTest(unsigned long long *dataFtoken);
82 int AccessfTokenidThreadTest(uint8_t *dataFtoken);
83 int AccessfTokenidGrpTest(uint8_t *dataFtoken);
84 int AccessfTokenidGrpTestOther(uint8_t *dataFtoken);
85 bool SetfTokenidCmdFuzzTest(const uint8_t *data, size_t size);
86 bool GetfTokenidCmdFuzzTest(const uint8_t *data, size_t size);
87 bool SetTokenidCmdFuzzTest(const uint8_t *data, size_t size);
88 bool GetTokenidCmdFuzzTest(const uint8_t *data, size_t size);
89 } // namespace AccessToken
90 } // namespace Kernel
91 } // namespace OHOS
92 
93 #endif // ACCESSTOKENIDCOMMON_H
94