Skip to content

Repository files navigation

🛠️ Linux Driver Evaluation System

This project implements an automated evaluation pipeline for Linux character device driver code — including code generated by LLMs.
The system scores each driver file on:

  • ✅ Compilation success
  • ✅ Style compliance
  • ✅ Security heuristics

It outputs a detailed JSON report with component-wise scores.


📌 Features

  • ⚙️ Compilation check using gcc
  • 🎯 Style compliance via checkpatch.pl (Linux kernel style)
  • 🔐 Security scan for:
    • Buffer overflows
    • Race condition indicators
    • Input validation issues
  • 🤖 LLM-generated driver evaluation
  • 🧮 Score calculation based on weighted metrics
  • 🧪 Bonus: Runtime test simulation
  • 💡 LLM fine-tuning suggestions

🚀 How to Use

  1. Upload your .c driver file in Colab (e.g., char_driver_sample.c)

  2. Run each cell in h2loop.ipynb:

    • compile_driver()
    • check_style()
    • run_security_checks()
    • calculate_score()
  3. Final output:
    📄 evaluation_result.json
    Includes compilation, style, and security scores with total


🧪 Test Files Included

  • char_driver_sample.c — base test driver
  • llm_generated_driver.c — ChatGPT-generated driver
  • test_driver_sim.c — simulates runtime test

📊 Sample Output

{
  "compilation": {"success": false, "warnings": 0, "errors": 1},
  "code_quality": {"style_score": 1.0},
  "security": {
    "buffer_safety": 1.0,
    "race_conditions": 0.5,
    "input_validation": 0.4
  },
  "overall_score": 35.83
}

🧠 Bonus Tasks

1. Simulated Runtime Test

A user-space simulation (test_driver_sim.c) mimics interaction with the driver (read/write buffer). ➡️ Output saved in results/runtime_test_output.txt

2. LLM Evaluation Suggestions

See: LLM_Suggestions file for notes on fine-tuning, prompt engineering, and evaluation loop design.


📚 Documentation


📁 Repo Structure

h2loop.ipynb                 → Colab-based evaluation pipeline
char_driver_sample.c        → Sample driver file
llm_generated_driver.c      → LLM-generated test driver
test_driver_sim.c           → Runtime simulation test
evaluation_result.json      → Sample output JSON
ARCHITECTURE / RUBRICS / USER_GUIDE / LLM_Suggestions → Documentation files

🎥 Demo Recording

👉 Watch full walkthrough on Loom


👤 Author

Divyansh Gautam Automated evaluation pipeline for Linux device-driver code — including LLM-generated drivers.

About

Automated evaluation pipeline for Linux character-device drivers (including LLM-generated ones): compiles, checks kernel style via checkpatch, runs security heuristics, and emits a weighted score as JSON.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages