GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: 调整目录结构,兼容Pro版(模块版) · Corner514/SKRoot-linuxKernelRoot@2e5e233

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • patch_kernel_root
    • 3rdparty
      • aarch64_asm_helper.h
    • analyze
      • kernel_symbol_parser.cpp
      • kernel_symbol_parser.h
      • kernel_version_parser.cpp
      • kernel_version_parser.h
      • symbol_analyze.cpp
      • symbol_analyze.h
    • patch_avc_denied.cpp
    • patch_avc_denied.h
    • patch_base.cpp
    • patch_base.h
    • patch_do_execve.cpp
    • patch_do_execve.h
    • patch_filldir64.cpp
    • patch_filldir64.h
    • patch_freeze_task.cpp
    • patch_freeze_task.h
    • patch_kernel_root.cpp
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎patch_kernel_root/3rdparty/aarch64_asm_helper.h‎

Copy file name to clipboardExpand all lines: patch_kernel_root/3rdparty/aarch64_asm_helper.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static std::pair<std::shared_ptr<char>, size_t> aarch64_asm_to_bytes(const aarch
5151
size_t data_size = buf.size();
5252
std::shared_ptr<char> data_container(new (std::nothrow) char[data_size], std::default_delete<char[]>());
5353
memcpy(data_container.get(), data, data_size);
54-
return { data_container, data_size};
54+
return { data_container, data_size };
5555
}
5656

5757

Collapse file

‎patch_kernel_root/analyze/kernel_symbol_parser.cpp‎

Copy file name to clipboardExpand all lines: patch_kernel_root/analyze/kernel_symbol_parser.cpp
+5-13Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,30 @@ KernelSymbolParser::~KernelSymbolParser()
2121

2222
bool KernelSymbolParser::init_kallsyms_lookup_name() {
2323

24-
std::string current_version = m_kernel_ver_parser.find_kernel_versions();
24+
std::string current_version = m_kernel_ver_parser.get_kernel_version();
2525
if (current_version.empty()) {
2626
std::cout << "Failed to read Linux kernel version" << std::endl;
2727
return false;
2828
}
2929
std::cout << "Find the current Linux kernel version: " << current_version << std::endl;
3030
std::cout << std::endl;
3131

32-
if (m_kernel_ver_parser.is_version_less(current_version, "4.6.0")) {
32+
if (m_kernel_ver_parser.is_kernel_version_less("4.6.0")) {
3333
if (!m_kallsyms_lookup_name.init()) {
3434
std::cout << "Failed to analyze kernel kallsyms lookup name information" << std::endl;
3535
return false;
3636
}
37-
} else if (m_kernel_ver_parser.is_version_less(current_version, "6.1.42")) {
37+
} else if (m_kernel_ver_parser.is_kernel_version_less("6.1.42")) {
3838
if (!m_kallsyms_lookup_name_4_6_0.init()) {
3939
std::cout << "Failed to analyze kernel kallsyms lookup name information" << std::endl;
4040
return false;
4141
}
42-
} else if (m_kernel_ver_parser.is_version_less(current_version, "6.1.60")) {
42+
} else if (m_kernel_ver_parser.is_kernel_version_less("6.1.60")) {
4343
if (!m_kallsyms_lookup_name_6_1_42.init()) {
4444
std::cout << "Failed to analyze kernel kallsyms lookup name information" << std::endl;
4545
return false;
4646
}
47-
} else if (m_kernel_ver_parser.is_version_less(current_version, "6.6.30")) {
47+
} else if (m_kernel_ver_parser.is_kernel_version_less("6.6.30")) {
4848
if (!m_kallsyms_lookup_name_6_1_60.init()) {
4949
std::cout << "Failed to analyze kernel kallsyms lookup name information" << std::endl;
5050
return false;
@@ -94,11 +94,3 @@ std::unordered_map<std::string, uint64_t> KernelSymbolParser::kallsyms_lookup_na
9494
}
9595
return result;
9696
}
97-
98-
bool KernelSymbolParser::is_kernel_version_less(const std::string& ver) const {
99-
std::string current_version = m_kernel_ver_parser.find_kernel_versions();
100-
if (!current_version.empty()) {
101-
return m_kernel_ver_parser.is_version_less(current_version, ver);
102-
}
103-
return false;
104-
}
Collapse file

‎patch_kernel_root/analyze/kernel_symbol_parser.h‎

Copy file name to clipboardExpand all lines: patch_kernel_root/analyze/kernel_symbol_parser.h
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ class KernelSymbolParser
1717
bool init_kallsyms_lookup_name();
1818
uint64_t kallsyms_lookup_name(const char* name);
1919
std::unordered_map<std::string, uint64_t> kallsyms_lookup_names_like(const char* name);
20-
bool is_kernel_version_less(const std::string& ver) const;
2120
private:
2221
const std::vector<char>& m_file_buf;
2322
KernelVersionParser m_kernel_ver_parser;
Collapse file

‎patch_kernel_root/analyze/kernel_version_parser.cpp‎

Copy file name to clipboardExpand all lines: patch_kernel_root/analyze/kernel_version_parser.cpp
+13-4Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,21 @@
66
#define MIN(x, y)(x < y) ? (x) : (y)
77
#endif // !MIN
88

9-
KernelVersionParser::KernelVersionParser(const std::vector<char>& file_buf) : m_file_buf(file_buf)
10-
{
9+
KernelVersionParser::KernelVersionParser(const std::vector<char>& file_buf) : m_file_buf(file_buf) {
10+
m_ver = find_kernel_versions();
1111
}
1212

13-
KernelVersionParser::~KernelVersionParser()
14-
{
13+
KernelVersionParser::~KernelVersionParser() {}
14+
15+
std::string KernelVersionParser::get_kernel_version() const {
16+
return m_ver;
17+
}
18+
19+
bool KernelVersionParser::is_kernel_version_less(const std::string& ver) const {
20+
if (!m_ver.empty()) {
21+
return is_version_less(m_ver, ver);
22+
}
23+
return false;
1524
}
1625

1726
// Helper function to extract and print the version number starting from the given index
Collapse file

‎patch_kernel_root/analyze/kernel_version_parser.h‎

Copy file name to clipboardExpand all lines: patch_kernel_root/analyze/kernel_version_parser.h
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@ class KernelVersionParser
88
~KernelVersionParser();
99

1010
public:
11-
std::string find_kernel_versions() const;
12-
bool is_version_less(const std::string& v1, const std::string& v2) const;
11+
std::string get_kernel_version() const;
12+
bool is_kernel_version_less(const std::string& ver) const;
1313
private:
14+
std::string find_kernel_versions() const;
1415
std::string extract_version(const std::vector<char>& buffer, size_t start_index) const;
16+
bool is_version_less(const std::string& v1, const std::string& v2) const;
1517
std::vector<int> parse_version(const std::string& version) const;
18+
1619
const std::vector<char>& m_file_buf;
20+
std::string m_ver;
1721
};
Collapse file

‎patch_kernel_root/analyze/symbol_analyze.cpp‎

Copy file name to clipboardExpand all lines: patch_kernel_root/analyze/symbol_analyze.cpp
-4Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ KernelSymbolOffset SymbolAnalyze::get_symbol_offset() {
2424
return m_kernel_sym_offset;
2525
}
2626

27-
bool SymbolAnalyze::is_kernel_version_less(const std::string& ver) const {
28-
return m_kernel_sym_parser.is_kernel_version_less(ver);
29-
}
30-
3127
bool SymbolAnalyze::find_symbol_offset() {
3228
m_kernel_sym_offset._text = kallsyms_matching_single("_text");
3329
m_kernel_sym_offset._stext = kallsyms_matching_single("_stext");
Collapse file

‎patch_kernel_root/analyze/symbol_analyze.h‎

Copy file name to clipboardExpand all lines: patch_kernel_root/analyze/symbol_analyze.h
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ class SymbolAnalyze
5555
public:
5656
bool analyze_kernel_symbol();
5757
KernelSymbolOffset get_symbol_offset();
58-
bool is_kernel_version_less(const std::string& ver) const;
5958
private:
6059
bool find_symbol_offset();
6160
uint64_t kallsyms_matching_single(const char* name, bool fuzzy = false);
Collapse file

‎patch_kernel_root/patch_avc_denied.cpp‎

Copy file name to clipboardExpand all lines: patch_kernel_root/patch_avc_denied.cpp
+4-9Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,10 @@ using namespace asmjit;
55
using namespace asmjit::a64;
66
using namespace asmjit::a64::Predicate;
77

8-
PatchAvcDenied::PatchAvcDenied(const std::vector<char>& file_buf, const KernelSymbolOffset& sym,
9-
const SymbolAnalyze& symbol_analyze) : PatchBase(file_buf, sym, symbol_analyze) {
8+
PatchAvcDenied::PatchAvcDenied(const std::vector<char>& file_buf, const SymbolRegion& avc_denied)
9+
: PatchBase(file_buf), m_avc_denied(avc_denied) {}
1010

11-
}
12-
13-
PatchAvcDenied::~PatchAvcDenied()
14-
{
15-
}
11+
PatchAvcDenied::~PatchAvcDenied() {}
1612

1713
int PatchAvcDenied::get_need_read_cap_cnt() {
1814
int cnt = get_cap_cnt();
@@ -27,8 +23,7 @@ size_t PatchAvcDenied::patch_avc_denied_first_guide(const SymbolRegion& hook_fun
2723
size_t hook_func_start_addr = hook_func_start_region.offset;
2824
if (hook_func_start_addr == 0) { return 0; }
2925
std::cout << "Start hooking addr: " << std::hex << hook_func_start_addr << std::endl << std::endl;
30-
size_t avc_denied_addr = m_sym.avc_denied.offset + m_sym.avc_denied.size - 4;
31-
26+
size_t avc_denied_addr = m_avc_denied.offset + m_avc_denied.size - 4;
3227

3328
aarch64_asm_info asm_info = init_aarch64_asm();
3429
auto& a = asm_info.a;
Collapse file

‎patch_kernel_root/patch_avc_denied.h‎

Copy file name to clipboardExpand all lines: patch_kernel_root/patch_avc_denied.h
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
class PatchAvcDenied : public PatchBase
66
{
77
public:
8-
PatchAvcDenied(const std::vector<char>& file_buf, const KernelSymbolOffset& sym,
9-
const SymbolAnalyze& analyze_kernel);
8+
PatchAvcDenied(const std::vector<char>& file_buf, const SymbolRegion &avc_denied);
109
~PatchAvcDenied();
1110

1211
size_t patch_avc_denied_first_guide(const SymbolRegion& hook_func_start_region, const std::vector<size_t>& task_struct_offset_cred,
@@ -17,4 +16,5 @@ class PatchAvcDenied : public PatchBase
1716
size_t patch_avc_denied_end_guide(const SymbolRegion& hook_func_start_region, std::vector<patch_bytes_data>& vec_out_patch_bytes_data);
1817
private:
1918
int get_need_read_cap_cnt();
19+
SymbolRegion m_avc_denied = {0};
2020
};
Collapse file

‎patch_kernel_root/patch_base.cpp‎

Copy file name to clipboardExpand all lines: patch_kernel_root/patch_base.cpp
+6-11Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,13 @@ using namespace asmjit;
55
using namespace asmjit::a64;
66
using namespace asmjit::a64::Predicate;
77

8-
PatchBase::PatchBase(const std::vector<char>& file_buf, const KernelSymbolOffset& sym,
9-
const SymbolAnalyze& symbol_analyze) : m_file_buf(file_buf), m_sym(sym), m_symbol_analyze(symbol_analyze) {
8+
PatchBase::PatchBase(const std::vector<char>& file_buf) : m_file_buf(file_buf), m_kernel_ver_parser(file_buf) {}
109

11-
}
12-
13-
PatchBase::~PatchBase()
14-
{
15-
}
10+
PatchBase::~PatchBase() {}
1611

1712
int PatchBase::get_cred_atomic_usage_len() {
1813
int len = 8;
19-
if (m_symbol_analyze.is_kernel_version_less("6.6.0")) {
14+
if (m_kernel_ver_parser.is_kernel_version_less("6.6.0")) {
2015
len = 4;
2116
}
2217
return len;
@@ -31,10 +26,10 @@ int PatchBase::get_cred_securebits_padding() {
3126

3227
uint64_t PatchBase::get_cap_ability_max() {
3328
uint64_t cap = 0x3FFFFFFFFF;
34-
if (m_symbol_analyze.is_kernel_version_less("5.8.0")) {
29+
if (m_kernel_ver_parser.is_kernel_version_less("5.8.0")) {
3530
cap = 0x3FFFFFFFFF;
3631
}
37-
else if (m_symbol_analyze.is_kernel_version_less("5.9.0")) {
32+
else if (m_kernel_ver_parser.is_kernel_version_less("5.9.0")) {
3833
cap = 0xFFFFFFFFFF;
3934
}
4035
else {
@@ -45,7 +40,7 @@ uint64_t PatchBase::get_cap_ability_max() {
4540

4641
int PatchBase::get_cap_cnt() {
4742
int cnt = 0;
48-
if (m_symbol_analyze.is_kernel_version_less("4.3.0")) {
43+
if (m_kernel_ver_parser.is_kernel_version_less("4.3.0")) {
4944
cnt = 4;
5045
} else {
5146
cnt = 5;

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.