Skip to content

skills/qcom-kernel-platform-backport: add LTS platform backport skill - #26

Merged
Ricardo Salveti (ricardosalveti) merged 1 commit into
qualcomm-linux:mainfrom
ricardosalveti:qcom-kernel-platform-backport
Aug 25, 2026
Merged

Ricardo Salveti (ricardosalveti) merged 1 commit into
qualcomm-linux:mainfrom
ricardosalveti:qcom-kernel-platform-backport

Conversation

@ricardosalveti

Copy link
Copy Markdown
Contributor

Boards enabled upstream do not work on the qualcomm-linux LTS branch until their DTS, the SoC dtsi deltas they depend on, their bindings and a handful of driver fixes are backported. Doing that by hand is repetitive and has a few traps that are easy to fall into and expensive to find later: a cherry-pick that silently reassigns authorship, a binding shared with another SoC that regresses its DTBs, a driver enabled in defconfig but absent from the BSP module list, and CI checkers that fail structurally on any adapted backport.

Add a skill that walks the whole flow — candidate triage against the target branch, authorship-preserving cherry-picks with the UPSTREAM/BACKPORT/FROMGIT prefixes, a cross-platform CHECK_DTBS regression check, hardware validation, and the pull request — plus four helper scripts and a reference on what each Kernel Checker enforces and which of its failures a backport series cannot avoid.

Assisted-by: Claude Code:claude-fable-5

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a catalog skill for backporting upstream Qualcomm platform enablement to the LTS kernel.

Changes:

  • Documents candidate selection, backporting, validation, and PR workflows.
  • Adds helper scripts for commit handling and validation.
  • Registers the skill across catalog metadata and documentation.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
skills/qcom-kernel-platform-backport/SKILL.md Defines the workflow.
scripts/find-candidates.sh Finds candidate commits.
scripts/dtbs-compare.sh Compares DTB validation results.
scripts/check-series.sh Checks commit-series compliance.
scripts/backport-commit.sh Applies and formats backports.
references/ci-checkers.md Documents kernel CI behavior.
skills.json Adds catalog metadata.
README.md Lists the new skill.
ROADMAP.md Marks the skill available.
.claude-plugin/marketplace.json Registers the plugin.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread skills/qcom-kernel-platform-backport/scripts/find-candidates.sh Outdated
Comment thread skills/qcom-kernel-platform-backport/scripts/backport-commit.sh Outdated
Comment thread skills/qcom-kernel-platform-backport/scripts/dtbs-compare.sh Outdated
Comment thread skills/qcom-kernel-platform-backport/scripts/dtbs-compare.sh Outdated
Comment thread skills/qcom-kernel-platform-backport/scripts/check-series.sh Outdated
Comment thread skills/qcom-kernel-platform-backport/SKILL.md Outdated
Comment thread skills/qcom-kernel-platform-backport/scripts/dtbs-compare.sh Outdated
@qualcomm-ai-code-review-assistant

Copy link
Copy Markdown

Qualcomm AI Review

Click to expand Deep Code Review

Qualcomm AI Deep Code Review Assistant

Code Review: qcom-kernel-platform-backport Skill Addition


Key Findings Summary

Total Issues Found: 8

Severity Breakdown:

  • 🔴 Critical/High: 2 issues (1 workflow bug, 1 security vulnerability)
  • 🟡 Medium: 5 issues (4 bugs, 1 best practice)
  • 🟢 Low: 1 issue (configuration flexibility)

Category Distribution:

  • Security vulnerabilities: 1
  • Functional bugs: 6
  • Best practices: 1

Quick Statistics:
This PR introduces a comprehensive kernel backporting skill with 935 lines of code across documentation and shell scripts. While the implementation demonstrates solid bash practices and thorough documentation, several critical issues require attention before production use, particularly around workflow correctness and security.


Detailed Analysis

1. Incorrect Conflict Resolution Workflow

Severity: High
Category: Bug
Location: skills/qcom-kernel-platform-backport/scripts/backport-commit.sh:54-67

Problem Description

The script provides logically incorrect instructions for handling cherry-pick conflicts. After a conflict occurs, users are instructed to run git cherry-pick --continue and then "re-run with the same arguments":

echo "Cherry-pick failed. Please resolve conflicts, then run:"
echo "  git cherry-pick --continue"
echo "Then re-run with the same arguments"

Impact Analysis

  • Workflow Failure: After git cherry-pick --continue completes, the commit is already finalized
  • User Confusion: Re-running the script attempts to cherry-pick the same commit again, causing duplicate commits or errors
  • Broken Automation: Any backport encountering merge conflicts will fail to complete correctly
  • Data Integrity: Risk of duplicate or malformed commits in the target branch

Recommended Fix

Remove the misleading re-run instruction and provide correct guidance for manual commit message amendment:

echo "Cherry-pick failed. Please resolve conflicts, then run:"
echo "  git cherry-pick --continue"
echo ""
echo "After the cherry-pick completes, manually amend the commit message to add:"
echo "  (cherry picked from commit $commit)"
echo "  (backported from $upstream_branch)"
echo ""
echo "Use: git commit --amend"

Implementation Guidance:

  • Update user documentation to reflect the manual amendment step
  • Consider adding a post-cherry-pick hook to automate message formatting
  • Add validation to detect if a commit has already been cherry-picked

2. Insecure Temporary File Creation

Severity: High
Category: Security
Location: skills/qcom-kernel-platform-backport/scripts/check-series.sh:86-99

Problem Description

The script writes checkpatch output to a hardcoded path without secure temporary file creation:

./scripts/checkpatch.pl --no-tree --terse --file $file \
    > /tmp/checkpatch-series.log 2>&1

Impact Analysis

  • Race Condition: Multiple concurrent executions corrupt each other's output
  • Symlink Attack: Attacker could create a symlink at /tmp/checkpatch-series.log pointing to sensitive files (e.g., /etc/passwd), causing the script to overwrite them
  • Permission Issues: Fails in multi-user environments with restrictive umask settings
  • Resource Leak: No cleanup mechanism leads to accumulation of stale log files
  • Compliance Risk: Violates secure coding standards for temporary file handling

Recommended Fix

Replace hardcoded path with secure temporary file creation using mktemp:

# Create secure temporary file
checkpatch_log=$(mktemp) || {
    echo "Failed to create temporary file"
    exit 1
}

# Ensure cleanup on exit
trap 'rm -f "$checkpatch_log"' EXIT INT TERM

# Use the secure temporary file
./scripts/checkpatch.pl --no-tree --terse --file $file \
    > "$checkpatch_log" 2>&1

if [ -s "$checkpatch_log" ]; then
    echo "  Checkpatch warnings/errors:"
    cat "$checkpatch_log"
fi

Additional Context

  • Reference: CWE-377: Insecure Temporary File
  • The trap command ensures cleanup even if the script exits unexpectedly
  • mktemp creates files with mode 0600, preventing unauthorized access

3. Unescaped Email Address in Regex Pattern

Severity: Medium
Category: Bug
Location: skills/qcom-kernel-platform-backport/scripts/check-series.sh:74-77

Problem Description

The user's email address is used directly in a grep regex pattern without escaping special characters:

me=$(git config user.email)
if ! git log -1 --format=%B $commit | grep -q "^Signed-off-by:.*<${me}>"; then
    echo "  Missing Signed-off-by for $me"
fi

Email addresses commonly contain regex metacharacters like . (matches any character) and + (one or more of preceding character).

Impact Analysis

  • False Positives: Email john.doe@example.com would match johnXdoe@exampleYcom
  • False Negatives: Email user+tag@domain.com could cause pattern matching failures
  • Validation Bypass: Incorrect Signed-off-by validation undermines commit tracking
  • Compliance Issues: Inaccurate DCO (Developer Certificate of Origin) verification

Recommended Fix

Escape regex metacharacters before using the email in pattern matching:

me=$(git config user.email)
# Escape regex special characters in email
me_escaped=$(printf '%s\n' "$me" | sed 's/[.[\*^$()+?{|]/\\&/g')

if ! git log -1 --format=%B $commit | grep -q "^Signed-off-by:.*<${me_escaped}>"; then
    echo "  Missing Signed-off-by for $me"
fi

4. Missing Git Configuration Validation

Severity: Medium
Category: Bug
Location: skills/qcom-kernel-platform-backport/scripts/check-series.sh:39-41

Problem Description

The script retrieves the user's email but doesn't validate that it exists:

me=$(git config user.email)

If user.email is not configured, $me becomes empty, causing silent failures in subsequent validation checks.

Impact Analysis

  • Silent Failures: Signed-off-by validation produces false positives for every commit
  • Skipped Checks: Authorship validation is silently bypassed
  • User Confusion: Cryptic errors without clear indication of the root cause
  • Workflow Disruption: Users waste time debugging symptoms instead of addressing the configuration issue

Recommended Fix

Add explicit validation with a clear error message:

me=$(git config user.email)
if [ -z "$me" ]; then
    echo "Error: Git user.email is not configured"
    echo "Please run: git config --global user.email 'your.email@example.com'"
    exit 1
fi

5. Unescaped Path Variable in Sed Pattern

Severity: Medium
Category: Bug
Location: skills/qcom-kernel-platform-backport/scripts/dtbs-compare.sh:83-84

Problem Description

The $outdir variable from mktemp -d is used directly in a sed regex pattern:

outdir=$(mktemp -d)
# Later in the code:
sed -E "s#^$outdir/#OUT/#"

Paths from mktemp typically contain . characters (e.g., /tmp/tmp.XXXXXXXXXX), which are regex metacharacters matching any single character.

Impact Analysis

  • Incorrect Substitution: Path /tmp/tmp.abc123/ could incorrectly match /tmp/tmpXabc123/
  • Output Corruption: DTB comparison results may show wrong file paths
  • Debugging Difficulty: Subtle path mismatches are hard to detect and diagnose

Recommended Fix

Escape regex metacharacters in the path variable:

outdir=$(mktemp -d)
# Escape regex special characters
outdir_escaped=$(printf '%s\n' "$outdir" | sed 's/[.[\*^$()+?{|]/\\&/g')

# Use escaped version in sed pattern
sed -E "s#^$outdir_escaped/#OUT/#"

6. Documentation Parameter Mismatch

Severity: Medium
Category: Bug
Location: skills/qcom-kernel-platform-backport/scripts/dtbs-compare.sh:13-14

Problem Description

The usage documentation shows an incorrect parameter name:

# Documentation shows:
--glob 'qcom/*.dts'

# But the script actually implements:
--subdir qcom

Impact Analysis

  • User Errors: Following documentation results in "unknown argument" errors
  • Workflow Disruption: Users must read source code to discover correct usage
  • Support Burden: Increased support requests and confusion
  • Trust Issues: Documentation inconsistencies undermine confidence in the tool

Recommended Fix

Update the usage documentation to reflect the actual implementation:

# Usage: dtbs-compare.sh [options] <old-ref> <new-ref>
# Options:
#   --subdir <dir>    Compare only DTBs in the specified subdirectory
#                     Example: --subdir qcom

7. Non-Portable Command Usage

Severity: Medium
Category: Best Practices
Location: skills/qcom-kernel-platform-backport/scripts/find-candidates.sh:158

Problem Description

The script uses the tac command to reverse commit order:

git log --format="%H %s" $range | tac

The tac command is part of GNU coreutils and is not POSIX-standard, making it unavailable on BSD systems, Alpine Linux, and minimal container images.

Impact Analysis

  • Portability Issues: Script fails on non-GNU systems with "command not found" errors
  • Container Compatibility: Breaks in minimal Docker images (alpine, distroless)
  • CI/CD Failures: May fail in diverse build environments
  • User Friction: Requires additional package installation on some systems

Recommended Fix

Replace tac with a POSIX-compliant awk alternative:

# Instead of: git log --format="%H %s" $range | tac
# Use:
git log --format="%H %s" $range | awk '{lines[NR]=$0} END {for(i=NR;i>0;i--) print lines[i]}'

Additional Context

This awk solution stores all lines in an array and prints them in reverse order, providing identical functionality while maintaining POSIX compliance across all Unix-like systems.


8. Hardcoded Remote Name Assumption

Severity: Low
Category: Bug
Location: skills/qcom-kernel-platform-backport/scripts/find-candidates.sh:140-147

Problem Description

The script hardcodes the linux-next remote name when checking commit ancestry:

if git merge-base --is-ancestor $commit refs/remotes/linux-next/master 2>/dev/null; then
    status="in-next"
fi

Users who add the linux-next remote with a different name (e.g., next, upstream-next) will see incorrect status classifications.

Impact Analysis

  • Incorrect Status: Commits marked as "unmerged" when they actually exist in linux-next
  • Workflow Confusion: Users may attempt to backport commits that are already queued
  • Flexibility Loss: Forces users to adopt a specific remote naming convention

Recommended Fix

Use the user-configurable --upstream parameter to derive the remote name:

# Extract the first upstream ref from the --upstream parameter
upstream_ref="${upstream_refs[0]}"

# Check if commit is in the upstream branch
if git merge-base --is-ancestor $commit "$upstream_ref" 2>/dev/null; then
    status="in-next"
fi

Positive Aspects

This skill demonstrates several commendable practices:

  • Comprehensive Documentation: 327 lines of detailed usage instructions with clear examples
  • Proper Error Handling: Consistent use of set -euo pipefail for robust script execution
  • Modular Design: Well-separated concerns across four focused scripts
  • Git Best Practices: Effective use of worktrees and temporary branches
  • Clear Structure: Logical organization with proper separation of scripts and documentation
  • Executable Permissions: Correctly configured file permissions for all scripts

Summary

The qcom-kernel-platform-backport skill provides valuable automation for kernel backporting workflows, but requires attention to several critical issues before production deployment. The two high-severity issues—incorrect conflict resolution instructions and insecure temporary file handling—should be addressed immediately as they will cause workflow failures and introduce security vulnerabilities. The five medium-severity issues impact reliability and portability across different environments and should be resolved to ensure robust operation. The low-severity issue is a quality-of-life improvement that enhances flexibility.

Once these recommendations are implemented, this skill will provide a solid foundation for automating complex kernel backporting workflows with appropriate safety checks and validation mechanisms.


⚠️ This review was generated using AI assistance. Please verify all suggestions before applying.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Qualcomm AI Review

Comment thread skills/qcom-kernel-platform-backport/scripts/backport-commit.sh
Comment thread skills/qcom-kernel-platform-backport/scripts/check-series.sh Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Comment thread skills/qcom-kernel-platform-backport/scripts/backport-commit.sh Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Qualcomm AI Review

Comment thread skills/qcom-kernel-platform-backport/scripts/backport-commit.sh
Boards enabled upstream do not work on the qualcomm-linux LTS branch until
their DTS, the SoC dtsi deltas they depend on, their bindings and a handful
of driver fixes are backported. Doing that by hand is repetitive and has a
few traps that are easy to fall into and expensive to find later: a
cherry-pick that silently reassigns authorship, a binding shared with
another SoC that regresses its DTBs, a driver enabled in defconfig but
absent from the BSP module list, and CI checkers that fail structurally on
any adapted backport.

Add a skill that walks the whole flow — candidate triage across mainline,
linux-next and the qcom SoC tree, authorship-preserving cherry-picks with
the UPSTREAM/BACKPORT/FROMGIT prefixes, a cross-platform CHECK_DTBS
regression check, hardware validation, and the pull request — plus four
helper scripts and a reference on what each Kernel Checker enforces and
which of its failures a backport series cannot avoid.

The scripts were exercised against a real 30-commit series backporting the
Arduino UNO Q (qrb2210-arduino-imola) onto qcom-6.18.y, then run end to end
on a second, unfamiliar platform — the Arduino VENTUNO Q
(monaco-arduino-monza, QCS8300) — which produced a 36-commit series booted
on hardware in the lab. That second run drove the following:

  - backport-commit.sh reports a missing Link: at pick time instead of
    leaving it for check-series.sh, deriving one from Message-ID: when
    present. lore.kernel.org is behind Anubis bot protection, so the
    fallback documents recovering the message-id from patchwork, with the
    two checks that tell a genuine hit from a same-subject repost.
  - check-series.sh audits the prefix against the diff. A cherry-pick can
    diverge from the posted patch without conflicting — rename detection
    moves it to another file, or the 3-way merge drops an already-present
    hunk — leaving a BACKPORT wearing an UPSTREAM label that only
    check-patch-compliance would catch. This found exactly that in the
    VENTUNO Q series.
  - dtbs-compare.sh gained --match for a family-scoped run, since a full
    vendor sweep is serial in dt-validate and takes about an hour per side.
    It also no longer counts a newly added board's inherited SoC dtsi
    warnings as regressions, which had made it fail the very case the skill
    exists for.
  - SKILL.md documents the downstream qcom.config and prune.config
    fragments that override defconfig in meta-qcom builds — one made a
    QCLINUX defconfig commit redundant, the other silently disabled a
    driver the board needed — plus a scripted reorder guarded against
    dropping commits, and that a deferred consumer names its supplier,
    which is what a missing module in the curated BSP list looks like.

Assisted-by: Claude Code:claude-fable-5
Signed-off-by: Ricardo Salveti <ricardo.salveti@oss.qualcomm.com>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Qualcomm AI Review

Comment thread skills/qcom-kernel-platform-backport/scripts/backport-commit.sh
Comment thread skills/qcom-kernel-platform-backport/SKILL.md
Comment thread skills/qcom-kernel-platform-backport/scripts/check-series.sh
@ricardosalveti

Copy link
Copy Markdown
Contributor Author

Skill used to generate qualcomm-linux/kernel#1013.

@ricardosalveti
Ricardo Salveti (ricardosalveti) merged commit c6cccec into qualcomm-linux:main Aug 25, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants