Skip to content

Commit bbe72f1

Browse files
Avenger-285714opsiff
authored andcommitted
lib/fonts: cjktty: Remove Unicode bidirectional control characters from 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>
1 parent 41af78e commit bbe72f1

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

lib/fonts/font_cjk_16x16.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24617,10 +24617,10 @@
2461724617
/* 8205 0x200d "‍" */
2461824618
0xaa,0x00,0x9e,0x02,0x84,0x08,0x90,0x1e,0x80,0x00,0x80,0x02,0x82,0x01,0x80,0x55,
2461924619
0xaa,0x01,0x44,0x45,0x54,0x55,0x6c,0x45,0x00,0x41,0x40,0x41,0x40,0x81,0x00,0x55,
24620-
/* 8206 0x200e "‎" */
24620+
/* 8206 0x200e (LRM) */
2462124621
0xaa,0x00,0x80,0x00,0xc7,0x44,0xc7,0x45,0xf4,0x00,0x80,0x00,0x80,0x00,0x80,0x55,
2462224622
0xaa,0x01,0x00,0x01,0x22,0xb7,0x2a,0x23,0xa2,0x01,0x00,0x01,0x00,0x01,0x00,0x55,
24623-
/* 8207 0x200f "‏" */
24623+
/* 8207 0x200f (RLM) */
2462424624
0xaa,0x00,0x80,0x00,0xf2,0x4a,0xf2,0x52,0xcb,0x00,0x80,0x00,0x80,0x00,0x80,0x55,
2462524625
0xaa,0x01,0x00,0x01,0x22,0x37,0x2a,0x23,0xa2,0x01,0x00,0x01,0x00,0x01,0x00,0x55,
2462624626
/* 8208 0x2010 "‐" */
@@ -24707,7 +24707,7 @@
2470724707
/* 8235 0x202b */
2470824708
0xaa,0x00,0x80,0x00,0xf2,0x4a,0xf2,0x52,0xcb,0x00,0x80,0x00,0x80,0x00,0x80,0x55,
2470924709
0xaa,0x01,0x00,0x01,0x1e,0x11,0x1e,0x11,0xde,0x01,0x00,0x01,0x00,0x01,0x00,0x55,
24710-
/* 8236 0x202c "‬" */
24710+
/* 8236 0x202c (PDF) */
2471124711
0xaa,0x00,0x80,0x00,0xf3,0x4a,0xf2,0x42,0xc3,0x00,0x80,0x00,0x80,0x00,0x80,0x55,
2471224712
0xaa,0x01,0x00,0x01,0x9e,0x51,0x5e,0x51,0x90,0x01,0x00,0x01,0x00,0x01,0x00,0x55,
2471324713
/* 8237 0x202d */
@@ -24890,7 +24890,7 @@
2489024890
/* 8296 0x2068 */
2489124891
0xaa,0x00,0x80,0x00,0xb9,0x22,0xb9,0x20,0xa3,0x00,0x80,0x00,0x80,0x00,0x80,0x55,
2489224892
0xaa,0x01,0x00,0x01,0xdc,0x09,0x88,0x49,0x9c,0x01,0x00,0x01,0x00,0x01,0x00,0x55,
24893-
/* 8297 0x2069 "⁩" */
24893+
/* 8297 0x2069 (PDI) */
2489424894
0xaa,0x00,0x80,0x00,0xf3,0x4a,0xf2,0x42,0xc3,0x00,0x80,0x00,0x80,0x00,0x80,0x55,
2489524895
0xaa,0x01,0x00,0x01,0x9c,0x49,0x48,0x49,0x9c,0x01,0x00,0x01,0x00,0x01,0x00,0x55,
2489624896
/* 8298 0x206a "" */

0 commit comments

Comments
 (0)