{"id":2645,"date":"2026-03-17T19:41:42","date_gmt":"2026-03-18T01:41:42","guid":{"rendered":"https:\/\/embeddedor.com\/blog\/?p=2645"},"modified":"2026-04-14T15:50:12","modified_gmt":"2026-04-14T21:50:12","slug":"here-to-fix-what-i-break-fixing-a-2-year-old-bug-in-the-linux-kernel","status":"publish","type":"post","link":"https:\/\/embeddedor.com\/blog\/2026\/03\/17\/here-to-fix-what-i-break-fixing-a-2-year-old-bug-in-the-linux-kernel\/","title":{"rendered":"Here to fix what I break: Fixing a 2-year-old bug in the Linux kernel"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"502\" src=\"https:\/\/embeddedor.com\/blog\/wp-content\/uploads\/2026\/03\/Screenshot-from-2026-03-17-18-19-25-700x502.png\" alt=\"\" class=\"wp-image-2647\" srcset=\"https:\/\/embeddedor.com\/blog\/wp-content\/uploads\/2026\/03\/Screenshot-from-2026-03-17-18-19-25-700x502.png 700w, https:\/\/embeddedor.com\/blog\/wp-content\/uploads\/2026\/03\/Screenshot-from-2026-03-17-18-19-25-300x215.png 300w, https:\/\/embeddedor.com\/blog\/wp-content\/uploads\/2026\/03\/Screenshot-from-2026-03-17-18-19-25-768x551.png 768w, https:\/\/embeddedor.com\/blog\/wp-content\/uploads\/2026\/03\/Screenshot-from-2026-03-17-18-19-25-800x574.png 800w, https:\/\/embeddedor.com\/blog\/wp-content\/uploads\/2026\/03\/Screenshot-from-2026-03-17-18-19-25.png 986w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>While reviewing <a href=\"https:\/\/lore.kernel.org\/linux-hardening\/bde61932-9c7e-4139-8d6a-8059c205a217@embeddedor.com\/T\/#t\" target=\"_blank\" rel=\"noreferrer noopener\">one<\/a> of the patches sent to the <a href=\"https:\/\/lore.kernel.org\/linux-hardening\/\" target=\"_blank\" rel=\"noreferrer noopener\">linux-hardening<\/a> list this afternoon, I spotted a bug I introduced in the same code two years ago (on March 5 2024, to be precise).<br><br>Over nearly a decade contributing to the Linux kernel, I&#8217;ve discovered and fixed many years-old bugs, and it&#8217;s always a special feeling. This time is no different. Here to fix what I break! &#x1f64c;&#x1f3fc;<br><br>&#8220;struct nx842_crypto_header is declared with the __packed attribute,<br>however the fields grouped with struct_group_tagged() were not packed.<br>This caused the grouped header portion of the structure to lose the<br>packed layout guarantees of the containing structure.<br><br>Fix this by replacing struct_group_tagged() with __struct_group(&#8230;,<br>&#8230;, __packed, &#8230;) so the grouped fields are packed, and the original<br>layout is preserved, restoring the intended packed layout of the<br>structure.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Before changes:<br>struct nx842_crypto_header {<br>\tunion {<br>\t\tstruct {<br>\t\t\t__be16     magic;                \/*     0     2 *\/<br>\t\t\t__be16     ignore;               \/*     2     2 *\/<br>\t\t\tu8         groups;               \/*     4     1 *\/<br>\t\t};                                       \/*     0     6 *\/<br>\t\tstruct nx842_crypto_header_hdr hdr;      \/*     0     6 *\/<br>\t};                                               \/*     0     6 *\/<br>\tstruct nx842_crypto_header_group group&#91;];        \/*     6     0 *\/<br><br>\t\/* size: 6, cachelines: 1, members: 2 *\/<br>\t\/* last cacheline: 6 bytes *\/<br>} __attribute__((__packed__));<br><br>After changes:<br>struct nx842_crypto_header {<br>\tunion {<br>\t\tstruct {<br>\t\t\t__be16     magic;                \/*     0     2 *\/<br>\t\t\t__be16     ignore;               \/*     2     2 *\/<br>\t\t\tu8         groups;               \/*     4     1 *\/<br>\t\t} __attribute__((__packed__));           \/*     0     5 *\/<br>\t\tstruct nx842_crypto_header_hdr hdr;      \/*     0     5 *\/<br>\t};                                               \/*     0     5 *\/<br>\tstruct nx842_crypto_header_group group&#91;];        \/*     5     0 *\/<br><br>\t\/* size: 5, cachelines: 1, members: 2 *\/<br>\t\/* last cacheline: 5 bytes *\/<br>} __attribute__((__packed__));<br><br>\"<\/code><\/pre>\n\n\n\n<p>This should be applied to multiple stable trees, soon.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Patch review: <a href=\"https:\/\/lore.kernel.org\/linux-hardening\/bde61932-9c7e-4139-8d6a-8059c205a217@embeddedor.com\/T\/#t\" target=\"_blank\" rel=\"noreferrer noopener\">crypto: nx &#8211; annotate struct nx842_crypto_header with __counted_by<\/a>&#x1f427;<\/li>\n\n\n\n<li>Bugfix: <a href=\"https:\/\/lore.kernel.org\/linux-hardening\/abnmUvHzhgS9xA-m@kspp\/\" target=\"_blank\" rel=\"noreferrer noopener\">[PATCH] crypto: nx &#8211; Fix packed layout in struct nx842_crypto_header<\/a> &#x1f427;<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>While reviewing one of the patches sent to the linux-hardening list this afternoon, I spotted a bug I introduced in the same code two years ago (on March 5 2024, to be precise). Over nearly a decade contributing to the Linux kernel, I&#8217;ve discovered and fixed many years-old bugs, and it&#8217;s always a special feeling&#8230;.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[31,13,18,9],"tags":[],"class_list":["post-2645","post","type-post","status-publish","format-standard","hentry","category-wfamnae","category-kernel-self-protection-project","category-linux-kernel-bugs","category-linux-kernel-hardening"],"_links":{"self":[{"href":"https:\/\/embeddedor.com\/blog\/wp-json\/wp\/v2\/posts\/2645","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/embeddedor.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/embeddedor.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/embeddedor.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/embeddedor.com\/blog\/wp-json\/wp\/v2\/comments?post=2645"}],"version-history":[{"count":10,"href":"https:\/\/embeddedor.com\/blog\/wp-json\/wp\/v2\/posts\/2645\/revisions"}],"predecessor-version":[{"id":2656,"href":"https:\/\/embeddedor.com\/blog\/wp-json\/wp\/v2\/posts\/2645\/revisions\/2656"}],"wp:attachment":[{"href":"https:\/\/embeddedor.com\/blog\/wp-json\/wp\/v2\/media?parent=2645"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/embeddedor.com\/blog\/wp-json\/wp\/v2\/categories?post=2645"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/embeddedor.com\/blog\/wp-json\/wp\/v2\/tags?post=2645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}