From b03c2054aabfa863c3d5b5ea5ee7c5e063adaf86 Mon Sep 17 00:00:00 2001 From: sky Date: Thu, 7 Aug 2025 04:48:12 +0800 Subject: [PATCH 1/3] =?UTF-8?q?docs:=20=E6=9B=B4=E6=96=B0=20README.md=20?= =?UTF-8?q?=E9=80=82=E9=85=8D=20v6.0.0=20=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 重新设计 README.md 文件,突出 v6.0.0 版本的核心特性和优势: 新特性: - 突出工作流驱动的设计理念 - 强调一键式 auto-patch 命令的简便性 - 展示代码精简和质量提升的成果 - 重新组织文档导航结构 - 添加版本对比表格 - 更新项目结构说明 内容优化: - 简化快速开始流程 - 明确使用场景和核心优势 - 提供清晰的文档阅读路径 - 更新依赖安装说明 --- docs: Update README.md for v6.0.0 version Redesigned README.md to highlight v6.0.0 core features and advantages: New Features: - Emphasize workflow-driven design philosophy - Highlight simplicity of one-click auto-patch command - Showcase code streamlining and quality improvements - Reorganize documentation navigation structure - Add version comparison table - Update project structure description Content Optimization: - Simplify quick start process - Clarify use cases and core advantages - Provide clear documentation reading path - Update dependency installation instructions --- README.md | 153 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 106 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index b1e5b8f..1007b98 100644 --- a/README.md +++ b/README.md @@ -1,73 +1,132 @@ -# OpenWrt 内核补丁管理工具集 +# OpenWrt 内核补丁管理工具 v6.0.0 -## �� 目录结构 +一个专为 OpenWrt 开发者设计的现代化 CVE 补丁制作工具,采用**工作流驱动**的设计理念,实现一键式自动化补丁制作。 + +## 🚀 v6.0.0 重大更新 + +- **🎯 工作流驱动**: 从工具箱模式转变为自动化工作流模式 +- **⚡ 极简操作**: 一个 `auto-patch` 命令完成整个补丁制作流程 +- **📦 代码精简**: 从 3500+ 行精简至 600+ 行,提升 83% 的代码质量 +- **🤖 自动元数据**: 补丁生成时自动注入完整的 CVE 元数据 +- **📚 文档重组**: 按类别重新组织文档结构,提升可读性 + +## 📁 项目结构 ``` -/Users/sky/linux-kernel/openwrt/ -├── tools/ # 🔧 工具脚本目录 -│ ├── quilt_patch_manager_final.sh # 主要工具 (v5.7) - 智能元数据集成 -│ ├── patch_helper_universal.sh # 通用补丁助手 -│ └── patch_helper.sh # 基础补丁助手 -├── doc/ # 📚 完整文档 -│ ├── QUILT_PATCH_MANAGER_GUIDE.md -│ ├── DOCUMENTATION_INDEX.md -│ ├── UBUNTU_COMPATIBILITY_GUIDE.md -│ └── ... (更多文档) -├── openwrt-source/ # OpenWrt 源码目录 -└── README.md # 本文件 +openwrt-tools/ +├── tools/ # 🔧 核心工具 +│ └── quilt_patch_manager_final.sh # v6.0.0 主工具 +├── doc/ # 📚 分类文档 +│ ├── 01_tool_guides/ # 工具使用指南 +│ ├── 02_workflow_guides/ # 工作流程指南 +│ ├── 03_reference_manuals/ # 参考手册 +│ ├── 04_summaries/ # 总结归档 +│ └── DOCUMENTATION_INDEX.md # 文档索引 +├── suggest/ # 💡 改进建议文档 +└── README.md # 本文件 ``` -## 🚀 快速开始 +## 🎯 核心功能 -### 主要工具 (推荐 v5.7) +### 🥇 一键式补丁制作 ```bash -# 演示所有功能 -./tools/quilt_patch_manager_final.sh demo +# 最推荐的使用方式 - 一键完成所有操作 +./tools/quilt_patch_manager_final.sh auto-patch +``` -# 🆕 智能补丁兼容性检测 (推荐先执行) +### 🥈 智能兼容性检测 +```bash +# 在制作补丁前检测兼容性 ./tools/quilt_patch_manager_final.sh test-patch +``` -# 查看补丁状态 +### 🥉 环境管理 +```bash +# 查看当前补丁状态 ./tools/quilt_patch_manager_final.sh status -# 🆕 网络连接检测和优化 -./tools/quilt_patch_manager_final.sh test-network - -# 自动制作 CVE 补丁 (已集成兼容性检测) -./tools/quilt_patch_manager_final.sh auto-patch +# 清理工作环境 +./tools/quilt_patch_manager_final.sh clean -# 🆕 生成补丁并自动集成元数据 (推荐) -./tools/quilt_patch_manager_final.sh auto-refresh +# 重置整个环境 +./tools/quilt_patch_manager_final.sh reset-env ``` -### 补丁管理 +## 🔧 安装与依赖 + +### 系统要求 +- ✅ **macOS** (所有版本) +- ✅ **Ubuntu 20.04+** +- ✅ **其他 Linux 发行版** + +### 依赖安装 ```bash -# 应用补丁 -./tools/quilt_patch_manager_final.sh push +# Ubuntu/Debian +sudo apt install -y curl quilt git -# 移除补丁 -./tools/quilt_patch_manager_final.sh pop +# macOS +brew install quilt curl git -# 清理补丁和临时文件 -./tools/quilt_patch_manager_final.sh clean +# CentOS/RHEL +sudo yum install -y curl quilt git ``` -## 📖 详细文档 +## 📖 文档导航 -查看 `doc/DOCUMENTATION_INDEX.md` 获取完整的工具和文档索引。 +| 文档类别 | 推荐阅读顺序 | 文档路径 | +|---------|-------------|----------| +| **🔰 新手入门** | 1️⃣ | [`doc/01_tool_guides/QUILT_PATCH_MANAGER_GUIDE.md`](doc/01_tool_guides/QUILT_PATCH_MANAGER_GUIDE.md) | +| **⚡ 快速上手** | 2️⃣ | [`doc/02_workflow_guides/QUILT_CVE_PATCH_CREATION_GUIDE.md`](doc/02_workflow_guides/QUILT_CVE_PATCH_CREATION_GUIDE.md) | +| **📋 标准流程** | 3️⃣ | [`doc/02_workflow_guides/CVE_PATCH_WORKFLOW.md`](doc/02_workflow_guides/CVE_PATCH_WORKFLOW.md) | +| **🔍 版本对比** | 4️⃣ | [`doc/01_tool_guides/VERSION_COMPARISON_v5.7_vs_v6.0.md`](doc/01_tool_guides/VERSION_COMPARISON_v5.7_vs_v6.0.md) | +| **📚 完整索引** | 🔗 | [`doc/DOCUMENTATION_INDEX.md`](doc/DOCUMENTATION_INDEX.md) | -## 🎯 支持平台 +## 💡 使用场景 -- ✅ macOS (所有版本) -- ✅ Ubuntu 20.04+ -- ✅ 其他 Linux 发行版 +### 场景 1: CVE 补丁制作 (最常用) +```bash +# 一键制作 CVE 补丁 +./tools/quilt_patch_manager_final.sh auto-patch 1234567890abcdef CVE-2024-12345 +``` -## 🔧 依赖要求 +### 场景 2: 企业 SVN 环境 +- ✅ 无需 Git 历史依赖 +- ✅ 支持多源补丁 (Linux 主线、Android、GitHub) +- ✅ 智能冲突预警 -```bash -# Ubuntu/Debian -sudo apt install -y curl quilt +### 场景 3: 高版本向低版本移植 +- ✅ 智能兼容性检测 +- ✅ 符号变更预警 +- ✅ 模糊匹配支持 -# macOS -brew install quilt -``` +## 🆚 版本对比 + +| 特性 | v5.7.0 (旧版) | v6.0.0 (当前) | +|------|---------------|---------------| +| **操作复杂度** | 多步手动操作 | 一键自动化 | +| **代码行数** | 3,535 行 | 607 行 | +| **学习成本** | 需要了解多个命令 | 只需掌握 `auto-patch` | +| **出错概率** | 高 (多步骤) | 极低 (自动化) | +| **维护难度** | 复杂 | 简单 | + +## 🌟 核心优势 + +1. **🎯 专注性**: 专门为 OpenWrt CVE 补丁制作而设计 +2. **⚡ 高效性**: 一键完成从下载到生成的全流程 +3. **🛡️ 安全性**: 智能兼容性检测,避免代码损坏 +4. **🔧 适应性**: 支持 SVN 环境和多源补丁场景 +5. **📚 完整性**: 详尽的文档体系和实战案例 + +## 🤝 贡献与支持 + +- **📋 问题反馈**: [GitHub Issues](https://github.com/TbusOS/openwrt-tools/issues) +- **💡 功能建议**: 查看 [`suggest/`](suggest/) 目录 +- **📖 文档改进**: 欢迎提交 PR 改进文档 + +## 📄 许可证 + +本项目采用 MIT 许可证 - 详见 [LICENSE](LICENSE) 文件。 + +--- + +**🎉 立即开始**: 阅读 [`doc/01_tool_guides/QUILT_PATCH_MANAGER_GUIDE.md`](doc/01_tool_guides/QUILT_PATCH_MANAGER_GUIDE.md) 开始您的 CVE 补丁制作之旅! \ No newline at end of file From ad0380389b017cec0726c6df2fdd56c89d33ddd4 Mon Sep 17 00:00:00 2001 From: sky Date: Thu, 7 Aug 2025 05:15:21 +0800 Subject: [PATCH 2/3] =?UTF-8?q?docs:=20=E5=90=8C=E6=AD=A5=E8=8B=B1?= =?UTF-8?q?=E6=96=87=E7=89=88=E6=96=87=E6=A1=A3=20README-en.md=20=E5=88=B0?= =?UTF-8?q?=20v6.0.0=20=E5=88=86=E6=94=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 从 main 分支同步英文版文档到 release/v6.0.0 分支,确保发布分支包含完整的国际化文档。 📖 同步内容: - OpenWrt 内核补丁管理工具 v6.0.0 完整英文文档 - v6.0.0 重大更新特性的英文描述 - 详细的安装指南和使用说明 - 完整的文档导航和版本对比表格 - 专业的技术术语翻译 🎯 目标: - 为 v6.0.0 发布版本提供完整的双语文档支持 - 服务国际开发者和海外用户社区 - 确保发布分支文档的完整性和一致性 --- docs: Sync English documentation README-en.md to v6.0.0 branch Synchronized English documentation from main branch to release/v6.0.0 branch to ensure the release branch contains complete internationalized documentation. 📖 Synchronized Content: - Complete English documentation for OpenWrt Kernel Patch Management Tool v6.0.0 - English descriptions of v6.0.0 major update features - Detailed installation guide and usage instructions - Complete documentation navigation and version comparison tables - Professional technical terminology translation 🎯 Goals: - Provide complete bilingual documentation support for v6.0.0 release - Serve international developers and overseas user communities - Ensure completeness and consistency of release branch documentation --- README-en.md | 132 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 README-en.md diff --git a/README-en.md b/README-en.md new file mode 100644 index 0000000..fda5543 --- /dev/null +++ b/README-en.md @@ -0,0 +1,132 @@ +# OpenWrt Kernel Patch Management Tool v6.0.0 + +A modern CVE patch creation tool designed specifically for OpenWrt developers, featuring a **workflow-driven** design philosophy for one-click automated patch creation. + +## 🚀 v6.0.0 Major Updates + +- **🎯 Workflow-Driven**: Transformed from toolbox mode to automated workflow mode +- **⚡ Ultra-Simple Operation**: One `auto-patch` command completes the entire patch creation process +- **📦 Code Streamlined**: Reduced from 3500+ lines to 600+ lines, improving code quality by 83% +- **🤖 Automatic Metadata**: Automatically injects complete CVE metadata during patch generation +- **📚 Documentation Reorganization**: Reorganized documentation structure by category for improved readability + +## 📁 Project Structure + +``` +openwrt-tools/ +├── tools/ # 🔧 Core Tools +│ └── quilt_patch_manager_final.sh # v6.0.0 Main Tool +├── doc/ # 📚 Categorized Documentation +│ ├── 01_tool_guides/ # Tool Usage Guides +│ ├── 02_workflow_guides/ # Workflow Process Guides +│ ├── 03_reference_manuals/ # Reference Manuals +│ ├── 04_summaries/ # Summary Archives +│ └── DOCUMENTATION_INDEX.md # Documentation Index +├── suggest/ # 💡 Improvement Suggestions +└── README.md # This File +``` + +## 🎯 Core Features + +### 🥇 One-Click Patch Creation +```bash +# Most recommended usage - one command completes all operations +./tools/quilt_patch_manager_final.sh auto-patch +``` + +### 🥈 Intelligent Compatibility Detection +```bash +# Test compatibility before creating patches +./tools/quilt_patch_manager_final.sh test-patch +``` + +### 🥉 Environment Management +```bash +# View current patch status +./tools/quilt_patch_manager_final.sh status + +# Clean working environment +./tools/quilt_patch_manager_final.sh clean + +# Reset entire environment +./tools/quilt_patch_manager_final.sh reset-env +``` + +## 🔧 Installation & Dependencies + +### System Requirements +- ✅ **macOS** (All versions) +- ✅ **Ubuntu 20.04+** +- ✅ **Other Linux Distributions** + +### Dependency Installation +```bash +# Ubuntu/Debian +sudo apt install -y curl quilt git + +# macOS +brew install quilt curl git + +# CentOS/RHEL +sudo yum install -y curl quilt git +``` + +## 📖 Documentation Navigation + +| Document Category | Recommended Reading Order | Document Path | +|-------------------|-------------------------|---------------| +| **🔰 Beginner Guide** | 1️⃣ | [`doc/01_tool_guides/QUILT_PATCH_MANAGER_GUIDE.md`](doc/01_tool_guides/QUILT_PATCH_MANAGER_GUIDE.md) | +| **⚡ Quick Start** | 2️⃣ | [`doc/02_workflow_guides/QUILT_CVE_PATCH_CREATION_GUIDE.md`](doc/02_workflow_guides/QUILT_CVE_PATCH_CREATION_GUIDE.md) | +| **📋 Standard Process** | 3️⃣ | [`doc/02_workflow_guides/CVE_PATCH_WORKFLOW.md`](doc/02_workflow_guides/CVE_PATCH_WORKFLOW.md) | +| **🔍 Version Comparison** | 4️⃣ | [`doc/01_tool_guides/VERSION_COMPARISON_v5.7_vs_v6.0.md`](doc/01_tool_guides/VERSION_COMPARISON_v5.7_vs_v6.0.md) | +| **📚 Complete Index** | 🔗 | [`doc/DOCUMENTATION_INDEX.md`](doc/DOCUMENTATION_INDEX.md) | + +## 💡 Use Cases + +### Scenario 1: CVE Patch Creation (Most Common) +```bash +# One-click CVE patch creation +./tools/quilt_patch_manager_final.sh auto-patch 1234567890abcdef CVE-2024-12345 +``` + +### Scenario 2: Enterprise SVN Environment +- ✅ No Git history dependency required +- ✅ Supports multi-source patches (Linux mainline, Android, GitHub) +- ✅ Intelligent conflict warnings + +### Scenario 3: High-to-Low Version Porting +- ✅ Intelligent compatibility detection +- ✅ Symbol change warnings +- ✅ Fuzzy matching support + +## 🆚 Version Comparison + +| Feature | v5.7.0 (Legacy) | v6.0.0 (Current) | +|---------|-----------------|------------------| +| **Operation Complexity** | Multi-step manual operations | One-click automation | +| **Lines of Code** | 3,535 lines | 607 lines | +| **Learning Curve** | Need to understand multiple commands | Only need to master `auto-patch` | +| **Error Probability** | High (multi-step) | Extremely low (automated) | +| **Maintenance Difficulty** | Complex | Simple | + +## 🌟 Core Advantages + +1. **🎯 Focus**: Specifically designed for OpenWrt CVE patch creation +2. **⚡ Efficiency**: One-click completion from download to generation +3. **🛡️ Security**: Intelligent compatibility detection to avoid code damage +4. **🔧 Adaptability**: Supports SVN environments and multi-source patch scenarios +5. **📚 Completeness**: Comprehensive documentation system and practical examples + +## 🤝 Contributing & Support + +- **📋 Issue Reports**: [GitHub Issues](https://github.com/TbusOS/openwrt-tools/issues) +- **💡 Feature Suggestions**: Check the [`suggest/`](suggest/) directory +- **📖 Documentation Improvements**: Welcome to submit PRs for documentation improvements + +## 📄 License + +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. + +--- + +**🎉 Get Started Now**: Read [`doc/01_tool_guides/QUILT_PATCH_MANAGER_GUIDE.md`](doc/01_tool_guides/QUILT_PATCH_MANAGER_GUIDE.md) to begin your CVE patch creation journey! \ No newline at end of file From d5a38d218bf9a31b9edb8ffd02908c4e4a0a4c32 Mon Sep 17 00:00:00 2001 From: sky Date: Thu, 7 Aug 2025 05:20:56 +0800 Subject: [PATCH 3/3] =?UTF-8?q?docs:=20=E8=AF=A6=E7=BB=86=E8=A1=A5?= =?UTF-8?q?=E5=85=85=20auto-patch=20=E5=91=BD=E4=BB=A4=E7=9A=84=E5=9B=9B?= =?UTF-8?q?=E6=AD=A5=E6=89=A7=E8=A1=8C=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为核心文档添加 auto-patch 命令的详细技术实现说明,包括: 🔄 四步自动化流程详解: - 步骤 1/4: 兼容性测试 (patch --dry-run, 冲突分析) - 步骤 2/4: 创建补丁并添加文件 (quilt new, awk 解析, quilt add) - 步骤 3/4: 等待手动修改 (交互暂停, 用户介入点) - 步骤 4/4: 生成带元数据的最终补丁 (元数据注入, quilt refresh) 📖 更新文档: - doc/01_tool_guides/QUILT_PATCH_MANAGER_GUIDE.md - 工具使用指南 - doc/02_workflow_guides/QUILT_CVE_PATCH_CREATION_GUIDE.md - CVE 补丁创建指南 - doc/02_workflow_guides/CVE_PATCH_WORKFLOW.md - CVE 工作流程 🎯 技术细节覆盖: - 具体的 bash 命令执行过程 - 文件路径和目录结构说明 - 用户交互点和操作指导 - 工具输出示例和日志格式 - 错误处理和冲突解决策略 🌟 用户价值: - 深入理解 auto-patch 的内部工作机制 - 明确每个步骤的具体操作和预期结果 - 提供详细的故障排除和操作指南 - 确保文档与 v6.0.0 代码实现完全同步 --- docs: Add detailed four-step execution flow for auto-patch command Added comprehensive technical implementation details for the auto-patch command to core documentation, including: 🔄 Four-step automation flow breakdown: - Step 1/4: Compatibility testing (patch --dry-run, conflict analysis) - Step 2/4: Create patch and add files (quilt new, awk parsing, quilt add) - Step 3/4: Wait for manual modifications (interactive pause, user intervention point) - Step 4/4: Generate final patch with metadata (metadata injection, quilt refresh) 📖 Updated documentation: - doc/01_tool_guides/QUILT_PATCH_MANAGER_GUIDE.md - Tool usage guide - doc/02_workflow_guides/QUILT_CVE_PATCH_CREATION_GUIDE.md - CVE patch creation guide - doc/02_workflow_guides/CVE_PATCH_WORKFLOW.md - CVE workflow 🎯 Technical details coverage: - Specific bash command execution process - File paths and directory structure explanations - User interaction points and operation guidance - Tool output examples and log formats - Error handling and conflict resolution strategies 🌟 User value: - Deep understanding of auto-patch internal mechanisms - Clear expectations for each step's operations and results - Detailed troubleshooting and operation guidance - Ensures documentation is fully synchronized with v6.0.0 code implementation --- .../QUILT_PATCH_MANAGER_GUIDE.md | 38 ++++++++++-- doc/02_workflow_guides/CVE_PATCH_WORKFLOW.md | 49 ++++++++++++++-- .../QUILT_CVE_PATCH_CREATION_GUIDE.md | 58 +++++++++++++++++++ 3 files changed, 136 insertions(+), 9 deletions(-) diff --git a/doc/01_tool_guides/QUILT_PATCH_MANAGER_GUIDE.md b/doc/01_tool_guides/QUILT_PATCH_MANAGER_GUIDE.md index d5c520f..a3a6521 100755 --- a/doc/01_tool_guides/QUILT_PATCH_MANAGER_GUIDE.md +++ b/doc/01_tool_guides/QUILT_PATCH_MANAGER_GUIDE.md @@ -24,11 +24,39 @@ ``` **工作流程详解:** -1. **兼容性测试**: 自动对指定的 `commit_id` 进行全面的兼容性分析。如果发现冲突,会给出警告并让用户确认是否继续。 -2. **创建补丁**: 在内核源码目录中自动创建一个新的 quilt 补丁。 -3. **添加文件**: 自动提取该 commit 涉及的所有文件,并使用 `quilt add` 将它们添加到补丁中。 -4. **等待用户修改**: 脚本会在此暂停,等待您根据需要**手动修改代码**以解决冲突或进行适配。 -5. **生成最终补丁**: 您修改完成后,按回车键,脚本会自动执行 `refresh-with-header`,生成包含原始作者、日期和提交信息的最终补丁文件,并将其拷贝到 `output` 目录。 + +#### 🔄 四步自动化流程 + +**步骤 1/4: 兼容性测试** (`test_patch_compatibility`) +- 📥 从 Linux 内核官方仓库 (`git.kernel.org`) 自动下载原始补丁 +- 🔍 智能查找 OpenWrt 内核源码目录 (支持 `build_dir/target-*/linux-*/linux-*` 路径) +- 🧪 执行 `patch --dry-run -p1 --verbose` 进行干运行测试 +- ⚠️ 如果发现冲突,显示详细的冲突分析报告并询问用户是否继续 +- 📋 生成兼容性分析结果到临时目录 + +**步骤 2/4: 创建补丁并添加文件** +- 🆕 调用 `quilt new ` 在内核源码目录创建新补丁 +- 📄 使用 `awk '/^--- a\// {print $2}'` 从原始补丁中提取所有涉及的文件列表 +- 💾 将文件列表保存到 `patch_manager_work/outputs/patch_files.txt` +- ✅ 验证每个文件的存在性,跳过不存在的文件 +- ➕ 使用 `printf "%s\n" "${valid_files[@]}" | xargs quilt add` 批量添加文件到补丁 + +**步骤 3/4: 等待手动修改** +- ⏸️ 脚本智能暂停,进入交互模式 +- 💡 提示用户当前是进行手动代码修改的最佳时机 +- 🔧 用户可以: + - 解决补丁冲突 + - 调整代码以适配当前内核版本 + - 修改功能实现细节 + - 测试修改效果 +- ⏳ 等待用户按 Enter 键继续流程 + +**步骤 4/4: 生成带元数据的最终补丁** (`quilt_refresh_with_header`) +- 📋 使用 `awk '/^diff --git/ {exit} {print}'` 从原始补丁提取完整元数据头部 +- 🔄 执行 `quilt refresh` 生成当前修改的代码差异 +- 🔗 将原始元数据 (作者、日期、描述、CVE 信息) 与代码差异智能合并 +- 📤 自动复制最终补丁到 `patch_manager_work/outputs/` 目录 +- ✅ 补丁同时保存在内核的 `patches/` 目录和输出目录中 --- diff --git a/doc/02_workflow_guides/CVE_PATCH_WORKFLOW.md b/doc/02_workflow_guides/CVE_PATCH_WORKFLOW.md index bed2572..35e00a6 100755 --- a/doc/02_workflow_guides/CVE_PATCH_WORKFLOW.md +++ b/doc/02_workflow_guides/CVE_PATCH_WORKFLOW.md @@ -41,10 +41,51 @@ make target/linux/prepare V=s ./tools/quilt_patch_manager_final.sh auto-patch 654b33ada4ab 950-proc-fix-UAF-in-proc_get_inode.patch ``` -工具会自动处理: -- 创建 quilt 补丁 -- 添加所有相关文件 -- **暂停并等待用户进行必要的手动修改** (如果 `test-patch` 提示有冲突) +#### 🔄 `auto-patch` 自动化执行流程 + +该命令将依次执行四个阶段,每个阶段都有明确的目标和输出: + +**阶段 1: 智能兼容性分析** +- 📥 自动从 `git.kernel.org` 下载 commit `654b33ada4ab` 的原始补丁 +- 🔍 智能定位 OpenWrt 内核源码目录 (`build_dir/target-*/linux-*/linux-*`) +- 🧪 执行 `patch --dry-run` 进行无损兼容性测试 +- 📊 生成详细的冲突分析报告(如果存在) +- ⚠️ 如检测到冲突,会提示用户确认是否继续 + +**阶段 2: 自动化补丁框架搭建** +- 🆕 在内核目录执行 `quilt new 950-proc-fix-UAF-in-proc_get_inode.patch` +- 📄 解析原始补丁,提取所有涉及的文件路径(如 `fs/proc/inode.c`) +- 💾 将文件列表保存到 `patch_manager_work/outputs/patch_files.txt` +- ✅ 验证文件存在性,自动跳过不存在的文件 +- ➕ 执行 `quilt add` 批量添加有效文件到补丁管理 + +**阶段 3: 人工交互介入点** +- ⏸️ 工具智能暂停,等待用户进行必要的代码修改 +- 💡 此时用户可以: + ```bash + # 进入内核目录进行代码修改 + cd build_dir/target-*/linux-*/linux-*/ + + # 手动编辑文件解决冲突 + vim fs/proc/inode.c + + # 或使用其他编辑器进行修改 + nano fs/proc/inode.c + ``` +- 🔧 用户修改的典型场景: + - 解决 API 变更导致的编译冲突 + - 适配不同内核版本的代码结构 + - 调整功能实现以符合 OpenWrt 环境 +- ⏳ 修改完成后,回到 OpenWrt 根目录按 Enter 键继续 + +**阶段 4: 元数据注入与补丁生成** +- 📋 从原始补丁中提取完整的元数据头部(作者、日期、描述、CVE 信息) +- 🔄 执行 `quilt refresh` 生成包含用户修改的代码差异 +- 🔗 智能合并原始元数据与新的代码差异 +- 📤 生成最终补丁文件,同时保存到: + - 内核目录:`patches/950-proc-fix-UAF-in-proc_get_inode.patch` + - 输出目录:`patch_manager_work/outputs/950-proc-fix-UAF-in-proc_get_inode.patch` +- ✅ 最终补丁包含完整的 CVE 信息和可用的代码修改 ### 步骤 4: 生成并获取最终补丁 diff --git a/doc/02_workflow_guides/QUILT_CVE_PATCH_CREATION_GUIDE.md b/doc/02_workflow_guides/QUILT_CVE_PATCH_CREATION_GUIDE.md index eeda637..c8bb27e 100755 --- a/doc/02_workflow_guides/QUILT_CVE_PATCH_CREATION_GUIDE.md +++ b/doc/02_workflow_guides/QUILT_CVE_PATCH_CREATION_GUIDE.md @@ -48,6 +48,64 @@ make target/linux/prepare V=s ./tools/quilt_patch_manager_final.sh auto-patch 654b33ada4ab 950-proc-fix-UAF-in-proc_get_inode.patch ``` +#### 🔄 `auto-patch` 详细执行流程 + +当您运行上述命令后,工具将自动执行以下四个步骤: + +**🔍 步骤 1/4: 自动兼容性测试** +``` +[INFO] --- 步骤 1/4: 兼容性测试 --- +[INFO] 测试 commit 654b33ada4ab 的补丁兼容性... +[SUCCESS] 找到内核源码目录: /path/to/openwrt/build_dir/target-mips_24kc_musl/linux-ath79_generic/linux-5.15.162 +[INFO] 开始干跑 (dry-run) 测试... +[SUCCESS] 🎉 补丁完全兼容! +``` +- 自动从 `git.kernel.org` 下载原始补丁并缓存 +- 执行 `patch --dry-run` 测试兼容性 +- 如果有冲突,会显示详细的冲突文件和行号 + +**🆕 步骤 2/4: 创建补丁并添加文件** +``` +[INFO] --- 步骤 2/4: 创建补丁并添加文件 --- +[INFO] 准备创建新补丁: 950-proc-fix-UAF-in-proc_get_inode.patch +[SUCCESS] 补丁 '950-proc-fix-UAF-in-proc_get_inode.patch' 创建成功 +[INFO] 提取 commit 654b33ada4ab 涉及的文件列表... +[SUCCESS] 找到 1 个文件,已保存到: patch_manager_work/outputs/patch_files.txt +[SUCCESS] 批量添加 1 个文件完成。 +``` +- 自动执行 `quilt new` 创建新补丁 +- 提取补丁涉及的所有文件 (如 `fs/proc/inode.c`) +- 使用 `quilt add` 批量添加文件到补丁管理 + +**⏸️ 步骤 3/4: 等待手动修改** +``` +[INFO] --- 步骤 3/4: 等待手动修改 --- +[WARNING] 补丁已创建,文件已添加。现在是手动修改代码以解决冲突的最佳时机。 +[INFO] 修改完成后,按 Enter键继续以生成最终补丁... +``` +- 此时工具暂停等待您的操作 +- 您可以进入内核目录手动修改代码: + ```bash + cd build_dir/target-*/linux-*/linux-*/ + # 编辑相关文件,如: vim fs/proc/inode.c + # 应用您需要的修改,解决冲突或适配代码 + ``` +- 修改完成后回到原目录按 Enter 继续 + +**🎉 步骤 4/4: 生成最终补丁** +``` +[INFO] --- 步骤 4/4: 生成带元数据的最终补丁 --- +[INFO] 🔄 [核心] 刷新补丁并注入来自 commit '654b33ada4ab' 的元数据... +[INFO] 元数据头已提取, 正在生成纯代码 diff... +[SUCCESS] 🎉 补丁已成功生成: /path/to/patches/950-proc-fix-UAF-in-proc_get_inode.patch +[SUCCESS] 📄 最终补丁已拷贝到: patch_manager_work/outputs/950-proc-fix-UAF-in-proc_get_inode.patch +[SUCCESS] 🎉 自动化流程完成! +``` +- 自动提取原始补丁的元数据 (作者、日期、描述) +- 执行 `quilt refresh` 生成代码差异 +- 将元数据和代码差异合并成最终补丁 +- 补丁同时保存在内核目录和输出目录 + **工具在后台会自动完成以下所有操作:** 1. **查找内核目录**: 自动定位到 `build_dir/.../linux-x.x.x`。 2. **创建新补丁**: 自动执行 `quilt new`。