{"id":23934031,"url":"https://github.com/JiaHuann/Smart_Fault_Injector_LLM","last_synced_at":"2025-09-11T16:33:35.683Z","repository":{"id":263386345,"uuid":"883793408","full_name":"JiaHuann/Smart_Fault_Injector_LLM","owner":"JiaHuann","description":"Intelligent kernel error injection/testing tool based on large model and eBPF.(基于大模型和eBPF的智能化kernel错误注入、测试工具)","archived":false,"fork":false,"pushed_at":"2025-02-05T09:34:38.000Z","size":5507,"stargazers_count":24,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-11T14:14:06.663Z","etag":null,"topics":["ebpf","fault-injection","kernel","security-tools","testing-tools"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JiaHuann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-11-05T15:25:51.000Z","updated_at":"2025-03-28T06:13:00.000Z","dependencies_parsed_at":"2025-04-11T14:06:41.827Z","dependency_job_id":"61d3a321-ebf2-466f-b561-706939a49764","html_url":"https://github.com/JiaHuann/Smart_Fault_Injector_LLM","commit_stats":null,"previous_names":["jiahuann/smart_fault_injector_llm"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/JiaHuann/Smart_Fault_Injector_LLM","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JiaHuann%2FSmart_Fault_Injector_LLM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JiaHuann%2FSmart_Fault_Injector_LLM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JiaHuann%2FSmart_Fault_Injector_LLM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JiaHuann%2FSmart_Fault_Injector_LLM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JiaHuann","download_url":"https://codeload.github.com/JiaHuann/Smart_Fault_Injector_LLM/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JiaHuann%2FSmart_Fault_Injector_LLM/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274670618,"owners_count":25328275,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-11T02:00:13.660Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ebpf","fault-injection","kernel","security-tools","testing-tools"],"created_at":"2025-01-06T00:30:03.665Z","updated_at":"2025-09-11T16:33:35.660Z","avatar_url":"https://github.com/JiaHuann.png","language":"C","funding_links":[],"categories":["Building"],"sub_categories":["Tools"],"readme":"# faultInjectionLLM  *beta-v1.0*\nfaultInjectionLLM 是对任意内核态函数进行错误注入，并基于大模型的推荐注入进行自动化执行系统。底层注入技术依赖于eBPF.\n\n通过替换任意内核态函数的返回值达到注入错误返回值的效果，验证上层函数及错误处理逻辑等。可模拟硬件错误，内存分配错误、网络错误、任意内核子系统错误等。\n\n\u003e 更多请看此文章https://zhuanlan.zhihu.com/p/2590022381\n\u003e \n\u003e bilibili演示视频：https://www.bilibili.com/video/BV1sPfhYmEm1/?vd_source=43ca4f09ea15a0b83e665cfec42b5cdd\n\n## 0.定制Kernel\n\n1. `/内核根目录/lib/error-inject.c` 将`within_error_injection_list`函数修改为如下：\n```c\nbool within_error_injection_list(unsigned long addr)\n{\n\t// struct ei_entry *ent;\n\t// bool ret = false;\n\n\t// mutex_lock(\u0026ei_mutex);\n\t// list_for_each_entry(ent, \u0026error_injection_list, list) {\n\t// \tif (addr \u003e= ent-\u003estart_addr \u0026\u0026 addr \u003c ent-\u003eend_addr) {\n\t// \t\tret = true;\n\t// \t\tbreak;\n\t// \t}\n\t// }\n\t// mutex_unlock(\u0026ei_mutex);\n\t// return ret;\n\n    return true;\n}\n\n```\n2. 打开`CONFIG_BPF_KPROBE_OVERRIDE`以及ebpf相关基本config\n3. 重新编译安装内核。\n\n## 1. 环境安装\n\n- 安装依赖包\n```shell\nsudo apt install clang libc6-dev-i386 linux-headers-$(uname -r) python3.11-venv tmux\n```\n\n- 安装内核编译环境（使用适配faultInjectionLLM的内核可忽略）\n```shell\nsudo apt install build-essential flex bison dwarves libssl-dev libelf-dev libncurses-dev bc\n```\n\n- 安装 faultInjectionLLM\n\n  前往[Github Releases](https://github.com/JiaHuann/Smart_Fault_Injector_LLM/releases), 下载最新 deb 文件。\n\n  安装 faultInjectionLLM, 将其中/path/to/faultinjectionllm_x.y.z_amd64.deb 换成你的路径和文件名\n  ```bash\n  sudo dpkg -i /path/to/faultinjectionllm_x.y.z_amd64.deb\n  ```\n\n## 2.使用faultInjectionLLM\n0. 在仓库根目录创建`.env`文件,并根据实际情况填写。\n```yaml\nOPENAI_API_KEY=xxxxx\nOPENAI_BASE_URL=xxxx\n```\n\n1. 启动LLM Server：\n\n    `faultInjectionLLM server` \n\n2. 添加需要分析的注入点所在源文件（支持手工添加注入点）：\n\n    `faultInjectionLLM add [default | multi | manual] \u003cAbsolute-Path-Of-SourceCode-File\u003e`\n\n3. 根据LLM的推荐具体选择注入点以及概率：\n\n    `faultInjectionLLM choose [-i | default]`\n\n4. 验证\n\n    `faultInjectionLLM verify `\n\n5. 生成注入执行程序\n\n    `faultInjectionLLM gen `\n\n6. 执行错误注入程序：\n\n    `faultInjectionLLM tmux [once | progressive]`\n\n\n## 3. 参数解释\n- add \n    - **default**: 默认使用所有的LLM推荐的错误注入点以及错误类型，每个类型被随机触发的概率为5%。\n    - **multi**: 使用所有的LLM推荐的错误注入点以及错误类型。\n    - **manual**: 手动选择额外的错误注入点以及错误类型，并可以自定义每个概率的触发概率\n- choose\n    - **-i**: 交互式选择错误注入值以及每个值的概率\n    - **default**: 默认（函数的所有错误值都会被触发，都为5%的概率，函数被触发错误的概率为N*0.05,不超过1）\n\n- tmux\n    - **once**: 一次性使能所有错误注入点。\n    - **progressive**: 每五秒加载一个错误注入点，同时不会覆盖已加载的错误注入点。\n\n## 4.其他使用方法\n\n1. 查看已添加的注入点：\n\n    `faultInjectionLLM list [recommend | select | verified]`\n\n2. 清除历史文件：\n\n    `faultInjectionLLM clean`\n\n\n## 5.MORE\n欢迎使用过程中遇到bug和问题时提交issue。你的意见会使得faultInjectionLLM更加完善！\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJiaHuann%2FSmart_Fault_Injector_LLM","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJiaHuann%2FSmart_Fault_Injector_LLM","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJiaHuann%2FSmart_Fault_Injector_LLM/lists"}