mirror of
https://github.com/openharmony/kernel_linux_build.git
synced 2026-07-19 16:24:25 -04:00
add access_to_ken_id new dtfuzzer testcase
Signed-off-by: wenfei <wenfei9@huawei.com>
This commit is contained in:
@@ -16,13 +16,23 @@ group("fuzztest") {
|
||||
deps = []
|
||||
|
||||
deps += [
|
||||
"accessftokenidgrptest_fuzzer:AccessfTokenidGrpTestFuzzTest",
|
||||
"accessftokenidgrptestother_fuzzer:AccessfTokenidGrpTestOtherFuzzTest",
|
||||
"accessftokenidthreadtest_fuzzer:AccessfTokenidThreadTestFuzzTest",
|
||||
"accesstokenidgrptest_fuzzer:AccessTokenidGrpTestFuzzTest",
|
||||
"accesstokenidgrptestother_fuzzer:AccessTokenidGrpTestOtherFuzzTest",
|
||||
"accesstokenidthreadtest_fuzzer:AccessTokenidThreadTestFuzzTest",
|
||||
"getftokenidcmdcorrect_fuzzer:GetfTokenidCmdCorrectFuzzTest",
|
||||
"getftokenidcmderror_fuzzer:GetfTokenidCmdErrorFuzzTest",
|
||||
"getftokenidnullptr_fuzzer:GetfTokenidNullptrFuzzTest",
|
||||
"gettokenidcmdcorrect_fuzzer:GetTokenidCmdCorrectFuzzTest",
|
||||
"gettokenidcmderror_fuzzer:GetTokenidCmdErrorFuzzTest",
|
||||
"gettokenidnullptr_fuzzer:GetTokenidNullptrFuzzTest",
|
||||
"setftokenidcmdcorrect_fuzzer:SetfTokenidCmdCorrectFuzzTest",
|
||||
"setftokenidcmderror_fuzzer:SetfTokenidCmdErrorFuzzTest",
|
||||
"setftokenidnullptr_fuzzer:SetfTokenidNullptrFuzzTest",
|
||||
"settokenidcmdcorrect_fuzzer:SetTokenidCmdCorrectFuzzTest",
|
||||
"settokenidcmderror_fuzzer:SetTokenidCmdErrorFuzzTest",
|
||||
"settokenidnullptr_fuzzer:SetTokenidNullptrFuzzTest",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/config/features.gni")
|
||||
import("//build/test.gni")
|
||||
|
||||
module_output_path = "linuxkerneltest/accesstokenid"
|
||||
|
||||
ohos_fuzztest("AccessfTokenidGrpTestFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
"-pthread",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"../src/accessftokenidcommon.cpp",
|
||||
"accessftokenidgrptest_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":AccessfTokenidGrpTestFuzzTest" ]
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include "accessftokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::Kernel::AccessToken;
|
||||
namespace OHOS {
|
||||
bool AccessfTokenidGrpTestFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
bool ret = false;
|
||||
if ((data == nullptr) || (size < sizeof(unsigned long long))) {
|
||||
return ret;
|
||||
} else {
|
||||
uint8_t *data_ftoken = const_cast<uint8_t *>(data);
|
||||
ret = AccessfTokenidGrpTest(data_ftoken);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
OHOS::AccessfTokenidGrpTestFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
# Copyright (c) 2020-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<fuzz_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
||||
@@ -0,0 +1,43 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/config/features.gni")
|
||||
import("//build/test.gni")
|
||||
|
||||
module_output_path = "linuxkerneltest/accesstokenid"
|
||||
|
||||
ohos_fuzztest("AccessfTokenidGrpTestOtherFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
"-pthread",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"../src/accessftokenidcommon.cpp",
|
||||
"accessftokenidgrptestother_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":AccessfTokenidGrpTestOtherFuzzTest" ]
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include "accessftokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::Kernel::AccessToken;
|
||||
namespace OHOS {
|
||||
bool AccessfTokenidGrpTestOtherFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
bool ret = false;
|
||||
if ((data == nullptr) || (size < sizeof(unsigned long long))) {
|
||||
return ret;
|
||||
} else {
|
||||
uint8_t *data_ftoken = const_cast<uint8_t *>(data);
|
||||
ret = AccessfTokenidGrpTestOther(data_ftoken);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
OHOS::AccessfTokenidGrpTestOtherFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
# Copyright (c) 2020-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<fuzz_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
||||
@@ -0,0 +1,43 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/config/features.gni")
|
||||
import("//build/test.gni")
|
||||
|
||||
module_output_path = "linuxkerneltest/accesstokenid"
|
||||
|
||||
ohos_fuzztest("AccessfTokenidThreadTestFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
"-pthread",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"../src/accessftokenidcommon.cpp",
|
||||
"accessftokenidthreadtest_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":AccessfTokenidThreadTestFuzzTest" ]
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include "accessftokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::Kernel::AccessToken;
|
||||
namespace OHOS {
|
||||
bool AccessfTokenidThreadTestFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
bool ret = false;
|
||||
if ((data == nullptr) || (size < sizeof(unsigned long long))) {
|
||||
return ret;
|
||||
} else {
|
||||
uint8_t *data_ftoken = const_cast<uint8_t *>(data);
|
||||
ret = AccessfTokenidThreadTest(data_ftoken);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
OHOS::AccessfTokenidThreadTestFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
# Copyright (c) 2020-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<fuzz_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
||||
@@ -0,0 +1,43 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/config/features.gni")
|
||||
import("//build/test.gni")
|
||||
|
||||
module_output_path = "linuxkerneltest/accesstokenid"
|
||||
|
||||
ohos_fuzztest("AccessTokenidGrpTestFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/accesstokenidgrptest_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
"-pthread",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"../src/accesstokenidcommon.cpp",
|
||||
"accesstokenidgrptest_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":AccessTokenidGrpTestFuzzTest" ]
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include "accesstokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::Kernel::AccessToken;
|
||||
namespace OHOS {
|
||||
bool AccessTokenidGrpTestFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
bool ret = false;
|
||||
if ((data == nullptr) || (size < sizeof(unsigned long long))) {
|
||||
return ret;
|
||||
} else {
|
||||
uint8_t *data_token = const_cast<uint8_t *>(data);
|
||||
ret = AccessTokenidGrpTest(data_token);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
OHOS::AccessTokenidGrpTestFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
# Copyright (c) 2020-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<fuzz_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
||||
@@ -0,0 +1,43 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/config/features.gni")
|
||||
import("//build/test.gni")
|
||||
|
||||
module_output_path = "linuxkerneltest/accesstokenid"
|
||||
|
||||
ohos_fuzztest("AccessTokenidGrpTestOtherFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/accesstokenidgrptestother_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
"-pthread",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"../src/accesstokenidcommon.cpp",
|
||||
"accesstokenidgrptestother_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":AccessTokenidGrpTestOtherFuzzTest" ]
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include "accesstokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::Kernel::AccessToken;
|
||||
namespace OHOS {
|
||||
bool AccessTokenidGrpTestOtherFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
bool ret = false;
|
||||
if ((data == nullptr) || (size < sizeof(unsigned long long))) {
|
||||
return ret;
|
||||
} else {
|
||||
uint8_t *data_token = const_cast<uint8_t *>(data);
|
||||
ret = AccessTokenidGrpTestOther(data_token);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
OHOS::AccessTokenidGrpTestOtherFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
# Copyright (c) 2020-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<fuzz_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
||||
@@ -0,0 +1,43 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/config/features.gni")
|
||||
import("//build/test.gni")
|
||||
|
||||
module_output_path = "linuxkerneltest/accesstokenid"
|
||||
|
||||
ohos_fuzztest("AccessTokenidThreadTestFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/accesstokenidthreadtest_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
"-pthread",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"../src/accesstokenidcommon.cpp",
|
||||
"accesstokenidthreadtest_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":AccessTokenidThreadTestFuzzTest" ]
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include "accesstokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::Kernel::AccessToken;
|
||||
namespace OHOS {
|
||||
bool AccessTokenidThreadTestFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
bool ret = false;
|
||||
if ((data == nullptr) || (size < sizeof(unsigned long long))) {
|
||||
return ret;
|
||||
} else {
|
||||
uint8_t *data_token = const_cast<uint8_t *>(data);
|
||||
ret = AccessTokenidThreadTest(data_token);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
OHOS::AccessTokenidThreadTestFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
# Copyright (c) 2020-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<fuzz_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
||||
@@ -30,7 +30,7 @@ ohos_fuzztest("GetfTokenidCmdCorrectFuzzTest") {
|
||||
]
|
||||
|
||||
sources = [
|
||||
"../src/accesstokenidcmdcorrect.cpp",
|
||||
"../src/accessftokenidcommon.cpp",
|
||||
"getftokenidcmdcorrect_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
+2
-3
@@ -14,11 +14,10 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include "accesstokenidcmdcorrect.h"
|
||||
#include "getftokenidcmdcorrect_fuzzer.h"
|
||||
#include "accessftokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::Security::AccessToken;
|
||||
using namespace OHOS::Kernel::AccessToken;
|
||||
namespace OHOS {
|
||||
bool GetfTokenidCmdCorrectFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ ohos_fuzztest("GetfTokenidCmdErrorFuzzTest") {
|
||||
]
|
||||
|
||||
sources = [
|
||||
"../src/accesstokenidcmderror.cpp",
|
||||
"../src/accessftokenidcommon.cpp",
|
||||
"getftokenidcmderror_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
+3
-3
@@ -14,11 +14,11 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include "accesstokenidcmderror.h"
|
||||
#include "getftokenidcmderror_fuzzer.h"
|
||||
#define CMDERROR
|
||||
#include "accessftokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::Security::AccessToken;
|
||||
using namespace OHOS::Kernel::AccessToken;
|
||||
namespace OHOS {
|
||||
bool GetfTokenidCmdCorrectFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/config/features.gni")
|
||||
import("//build/test.gni")
|
||||
|
||||
module_output_path = "linuxkerneltest/accesstokenid"
|
||||
|
||||
ohos_fuzztest("GetfTokenidNullptrFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/getftokenidnullptr_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"../src/accessftokenidcommon.cpp",
|
||||
"getftokenidnullptr_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":GetfTokenidNullptrFuzzTest" ]
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
# Copyright (c) 2020-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
reinterpret_cast
|
||||
static_cast
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include "accessftokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::Kernel::AccessToken;
|
||||
namespace OHOS {
|
||||
bool GetfTokenidNullptrFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
bool ret = false;
|
||||
if (data == nullptr) {
|
||||
unsigned long long tokenId = *(reinterpret_cast<const unsigned long long *>(data));
|
||||
ret = GetfTokenid(&tokenId);
|
||||
} else {
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
OHOS::GetfTokenidNullptrFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<fuzz_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
||||
@@ -30,7 +30,7 @@ ohos_fuzztest("GetTokenidCmdCorrectFuzzTest") {
|
||||
]
|
||||
|
||||
sources = [
|
||||
"../src/accesstokenidcmdcorrect.cpp",
|
||||
"../src/accesstokenidcommon.cpp",
|
||||
"gettokenidcmdcorrect_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
+2
-3
@@ -16,11 +16,10 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include "accesstokenidcmdcorrect.h"
|
||||
#include "gettokenidcmdcorrect_fuzzer.h"
|
||||
#include "accesstokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::Security::AccessToken;
|
||||
using namespace OHOS::Kernel::AccessToken;
|
||||
namespace OHOS {
|
||||
bool GetTokenidCmdCorrectFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ ohos_fuzztest("GetTokenidCmdErrorFuzzTest") {
|
||||
]
|
||||
|
||||
sources = [
|
||||
"../src/accesstokenidcmderror.cpp",
|
||||
"../src/accesstokenidcommon.cpp",
|
||||
"gettokenidcmderror_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include "accesstokenidcmderror.h"
|
||||
#include "gettokenidcmderror_fuzzer.h"
|
||||
#define CMDERROR
|
||||
#include "accesstokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::Security::AccessToken;
|
||||
using namespace OHOS::Kernel::AccessToken;
|
||||
namespace OHOS {
|
||||
bool GetTokenidCmdErrorFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/config/features.gni")
|
||||
import("//build/test.gni")
|
||||
|
||||
module_output_path = "linuxkerneltest/accesstokenid"
|
||||
|
||||
ohos_fuzztest("GetTokenidNullptrFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/gettokenidnullptr_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"../src/accesstokenidcommon.cpp",
|
||||
"gettokenidnullptr_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":GetTokenidNullptrFuzzTest" ]
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
# Copyright (c) 2020-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
reinterpret_cast
|
||||
static_cast
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include "accesstokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::Kernel::AccessToken;
|
||||
namespace OHOS {
|
||||
bool GetTokenidNullptrFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
bool ret = false;
|
||||
if (data == nullptr) {
|
||||
unsigned long long tokenId = *(reinterpret_cast<const unsigned long long *>(data));
|
||||
ret = GetTokenid(&tokenId);
|
||||
} else {
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
OHOS::GetTokenidNullptrFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<fuzz_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ACCESSFTOKENIDCOMMON_H
|
||||
#define ACCESSFTOKENIDCOMMON_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "accessftokenidcommon"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Kernel {
|
||||
namespace AccessToken {
|
||||
#define ACCESS_TOKEN_ID_IOCTL_BASE 'A'
|
||||
|
||||
#ifdef CMDERROR
|
||||
constexpr unsigned int GET_FTOKEN_ID = 0;
|
||||
constexpr unsigned int SET_FTOKEN_ID = 0;
|
||||
#else
|
||||
constexpr unsigned int GET_FTOKEN_ID = 3;
|
||||
constexpr unsigned int SET_FTOKEN_ID = 4;
|
||||
#endif
|
||||
|
||||
#define ACCESS_TOKENID_GET_FTOKENID \
|
||||
_IOR(ACCESS_TOKEN_ID_IOCTL_BASE, GET_FTOKEN_ID, unsigned long long)
|
||||
#define ACCESS_TOKENID_SET_FTOKENID \
|
||||
_IOW(ACCESS_TOKEN_ID_IOCTL_BASE, SET_FTOKEN_ID, unsigned long long)
|
||||
|
||||
#define LIST_NUM_1 1
|
||||
#define LIST_NUM_2 2
|
||||
#define TEST_VALUE 123
|
||||
#define CHILDREN_NUM 3
|
||||
#define WAIT_FOR_SHELL_OP_TIME 1
|
||||
#define FATHER_WAIT_TIME (WAIT_FOR_SHELL_OP_TIME * (CHILDREN_NUM + 1))
|
||||
|
||||
#define ACCESS_TOKEN_UID 3020
|
||||
#define ACCESS_TOKEN_GRPID 3020
|
||||
|
||||
#define ACCESS_TOKEN_OTHER_UID 1234
|
||||
#define ACCESS_TOKEN_OTHER_GRPID 1234
|
||||
|
||||
#define INVAL_TOKEN 0xffffffffffffffff
|
||||
|
||||
int GetfTokenid(unsigned long long *ftoken);
|
||||
int SetfTokenid(unsigned long long *ftoken);
|
||||
|
||||
void SetUidAndGrp();
|
||||
void SetUidAndGrpOther();
|
||||
void GetCurfToken(unsigned long long *ftoken);
|
||||
void SetRandfTokenAndCheck(unsigned long long *data_ftoken);
|
||||
void fTokenTest(unsigned long long *data_ftoken);
|
||||
void ThreadTest(unsigned long long *data_ftoken);
|
||||
int AccessfTokenidThreadTest(uint8_t *data_ftoken);
|
||||
int AccessfTokenidGrpTest(uint8_t *data_ftoken);
|
||||
int AccessfTokenidGrpTestOther(uint8_t *data_ftoken);
|
||||
} // namespace AccessToken
|
||||
} // namespace Kernel
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // ACCESSTOKENIDCOMMON_H
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef TEST_FUZZTEST_ACCESSTOKENIDCMDCORRECT_FUZZER_H
|
||||
#define TEST_FUZZTEST_ACCESSTOKENIDCMDCORRECT_FUZZER_H
|
||||
|
||||
namespace OHOS {
|
||||
namespace Security {
|
||||
namespace AccessToken {
|
||||
constexpr unsigned char ACCESS_TOKEN_ID_IOCTL_BASE = 'A';
|
||||
constexpr unsigned int GET_TOKEN_ID = 1;
|
||||
constexpr unsigned int SET_TOKEN_ID = 2;
|
||||
constexpr unsigned int GET_FTOKEN_ID = 3;
|
||||
constexpr unsigned int SET_FTOKEN_ID = 4;
|
||||
|
||||
#define ACCESS_TOKENID_GET_TOKENID \
|
||||
_IOR(ACCESS_TOKEN_ID_IOCTL_BASE, GET_TOKEN_ID, unsigned long long)
|
||||
#define ACCESS_TOKENID_SET_TOKENID \
|
||||
_IOW(ACCESS_TOKEN_ID_IOCTL_BASE, SET_TOKEN_ID, unsigned long long)
|
||||
#define ACCESS_TOKENID_GET_FTOKENID \
|
||||
_IOR(ACCESS_TOKEN_ID_IOCTL_BASE, GET_FTOKEN_ID, unsigned long long)
|
||||
#define ACCESS_TOKENID_SET_FTOKENID \
|
||||
_IOW(ACCESS_TOKEN_ID_IOCTL_BASE, SET_FTOKEN_ID, unsigned long long)
|
||||
|
||||
int GetTokenid(unsigned long long *token);
|
||||
int SetTokenid(unsigned long long *token);
|
||||
int GetfTokenid(unsigned long long *ftoken);
|
||||
int SetfTokenid(unsigned long long *ftoken);
|
||||
} // namespace AccessToken
|
||||
} // namespace Security
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // TEST_FUZZTEST_ACCESSTOKENIDCMDCORRECT_FUZZER_H
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef TEST_FUZZTEST_ACCESSTOKENIDCMDERROR_FUZZER_H
|
||||
#define TEST_FUZZTEST_ACCESSTOKENIDCMDERROR_FUZZER_H
|
||||
|
||||
namespace OHOS {
|
||||
namespace Security {
|
||||
namespace AccessToken {
|
||||
constexpr unsigned char ACCESS_TOKEN_ID_IOCTL_BASE = 'A';
|
||||
constexpr unsigned int GET_TOKEN_ID = 0;
|
||||
constexpr unsigned int SET_TOKEN_ID = 0;
|
||||
constexpr unsigned int GET_FTOKEN_ID = 0;
|
||||
constexpr unsigned int SET_FTOKEN_ID = 0;
|
||||
|
||||
#define ACCESS_TOKENID_GET_TOKENID \
|
||||
_IOR(ACCESS_TOKEN_ID_IOCTL_BASE, GET_TOKEN_ID, unsigned long long)
|
||||
#define ACCESS_TOKENID_SET_TOKENID \
|
||||
_IOW(ACCESS_TOKEN_ID_IOCTL_BASE, SET_TOKEN_ID, unsigned long long)
|
||||
#define ACCESS_TOKENID_GET_FTOKENID \
|
||||
_IOR(ACCESS_TOKEN_ID_IOCTL_BASE, GET_FTOKEN_ID, unsigned long long)
|
||||
#define ACCESS_TOKENID_SET_FTOKENID \
|
||||
_IOW(ACCESS_TOKEN_ID_IOCTL_BASE, SET_FTOKEN_ID, unsigned long long)
|
||||
|
||||
int GetTokenid(unsigned long long *token);
|
||||
int SetTokenid(unsigned long long *token);
|
||||
int GetfTokenid(unsigned long long *ftoken);
|
||||
int SetfTokenid(unsigned long long *ftoken);
|
||||
} // namespace AccessToken
|
||||
} // namespace Security
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // TEST_FUZZTEST_ACCESSTOKENIDCMDERROR_FUZZER_H
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ACCESSTOKENIDCOMMON_H
|
||||
#define ACCESSTOKENIDCOMMON_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "accesstokenidcommon"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Kernel {
|
||||
namespace AccessToken {
|
||||
#define ACCESS_TOKEN_ID_IOCTL_BASE 'A'
|
||||
|
||||
#ifdef CMDERROR
|
||||
constexpr unsigned int GET_TOKEN_ID = 0;
|
||||
constexpr unsigned int SET_TOKEN_ID = 0;
|
||||
#else
|
||||
constexpr unsigned int GET_TOKEN_ID = 1;
|
||||
constexpr unsigned int SET_TOKEN_ID = 2;
|
||||
#endif
|
||||
|
||||
#define ACCESS_TOKENID_GET_TOKENID \
|
||||
_IOR(ACCESS_TOKEN_ID_IOCTL_BASE, GET_TOKEN_ID, unsigned long long)
|
||||
#define ACCESS_TOKENID_SET_TOKENID \
|
||||
_IOW(ACCESS_TOKEN_ID_IOCTL_BASE, SET_TOKEN_ID, unsigned long long)
|
||||
|
||||
#define LIST_NUM_1 1
|
||||
#define LIST_NUM_2 2
|
||||
#define TEST_VALUE 123
|
||||
#define CHILDREN_NUM 3
|
||||
#define WAIT_FOR_SHELL_OP_TIME 1
|
||||
#define FATHER_WAIT_TIME (WAIT_FOR_SHELL_OP_TIME * (CHILDREN_NUM + 1))
|
||||
|
||||
#define ACCESS_TOKEN_UID 3020
|
||||
#define ACCESS_TOKEN_GRPID 3020
|
||||
|
||||
#define ACCESS_TOKEN_OTHER_UID 1234
|
||||
#define ACCESS_TOKEN_OTHER_GRPID 1234
|
||||
|
||||
#define INVAL_TOKEN 0xffffffffffffffff
|
||||
|
||||
int GetTokenid(unsigned long long *token);
|
||||
int SetTokenid(unsigned long long *token);
|
||||
|
||||
void SetUidAndGrp();
|
||||
void SetUidAndGrpOther();
|
||||
void GetCurToken(unsigned long long *token);
|
||||
void SetRandTokenAndCheck(unsigned long long *data_token);
|
||||
void TokenTest(unsigned long long *data_token);
|
||||
void ThreadTest(unsigned long long *data_token);
|
||||
int AccessTokenidThreadTest(uint8_t *data_token);
|
||||
int AccessTokenidGrpTest(uint8_t *data_token);
|
||||
int AccessTokenidGrpTestOther(uint8_t *data_token);
|
||||
} // namespace AccessToken
|
||||
} // namespace Kernel
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // ACCESSTOKENIDCOMMON_H
|
||||
@@ -30,7 +30,7 @@ ohos_fuzztest("SetfTokenidCmdCorrectFuzzTest") {
|
||||
]
|
||||
|
||||
sources = [
|
||||
"../src/accesstokenidcmdcorrect.cpp",
|
||||
"../src/accessftokenidcommon.cpp",
|
||||
"setftokenidcmdcorrect_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
+2
-3
@@ -14,11 +14,10 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include "accesstokenidcmdcorrect.h"
|
||||
#include "setftokenidcmdcorrect_fuzzer.h"
|
||||
#include "accessftokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::Security::AccessToken;
|
||||
using namespace OHOS::Kernel::AccessToken;
|
||||
namespace OHOS {
|
||||
bool SetfTokenidCmdCorrectFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ ohos_fuzztest("SetfTokenidCmdErrorFuzzTest") {
|
||||
]
|
||||
|
||||
sources = [
|
||||
"../src/accesstokenidcmderror.cpp",
|
||||
"../src/accessftokenidcommon.cpp",
|
||||
"setftokenidcmderror_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
+3
-3
@@ -14,11 +14,11 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include "accesstokenidcmderror.h"
|
||||
#include "setftokenidcmderror_fuzzer.h"
|
||||
#define CMDERROR
|
||||
#include "accessftokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::Security::AccessToken;
|
||||
using namespace OHOS::Kernel::AccessToken;
|
||||
namespace OHOS {
|
||||
bool SetfTokenidCmdErrorFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/config/features.gni")
|
||||
import("//build/test.gni")
|
||||
|
||||
module_output_path = "linuxkerneltest/accesstokenid"
|
||||
|
||||
ohos_fuzztest("SetfTokenidNullptrFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/setftokenidnullptr_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"../src/accessftokenidcommon.cpp",
|
||||
"setftokenidnullptr_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":SetfTokenidNullptrFuzzTest" ]
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
# Copyright (c) 2020-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<fuzz_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
reinterpret_cast
|
||||
static_cast
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include "accessftokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::Kernel::AccessToken;
|
||||
namespace OHOS {
|
||||
bool SetfTokenidNullptrFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
bool ret = false;
|
||||
if (data == nullptr) {
|
||||
unsigned long long tokenId = *(reinterpret_cast<const unsigned long long *>(data));
|
||||
ret = SetfTokenid(&tokenId);
|
||||
} else {
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
OHOS::SetfTokenidNullptrFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
@@ -29,7 +29,7 @@ ohos_fuzztest("SetTokenidCmdCorrectFuzzTest") {
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [
|
||||
"../src/accesstokenidcmdcorrect.cpp",
|
||||
"../src/accesstokenidcommon.cpp",
|
||||
"settokenidcmdcorrect_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
+2
-3
@@ -16,11 +16,10 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include "accesstokenidcmdcorrect.h"
|
||||
#include "settokenidcmdcorrect_fuzzer.h"
|
||||
#include "accesstokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::Security::AccessToken;
|
||||
using namespace OHOS::Kernel::AccessToken;
|
||||
namespace OHOS {
|
||||
bool SetTokenidCmdCorrectFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ ohos_fuzztest("SetTokenidCmdErrorFuzzTest") {
|
||||
]
|
||||
|
||||
sources = [
|
||||
"../src/accesstokenidcmderror.cpp",
|
||||
"../src/accesstokenidcommon.cpp",
|
||||
"settokenidcmderror_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include "accesstokenidcmderror.h"
|
||||
#include "settokenidcmderror_fuzzer.h"
|
||||
#define CMDERROR
|
||||
#include "accesstokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::Security::AccessToken;
|
||||
using namespace OHOS::Kernel::AccessToken;
|
||||
namespace OHOS {
|
||||
bool SetTokenidCmdErrorFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/config/features.gni")
|
||||
import("//build/test.gni")
|
||||
|
||||
module_output_path = "linuxkerneltest/accesstokenid"
|
||||
|
||||
ohos_fuzztest("SetTokenidNullptrFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/settokenidnullptr_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"../src/accesstokenidcommon.cpp",
|
||||
"settokenidnullptr_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":SetTokenidNullptrFuzzTest" ]
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
# Copyright (c) 2020-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<fuzz_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
reinterpret_cast
|
||||
static_cast
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include "accesstokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::Kernel::AccessToken;
|
||||
namespace OHOS {
|
||||
bool SetTokenidNullptrFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
bool ret = false;
|
||||
if (data == nullptr) {
|
||||
unsigned long long tokenId = *(reinterpret_cast<const unsigned long long *>(data));
|
||||
ret = SetTokenid(&tokenId);
|
||||
} else {
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
OHOS::SetTokenidNullptrFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/wait.h>
|
||||
#include <ctime>
|
||||
#include <fcntl.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <vector>
|
||||
#include "accessftokenidcommon.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Kernel {
|
||||
namespace AccessToken {
|
||||
const char *DEVACCESSTOKENID = "/dev/access_token_id";
|
||||
|
||||
int GetfTokenid(unsigned long long *ftoken)
|
||||
{
|
||||
int fd = open(DEVACCESSTOKENID, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = ioctl(fd, ACCESS_TOKENID_GET_FTOKENID, ftoken);
|
||||
if (ret) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetfTokenid(unsigned long long *ftoken)
|
||||
{
|
||||
int fd = open(DEVACCESSTOKENID, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = ioctl(fd, ACCESS_TOKENID_SET_FTOKENID, ftoken);
|
||||
if (ret) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SetUidAndGrp()
|
||||
{
|
||||
int ret = 0;
|
||||
size_t groupListSize = LIST_NUM_2;
|
||||
gid_t groupList[LIST_NUM_2] = {ACCESS_TOKEN_GRPID, TEST_VALUE};
|
||||
|
||||
ret = setgroups(groupListSize, groupList);
|
||||
if (ret != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
ret = setuid(ACCESS_TOKEN_UID);
|
||||
if (ret != 0) {
|
||||
printf("SetUidAndGrp setuid error %d \n", ret);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void SetUidAndGrpOther()
|
||||
{
|
||||
int ret = 0;
|
||||
size_t groupListSize = LIST_NUM_1;
|
||||
gid_t groupList[LIST_NUM_1] = {ACCESS_TOKEN_OTHER_GRPID};
|
||||
|
||||
ret = setgroups(groupListSize, groupList);
|
||||
if (ret != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
ret = setuid(ACCESS_TOKEN_OTHER_UID);
|
||||
if (ret != 0) {
|
||||
printf("SetUidAndGrp setuid error %d \r\n", ret);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void SetRandfTokenAndCheck(unsigned long long *data_ftoken)
|
||||
{
|
||||
pid_t pid = getpid();
|
||||
pid_t tid = syscall(__NR_gettid);
|
||||
unsigned long long ftoken = INVAL_TOKEN;
|
||||
unsigned long long ftokenSet = *data_ftoken;
|
||||
|
||||
SetfTokenid(&ftokenSet);
|
||||
GetfTokenid(&ftoken);
|
||||
|
||||
if (ftoken != ftokenSet) {
|
||||
printf("pid:%d tid:%d ftoken test failed, ftoken:%llu ftokenSet:%llu\n",
|
||||
pid, tid, ftoken, ftokenSet);
|
||||
} else {
|
||||
printf("pid:%d tid:%d ftoken test succeed, ftoken:%llu ftokenSet:%llu\n",
|
||||
pid, tid, ftoken, ftokenSet);
|
||||
}
|
||||
|
||||
sleep(WAIT_FOR_SHELL_OP_TIME);
|
||||
|
||||
GetfTokenid(&ftoken);
|
||||
if (ftoken != ftokenSet) {
|
||||
printf("pid:%d tid:%d ftoken test failed, ftoken:%llu ftokenSet:%llu\n",
|
||||
pid, tid, ftoken, ftokenSet);
|
||||
} else {
|
||||
printf("pid:%d tid:%d ftoken test succeed, ftoken:%llu ftokenSet:%llu\n",
|
||||
pid, tid, ftoken, ftokenSet);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void *fTokenTest(void *data_ftoken)
|
||||
{
|
||||
SetRandfTokenAndCheck(static_cast<unsigned long long *>(data_ftoken));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ThreadTest(void *data_ftoken)
|
||||
{
|
||||
pthread_t id_1;
|
||||
pthread_t id_2;
|
||||
pthread_t id_3;
|
||||
int ret = 0;
|
||||
|
||||
ret = pthread_create(&id_1, nullptr, fTokenTest, data_ftoken);
|
||||
if (ret != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
ret = pthread_create(&id_2, nullptr, fTokenTest, data_ftoken);
|
||||
if (ret != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
ret = pthread_create(&id_3, nullptr, fTokenTest, data_ftoken);
|
||||
if (ret != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
pthread_join(id_1, nullptr);
|
||||
pthread_join(id_2, nullptr);
|
||||
pthread_join(id_3, nullptr);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int AccessfTokenidThreadTest(uint8_t *data_ftoken)
|
||||
{
|
||||
fTokenTest(static_cast<void *>(data_ftoken));
|
||||
ThreadTest(static_cast<void *>(data_ftoken));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AccessfTokenidGrpTest(uint8_t *data_ftoken)
|
||||
{
|
||||
SetUidAndGrp();
|
||||
fTokenTest(static_cast<void *>(data_ftoken));
|
||||
ThreadTest(static_cast<void *>(data_ftoken));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AccessfTokenidGrpTestOther(uint8_t *data_ftoken)
|
||||
{
|
||||
SetUidAndGrpOther();
|
||||
fTokenTest(static_cast<void *>(data_ftoken));
|
||||
ThreadTest(static_cast<void *>(data_ftoken));
|
||||
return 0;
|
||||
}
|
||||
} // namespace AccessToken
|
||||
} // namespace Kernel
|
||||
} // namespace OHOS
|
||||
@@ -1,106 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <fcntl.h>
|
||||
#include <cerrno>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <ctime>
|
||||
#include <climits>
|
||||
#include <pthread.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <grp.h>
|
||||
#include "accesstokenidcmdcorrect.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Security {
|
||||
namespace AccessToken {
|
||||
const char *DEVACCESSTOKENID = "/dev/access_token_id";
|
||||
|
||||
int GetTokenid(unsigned long long *token)
|
||||
{
|
||||
int fd = open(DEVACCESSTOKENID, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = ioctl(fd, ACCESS_TOKENID_GET_TOKENID, token);
|
||||
if (ret) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetTokenid(unsigned long long *token)
|
||||
{
|
||||
int fd = open(DEVACCESSTOKENID, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = ioctl(fd, ACCESS_TOKENID_SET_TOKENID, token);
|
||||
if (ret) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GetfTokenid(unsigned long long *ftoken)
|
||||
{
|
||||
int fd = open(DEVACCESSTOKENID, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = ioctl(fd, ACCESS_TOKENID_GET_FTOKENID, ftoken);
|
||||
if (ret) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetfTokenid(unsigned long long *ftoken)
|
||||
{
|
||||
int fd = open(DEVACCESSTOKENID, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = ioctl(fd, ACCESS_TOKENID_SET_FTOKENID, ftoken);
|
||||
if (ret) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
} // namespace AccessToken
|
||||
} // namespace Security
|
||||
} // namespace OHOS
|
||||
@@ -1,106 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <fcntl.h>
|
||||
#include <cerrno>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <ctime>
|
||||
#include <climits>
|
||||
#include <pthread.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <grp.h>
|
||||
#include "accesstokenidcmderror.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Security {
|
||||
namespace AccessToken {
|
||||
const char *DEVACCESSTOKENID = "/dev/access_token_id";
|
||||
|
||||
int GetTokenid(unsigned long long *token)
|
||||
{
|
||||
int fd = open(DEVACCESSTOKENID, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = ioctl(fd, ACCESS_TOKENID_GET_TOKENID, token);
|
||||
if (ret) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetTokenid(unsigned long long *token)
|
||||
{
|
||||
int fd = open(DEVACCESSTOKENID, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = ioctl(fd, ACCESS_TOKENID_SET_TOKENID, token);
|
||||
if (ret) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GetfTokenid(unsigned long long *ftoken)
|
||||
{
|
||||
int fd = open(DEVACCESSTOKENID, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = ioctl(fd, ACCESS_TOKENID_GET_FTOKENID, ftoken);
|
||||
if (ret) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetfTokenid(unsigned long long *ftoken)
|
||||
{
|
||||
int fd = open(DEVACCESSTOKENID, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = ioctl(fd, ACCESS_TOKENID_SET_FTOKENID, ftoken);
|
||||
if (ret) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
} // namespace AccessToken
|
||||
} // namespace Security
|
||||
} // namespace OHOS
|
||||
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/wait.h>
|
||||
#include <ctime>
|
||||
#include <fcntl.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <vector>
|
||||
#include "accesstokenidcommon.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Kernel {
|
||||
namespace AccessToken {
|
||||
const char *DEVACCESSTOKENID = "/dev/access_token_id";
|
||||
|
||||
int GetTokenid(unsigned long long *token)
|
||||
{
|
||||
int fd = open(DEVACCESSTOKENID, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
int ret = ioctl(fd, ACCESS_TOKENID_GET_TOKENID, token);
|
||||
if (ret) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetTokenid(unsigned long long *token)
|
||||
{
|
||||
int fd = open(DEVACCESSTOKENID, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
int ret = ioctl(fd, ACCESS_TOKENID_SET_TOKENID, token);
|
||||
if (ret) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SetUidAndGrp()
|
||||
{
|
||||
int ret = 0;
|
||||
size_t groupListSize = LIST_NUM_2;
|
||||
gid_t groupList[LIST_NUM_2] = {ACCESS_TOKEN_GRPID, TEST_VALUE};
|
||||
|
||||
ret = setgroups(groupListSize, groupList);
|
||||
if (ret != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
ret = setuid(ACCESS_TOKEN_UID);
|
||||
if (ret != 0) {
|
||||
printf("SetUidAndGrp setuid error %d \n", ret);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void SetUidAndGrpOther()
|
||||
{
|
||||
int ret = 0;
|
||||
size_t groupListSize = LIST_NUM_1;
|
||||
gid_t groupList[LIST_NUM_1] = {ACCESS_TOKEN_OTHER_GRPID};
|
||||
|
||||
ret = setgroups(groupListSize, groupList);
|
||||
if (ret != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
ret = setuid(ACCESS_TOKEN_OTHER_UID);
|
||||
if (ret != 0) {
|
||||
printf("SetUidAndGrp setuid error %d \n", ret);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void SetRandTokenAndCheck(unsigned long long *data_token)
|
||||
{
|
||||
pid_t pid = getpid();
|
||||
pid_t tid = syscall(__NR_gettid);
|
||||
unsigned long long token = INVAL_TOKEN;
|
||||
unsigned long long tokenSet = *data_token;
|
||||
|
||||
SetTokenid(&tokenSet);
|
||||
GetTokenid(&token);
|
||||
|
||||
if (token != tokenSet) {
|
||||
printf("pid:%d tid:%d token test failed, token:%llu tokenSet:%llu\n",
|
||||
pid, tid, token, tokenSet);
|
||||
} else {
|
||||
printf("pid:%d tid:%d token test succeed, token:%llu tokenSet:%llu\n",
|
||||
pid, tid, token, tokenSet);
|
||||
}
|
||||
|
||||
sleep(WAIT_FOR_SHELL_OP_TIME);
|
||||
|
||||
GetTokenid(&token);
|
||||
if (token != tokenSet) {
|
||||
printf("pid:%d tid:%d token test failed, token:%llu tokenSet:%llu\n",
|
||||
pid, tid, token, tokenSet);
|
||||
} else {
|
||||
printf("pid:%d tid:%d token test succeed, token:%llu tokenSet:%llu\n",
|
||||
pid, tid, token, tokenSet);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void *TokenTest(void *data_token)
|
||||
{
|
||||
SetRandTokenAndCheck(static_cast<unsigned long long *>(data_token));
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ThreadTest(void *data_token)
|
||||
{
|
||||
pthread_t id_1;
|
||||
pthread_t id_2;
|
||||
pthread_t id_3;
|
||||
int ret = 0;
|
||||
|
||||
ret = pthread_create(&id_1, nullptr, TokenTest, data_token);
|
||||
if (ret != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
ret = pthread_create(&id_2, nullptr, TokenTest, data_token);
|
||||
if (ret != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
ret = pthread_create(&id_3, nullptr, TokenTest, data_token);
|
||||
if (ret != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
pthread_join(id_1, nullptr);
|
||||
pthread_join(id_2, nullptr);
|
||||
pthread_join(id_3, nullptr);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int AccessTokenidThreadTest(uint8_t *data_token)
|
||||
{
|
||||
TokenTest(static_cast<void *>(data_token));
|
||||
ThreadTest(static_cast<void *>(data_token));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AccessTokenidGrpTest(uint8_t *data_token)
|
||||
{
|
||||
SetUidAndGrp();
|
||||
TokenTest(static_cast<void *>(data_token));
|
||||
ThreadTest(static_cast<void *>(data_token));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AccessTokenidGrpTestOther(uint8_t *data_token)
|
||||
{
|
||||
SetUidAndGrpOther();
|
||||
TokenTest(static_cast<void *>(data_token));
|
||||
ThreadTest(static_cast<void *>(data_token));
|
||||
return 0;
|
||||
}
|
||||
} // namespace AccessToken
|
||||
} // namespace Kernel
|
||||
} // namespace OHOS
|
||||
Reference in New Issue
Block a user