Skip to content
← ENGINEERING NOTES
KERNEL7 min read

Linux Kernel Rules for AI-Found Bugs and Patches

What the Linux kernel's own docs say about AI-found bugs and AI-written patches: no AI Signed-off-by, reproducers first, plus a checkpatch and get_maintainer workflow.

BY ASHLIN DARIUS GOVINDASAMY

Your LLM just told you it found a use-after-free in the Linux kernel. Congratulations, you are about to become a maintainer's least favourite email, unless you read three short files first. The kernel tree now carries written rules for AI-found bugs and AI-written patches: coding-assistants.rst, generated-content.rst and threat-model.rst, all under Documentation/process. This post explains what they require, then turns the rules into a workflow you can run in a shell.

Why the kernel wrote these rules down

The generated-content document opens with the real reason: tools can increase the volume of contributions, while reviewer and maintainer bandwidth is a scarce resource. Knowing which parts came from a human and which from a tool helps maintainers spend that bandwidth well. The coding-assistants document is blunter about the failure mode: maintainers currently waste too much time analyzing unverified reports and untested fixes.

So the rules are not anti-AI. They are anti-noise. A bug report with a reproducer and a tested fix is welcome whatever found it. A confident paragraph of machine speculation is not.

The hard rule: only a human signs off

The Signed-off-by tag certifies the Developer Certificate of Origin, a legal statement. The coding-assistants document says AI agents MUST NOT add Signed-off-by tags, and that only humans can legally certify the DCO. The human submitter reviews all AI-generated code, checks licensing, adds their own Signed-off-by and takes full responsibility for the contribution.

Licensing is part of the same section: all code must be compatible with GPL-2.0-only and carry appropriate SPDX identifiers. If your agent runs git commit with a sign-off flag by default, turn that off for kernel work. The commit your agent prepares should have none, and you add yours when you have actually read the diff.

QUICK CHECK

Who may add the Signed-off-by tag to a patch an AI assistant helped write?

The nine-step bug procedure

When an assistant is used to find and fix bugs, the document says it MUST follow at least a list of steps. Paraphrased and trimmed, they are:

  • Read the whole process documentation, not isolated keyword hits.
  • Note the commit ID you analyzed and locate the bug.
  • For anything non-trivial, build a reproducer. If you cannot make it show up, stop: unverified reports may be ignored.
  • Write the fix. The document says this is not optional, because an assistant able to find a bug can usually fix it, and a fix written in the same session tends to be more accurate.
  • Build and verify. The fix must add no build warnings and pass checkpatch.pl. Drop fixes that do not work.
  • Commit with a detailed message and a Fixes tag, with no Signed-off-by.
  • Find the maintainers and lists with scripts/get_maintainer.pl.
  • Say explicitly what could not be built, tested or reproduced.
  • Use the threat model to decide bug versus vulnerability, and leave the result to the reporter. The assistant must never send anything itself.

Hands-on: from finding to a sendable patch

Here is the human side of that procedure as a shell session. Run it from the root of a kernel checkout. Replace the placeholders with your own commit and path. The commands are standard kernel tooling: checkpatch.pl and get_maintainer.pl live in scripts, and git format-patch writes the mail-ready file.

bash
# 1. Record exactly what you tested
git rev-parse HEAD

# 2. Build the touched code with warnings visible (adjust the path)
make -j"$(nproc)" W=1 drivers/example/

# 3. Generate the Fixes tag for the commit that introduced the bug
#    (use a 12-character abbreviation, the kernel norm)
git config core.abbrev 12
git log -1 --format='Fixes: %h ("%s")' <offending-commit>

# 4. Commit WITHOUT -s: an AI agent must not add Signed-off-by.
#    You add your own line after reviewing the diff.
git commit -a

# 5. Style check the commit you just made
scripts/checkpatch.pl --strict -g HEAD

# 6. Turn it into a mail-ready patch and find who should get it
git format-patch -1 -o /tmp/outgoing
scripts/get_maintainer.pl /tmp/outgoing/0001-*.patch
Verify, format and route a fix

Then add your own sign-off, either by editing the commit or running git commit --amend -s once you are satisfied. Put the tool disclosure in the changelog, covered next.

Disclose the tool, not just the result

The generated-content document is about transparency. It applies when a meaningful amount of content was not written by a person in the Signed-off-by chain. Its examples include a chatbot writing a function, a coding assistant producing a .c file you cleaned up by hand, and a generative tool writing the changelog. It also says that if a tool was used to find the problem, that belongs in the changelog, which credits the tool and helps others discover it.

It lists what helps reviewers: which tools you used, the input you gave them (a Coccinelle script, say), the prompts if the code came from a short set of them or a summary of longer sessions, which parts were affected, and how you tested. Out of scope are trivial tweaks and menial work such as spelling fixes, identifier completion, mechanical renames and running a formatter like clang-format.

text
The bug was found by running an LLM-based code review over
drivers/example/ at commit <sha>. The model flagged the missing
unlock on the error path; I confirmed it with the reproducer below
(a fault-injected probe failure under KASAN) before writing this
fix by hand. Built with W=1, no new warnings, checkpatch clean.
Tested on x86_64 only; I could not test on real hardware.
A changelog paragraph that follows the guidelines
›What maintainers are allowed to do with your patch

The guidelines say individual maintainers keep discretion. They may treat it like any other patch, reject it outright, ask for extra testing, review it with extra scrutiny or at lower priority, ask how a model was trained, ask you to explain the code in detail, or suggest a better prompt instead of code changes. They also say expect additional scrutiny in proportion to how much was generated, and that maintainers may reject a series without detailed review if you cannot defend what you submitted.

Bug or vulnerability? Ask the threat model first

Step nine sends you to threat-model.rst, and this is where a lot of machine-found reports die. The document lists what the kernel does promise by default: isolation between unprivileged users, and capability-based protection such as users without CAP_NET_ADMIN being unable to alter network configuration. Bugs that violate those are security breaches, while a bug that only matters after another violation has already succeeded is a weakness.

It then lists classes that are not vulnerabilities, to be handled as regular bugs: end-of-life kernels, debug-only features like LOCKDEP, KASAN or FAULT_INJECTION, staging and experimental code, out-of-tree modules, actions by users who already hold the needed privilege such as CAP_SYS_ADMIN, and attacks needing laboratory conditions or billions of attempts. The document says these should still be reported if the kernel could do better, but as ordinary bugs.

In practice, ask three questions before you label something a vulnerability: Does it work on a maintained kernel? Does it work as an unprivileged user without a non-default configuration? Does it cross a boundary from the list above? If any answer is no, send it as a regular bug through the normal patch process.

QUICK CHECK

An LLM reports a crash that needs root in the initial namespace to trigger. How does the threat model classify it?

Find tool disclosures in a real tree

Curious how contributors disclose tools in practice? Search history for the wording. The guidelines do not define a special trailer, so grep the message text and keep your expectations loose.

bash
# Commits whose message mentions an LLM or a coding assistant
git log --since="2 weeks ago" --oneline -i \
  --grep='llm' --grep='coding assistant' --grep='generated by' | head -20

# Count Coccinelle-driven changes for comparison
git log --since="2 weeks ago" --oneline -i --grep='coccinelle' | wc -l
Search commit messages for tool mentions

Takeaway

The kernel's position is simple: use whatever tool you like, but a human owns the result. Reproduce the bug, write and test the fix, run checkpatch, route it with get_maintainer, disclose the tool, classify it with the threat model, and sign off yourself. If you cannot defend every line, do not send it. Doing it this way makes you the contributor maintainers answer first.

SOURCES

  1. Documentation/process/coding-assistants.rst (AI Coding Assistants) — Linux kernel source tree
  2. Documentation/process/generated-content.rst (Kernel Guidelines for Tool-Generated Content) — Linux kernel source tree
  3. Documentation/process/threat-model.rst (The Linux Kernel threat model) — Linux kernel source tree

Frequently asked questions

Can an AI add a Signed-off-by tag to a Linux kernel patch?

No. The kernel's coding-assistants document says AI agents must not add Signed-off-by tags, because only a human can certify the Developer Certificate of Origin and take responsibility for the contribution.

Do I have to disclose that I used an AI tool for a kernel patch?

The generated-content guidelines ask you to be transparent in cover letters and changelogs when a meaningful amount of content came from a tool, including tools that found the problem. Trivial edits like spelling fixes or running a formatter are out of scope.

What must I do before reporting an AI-found kernel bug?

Build a reproducer for non-trivial bugs, write and test a fix, make sure it builds without new warnings and passes checkpatch.pl, find recipients with get_maintainer.pl, and state clearly anything you could not test.

How do I know whether a kernel bug is a security vulnerability?

Check it against the kernel threat model. Bugs that break user isolation or capability-based protection on maintained kernels are vulnerabilities, while issues needing existing privileges, debug features or lab conditions are handled as regular bugs.

NEWSLETTER

Get the engineering notes in your inbox.

Kernels, GPUs, networks, AI infrastructure — and the things we broke along the way. No spam, one click to leave.

We store only your email address, to send you new articles. See our privacy policy.

TAGS

linuxkernelaillmpatchessecurityopen-source

RELATED

ENGINEERING NOTES

Things we built.Things we broke.Things we learned.