Skip to content

[Deepin-Kernel-SIG] [linux 6.18.y] [Deepin] lib/fonts: cjktty: Remove Unicode bidirectional control characters fr…#1650

Merged
opsiff merged 1 commit into
deepin-community:linux-6.18.yfrom
opsiff:linux-6.18.y-2026-04-27-fix-gcc15
Apr 27, 2026
Merged

[Deepin-Kernel-SIG] [linux 6.18.y] [Deepin] lib/fonts: cjktty: Remove Unicode bidirectional control characters fr…#1650
opsiff merged 1 commit into
deepin-community:linux-6.18.yfrom
opsiff:linux-6.18.y-2026-04-27-fix-gcc15

Conversation

@opsiff
Copy link
Copy Markdown
Member

@opsiff opsiff commented Apr 27, 2026

…om comments

GCC's -Wbidi-chars option (enabled by default since GCC 12) detects potentially dangerous Unicode bidirectional text control characters that could be exploited in "Trojan Source" attacks (CVE-2021-42574).

The font_cjk_16x16.h/font_cjk_32x32.h header files contained actual Unicode bidirectional control characters embedded within comments as glyph representations:

  • U+200E (LEFT-TO-RIGHT MARK)
  • U+200F (RIGHT-TO-LEFT MARK)
  • U+202C (POP DIRECTIONAL FORMATTING)
  • U+2069 (POP DIRECTIONAL ISOLATE)

Replace these invisible control characters with their standard Unicode abbreviations (LRM, RLM, PDF, PDI) enclosed in parentheses. This preserves the documentary intent of the comments while eliminating the build failure caused by -Werror=bidi-chars.

This change is necessary and appropriate because GCC 12 and later versions introduced the -Wbidi-chars warning (enabled by default) specifically to mitigate "Trojan Source" attacks as described in CVE-2021-42574. These attacks exploit Unicode bidirectional override characters to make source code appear different from how it actually executes, potentially hiding malicious logic within seemingly benign code. While the characters in this font header file are legitimately used as glyph data representations in comments rather than for malicious purposes, the compiler cannot distinguish intent and correctly flags them as a potential security risk. The kernel build system treats all warnings as errors (-Werror), causing the build to fail. By replacing the actual invisible control characters with their human-readable abbreviations (LRM for Left-to-Right Mark, RLM for Right-to-Left Mark, PDF for Pop Directional Formatting, and PDI for Pop Directional Isolate), we maintain the original documentation purpose of identifying which Unicode codepoint each glyph represents while ensuring the code compiles cleanly and passes security-focused static analysis.

Link: https://www.cve.org/CVERecord?id=CVE-2021-42574
Link: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wbidi-chars
Link: https://unicode.org/reports/tr9/

[Only fix 16x16]
(cherry picked from commit 380793f)

Summary by Sourcery

Bug Fixes:

  • Prevent build failures by removing Unicode bidirectional control characters from font_cjk_16x16.h comments and replacing them with readable abbreviations.

…om comments

GCC's -Wbidi-chars option (enabled by default since GCC 12) detects
potentially dangerous Unicode bidirectional text control characters that
could be exploited in "Trojan Source" attacks (CVE-2021-42574).

The font_cjk_16x16.h/font_cjk_32x32.h header files contained actual
Unicode bidirectional control characters embedded within comments as
glyph representations:
  - U+200E (LEFT-TO-RIGHT MARK)
  - U+200F (RIGHT-TO-LEFT MARK)
  - U+202C (POP DIRECTIONAL FORMATTING)
  - U+2069 (POP DIRECTIONAL ISOLATE)

Replace these invisible control characters with their standard Unicode
abbreviations (LRM, RLM, PDF, PDI) enclosed in parentheses. This
preserves the documentary intent of the comments while eliminating the
build failure caused by -Werror=bidi-chars.

This change is necessary and appropriate because GCC 12 and later versions
introduced the -Wbidi-chars warning (enabled by default) specifically to
mitigate "Trojan Source" attacks as described in CVE-2021-42574. These
attacks exploit Unicode bidirectional override characters to make source
code appear different from how it actually executes, potentially hiding
malicious logic within seemingly benign code. While the characters in this
font header file are legitimately used as glyph data representations in
comments rather than for malicious purposes, the compiler cannot distinguish
intent and correctly flags them as a potential security risk. The kernel
build system treats all warnings as errors (-Werror), causing the build
to fail. By replacing the actual invisible control characters with their
human-readable abbreviations (LRM for Left-to-Right Mark, RLM for
Right-to-Left Mark, PDF for Pop Directional Formatting, and PDI for Pop
Directional Isolate), we maintain the original documentation purpose of
identifying which Unicode codepoint each glyph represents while ensuring
the code compiles cleanly and passes security-focused static analysis.

Link: https://www.cve.org/CVERecord?id=CVE-2021-42574
Link: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wbidi-chars
Link: https://unicode.org/reports/tr9/
Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Only fix 16x16]
(cherry picked from commit 380793f)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Apr 27, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR removes actual Unicode bidirectional control characters from comments in the CJK 16x16 font header and replaces them with human-readable abbreviations, resolving GCC -Wbidi-chars build failures while preserving the documentation intent.

Flow diagram for GCC -Wbidi-chars handling after comment cleanup

flowchart LR
    OldSrc[font_cjk_16x16.h with bidi control characters in comments]
    NewSrc[font_cjk_16x16.h with LRM/RLM/PDF/PDI abbreviations in comments]

    OldSrc --> GCCWarn[GCC with -Wbidi-chars detects bidi control characters]
    GCCWarn --> Werror[Kernel build with -Werror converts warning to error]
    Werror --> BuildFail[Kernel build fails]

    NewSrc --> GCCNoWarn[GCC with -Wbidi-chars detects no bidi control characters]
    GCCNoWarn --> BuildPass[Kernel build succeeds]
Loading

File-Level Changes

Change Details Files
Replace invisible Unicode bidi control characters in font comments with textual abbreviations to satisfy GCC -Wbidi-chars.
  • Update the comment for U+200E to use '(LRM)' instead of the literal LEFT-TO-RIGHT MARK character.
  • Update the comment for U+200F to use '(RLM)' instead of the literal RIGHT-TO-LEFT MARK character.
  • Update the comment for U+202C to use '(PDF)' instead of the literal POP DIRECTIONAL FORMATTING character.
  • Update the comment for U+2069 to use '(PDI)' instead of the literal POP DIRECTIONAL ISOLATE character.
lib/fonts/font_cjk_16x16.h

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot deepin-ci-robot requested a review from myml April 27, 2026 07:14
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Removes invisible Unicode bidirectional control characters from comments in the CJK 16x16 font header to avoid GCC 12+ -Wbidi-chars warnings being promoted to errors during kernel builds, while preserving the intent of documenting the affected codepoints.

Changes:

  • Replace embedded bidi control characters in font_cjk_16x16.h comments with readable abbreviations: (LRM), (RLM), (PDF), (PDI).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Avenger-285714
Copy link
Copy Markdown
Member

/approve

@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Avenger-285714

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@opsiff opsiff merged commit 0f44649 into deepin-community:linux-6.18.y Apr 27, 2026
14 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants