Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2220037/?format=api
{ "id": 2220037, "url": "http://patchwork.ozlabs.org/api/patches/2220037/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/20260406023100.95279-1-S4210155@student.rmit.edu.au/", "project": { "id": 18, "url": "http://patchwork.ozlabs.org/api/projects/18/?format=api", "name": "U-Boot", "link_name": "uboot", "list_id": "u-boot.lists.denx.de", "list_email": "u-boot@lists.denx.de", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260406023100.95279-1-S4210155@student.rmit.edu.au>", "list_archive_url": null, "date": "2026-04-06T02:30:27", "name": "common: cli_hush: fix console_buffer overflow on boot retry", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "743cd70da0e7b6a800928b22bb065b48e6af4239", "submitter": { "id": 92995, "url": "http://patchwork.ozlabs.org/api/people/92995/?format=api", "name": "Ngo Luong Thanh Tra", "email": "ngotra27101996@gmail.com" }, "delegate": { "id": 3651, "url": "http://patchwork.ozlabs.org/api/users/3651/?format=api", "username": "trini", "first_name": "Tom", "last_name": "Rini", "email": "trini@ti.com" }, "mbox": "http://patchwork.ozlabs.org/project/uboot/patch/20260406023100.95279-1-S4210155@student.rmit.edu.au/mbox/", "series": [ { "id": 498818, "url": "http://patchwork.ozlabs.org/api/series/498818/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/list/?series=498818", "date": "2026-04-06T02:30:27", "name": "common: cli_hush: fix console_buffer overflow on boot retry", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/498818/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2220037/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2220037/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<u-boot-bounces@lists.denx.de>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=d8a6kqI/;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org)", "phobos.denx.de;\n dmarc=pass (p=none dis=none) header.from=gmail.com", "phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de", "phobos.denx.de;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.b=\"d8a6kqI/\";\n\tdkim-atps=neutral", "phobos.denx.de;\n dmarc=pass (p=none dis=none) header.from=gmail.com", "phobos.denx.de;\n spf=pass smtp.mailfrom=ngotra27101996@gmail.com" ], "Received": [ "from phobos.denx.de (unknown\n [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fpwFR3Lt8z1yFt\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 06 Apr 2026 13:44:59 +1000 (AEST)", "from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 4BBAD83936;\n\tMon, 6 Apr 2026 05:44:46 +0200 (CEST)", "by phobos.denx.de (Postfix, from userid 109)\n id 2EB0283E36; Mon, 6 Apr 2026 04:31:15 +0200 (CEST)", "from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com\n [IPv6:2607:f8b0:4864:20::1031])\n (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id 881EC8352B\n for <u-boot@lists.denx.de>; Mon, 6 Apr 2026 04:31:12 +0200 (CEST)", "by mail-pj1-x1031.google.com with SMTP id\n 98e67ed59e1d1-35da9c0c007so3248275a91.2\n for <u-boot@lists.denx.de>; Sun, 05 Apr 2026 19:31:12 -0700 (PDT)", "from MacBookAir.STASGS.RMIT.EDU.VN ([103.253.89.32])\n by smtp.gmail.com with ESMTPSA id\n 98e67ed59e1d1-35dd35f7229sm12887670a91.7.2026.04.05.19.31.08\n (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);\n Sun, 05 Apr 2026 19:31:10 -0700 (PDT)" ], "X-Spam-Checker-Version": "SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de", "X-Spam-Level": "", "X-Spam-Status": "No, score=-0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,\n DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_GMAIL_RCVD,\n FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_BLOCKED,\n SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1775442670; x=1776047470; darn=lists.denx.de;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:from:to:cc:subject:date:message-id:reply-to;\n bh=G7Jkx3XBhDlCbzTBjfR/ATBSo9c1w0FbxqMEFfgSEVY=;\n b=d8a6kqI/uxp81saLdMT52GnlRjLXGoArhMziRnunr7bs9EDff5ZFb9toAd4dzbOo05\n jZTT6PTEXimrWOhuHZHrZgJmdq09pSZ3saZYxRp87bapyP0+hY7h7YnabjAW4l9Fj7yG\n lyTSnKiwxPgHt06cMR33mW9txwArqlY4ZkHl7Zf8uZfEeIUBuJ75LDiJGOh5Bdyrfs4n\n tS+NX1JLdeDSgFoleKAsPaGyyV91GPQ9ozCGTCad1kMqzHzd0QhdttdFn86ebItxE6Lh\n FHlxmVYxeLN771ZWFtbqDbwm7JrY+rsH2aWrPJiyzRaZwvT8tW7LAajFUCVXfr8zqEvr\n irfg==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1775442670; x=1776047470;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n :message-id:reply-to;\n bh=G7Jkx3XBhDlCbzTBjfR/ATBSo9c1w0FbxqMEFfgSEVY=;\n b=CoUFRC5IUEN0A4kXqc9ojFghjEpdJIwms8VRVZrstM/J0L9lCsqIDisPQr0ISDlhVI\n QZkqwmCWC+ZZi92ZU5sF/pR/iO6ORvQBHwzjBE5yNZtE8D4BLpsZiCCquFkJlGr6l9u2\n LO82dEOmwaN5uUlVVpNM/smY7+XiPw4d0bpp3+M+YUv4KAc9D5/Yey0jHORTe5w+lMVx\n mk/zH8Nc07rzEuO+c1Qz3vuczJf7ceS7al6rhIHQrsPSY4HgLcLd9L+BVaroL3aUPi5x\n +pJUIPSZtV9i4KrxiFf+XOIDAagLALWUxmjWOrdMd5OL8M6WVjVQvHO7hrEbT3p+oTXp\n hScQ==", "X-Gm-Message-State": "AOJu0YxSBu0Ae2VV2okXix0TVhevVfNzyQKE9L0TjhpcqGAG13g92pLY\n 4qUDxYpuKO0ZlBCQBYo034Xkbn9Z5ouldUg615weMe9+lLvypE/zkCNQ7wa9V+us", "X-Gm-Gg": "AeBDiesDFLyAeqytIsTz2jPOS6YSIQITDZrO7knSlYs/nH1b1/4iGcbnojZzvnoovPR\n aWFd7+lJyz5agaAuSZ+3N98+SzVz7ecc99v/Dcz8J4BfWCC7mpK4k7R550zFa6vOCs/oBtvazQH\n sJzLzul3K59Ihz1CBTWeqfL/aoWompBNBHH+P8vFrV8VDLVSGjjRYUBgk0lpy9vN2foS+FKdd+q\n 3KUDQJtFIo/u3xAnAjgL4lgtC0gYKIKsQbrh7T0wdM+TwF0UF9KZcHAPeWL2PNSBSNux20nnW/Z\n LV0JHz/aBCC6f4CcDOPs4sQjKtbPd8icCq3GBN1mYu6nYs03b0LE4LP3ZQft/YQTxsxnSgRmRLH\n mm17PBdcDClC2brW6g76M/ZoRjMPohHYNH5CZ5v016yKadY0u50gAw6buouOnXgJzkdxV1n1paa\n +mDi2xaqRnlfC0qx0KSViIZh+MNnGxBBcpIuUqI6u3hDqxNwOtFVpaJLBdYfCnbBLTisyA8dThM\n Q==", "X-Received": "by 2002:a17:90b:2e07:b0:35d:a05f:c7eb with SMTP id\n 98e67ed59e1d1-35de68f9e47mr9535062a91.22.1775442670485;\n Sun, 05 Apr 2026 19:31:10 -0700 (PDT)", "From": "Ngo Luong Thanh Tra <ngotra27101996@gmail.com>", "X-Google-Original-From": "Ngo Luong Thanh Tra <S4210155@student.rmit.edu.au>", "To": "u-boot@lists.denx.de", "Cc": "Ngo Luong Thanh Tra <S4210155@student.rmit.edu.au>,\n Alexander Sverdlin <alexander.sverdlin@siemens.com>,\n Casey Connolly <casey.connolly@linaro.org>, Simon Glass <sjg@chromium.org>,\n Tom Rini <trini@konsulko.com>", "Subject": "[PATCH] common: cli_hush: fix console_buffer overflow on boot retry", "Date": "Mon, 6 Apr 2026 09:30:27 +0700", "Message-ID": "<20260406023100.95279-1-S4210155@student.rmit.edu.au>", "X-Mailer": "git-send-email 2.53.0", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-Mailman-Approved-At": "Mon, 06 Apr 2026 05:44:44 +0200", "X-BeenThere": "u-boot@lists.denx.de", "X-Mailman-Version": "2.1.39", "Precedence": "list", "List-Id": "U-Boot discussion <u-boot.lists.denx.de>", "List-Unsubscribe": "<https://lists.denx.de/options/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>", "List-Archive": "<https://lists.denx.de/pipermail/u-boot/>", "List-Post": "<mailto:u-boot@lists.denx.de>", "List-Help": "<mailto:u-boot-request@lists.denx.de?subject=help>", "List-Subscribe": "<https://lists.denx.de/listinfo/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=subscribe>", "Errors-To": "u-boot-bounces@lists.denx.de", "Sender": "\"U-Boot\" <u-boot-bounces@lists.denx.de>", "X-Virus-Scanned": "clamav-milter 0.103.8 at phobos.denx.de", "X-Virus-Status": "Clean" }, "content": "Add const_strcpy() macro to linux/build_bug.h that enforces at\ncompile time that the destination is a writable char array (not char *\nor const char *), the source is a string literal, and the source fits\nin the destination including the NUL terminator.\n\nFix the console_buffer extern declaration in console.h to include the\narray size so sizeof(console_buffer) is valid at call sites.\n\nReplace unbounded strcpy() in cli_hush.c with const_strcpy().\n\nFixes: 657e19f8f2dd (\"cli_hush: support running bootcmd on boot retry\")\n\nChanges in v3:\n- Reject const char * destinations in const_strcpy() (Simon Glass)\n\nSigned-off-by: Ngo Luong Thanh Tra <S4210155@student.rmit.edu.au>\nMade-with: Cursor\n---\n\n common/cli_hush.c | 3 ++-\n include/console.h | 3 ++-\n include/linux/build_bug.h | 24 ++++++++++++++++++++++++\n 3 files changed, 28 insertions(+), 2 deletions(-)", "diff": "diff --git a/common/cli_hush.c b/common/cli_hush.c\nindex 7bd6943d3ed..048577cb40a 100644\n--- a/common/cli_hush.c\n+++ b/common/cli_hush.c\n@@ -84,6 +84,7 @@\n #include <cli_hush.h>\n #include <command.h> /* find_cmd */\n #include <asm/global_data.h>\n+#include <linux/build_bug.h>\n #endif\n #ifndef __U_BOOT__\n #include <ctype.h> /* isalpha, isdigit */\n@@ -1029,7 +1030,7 @@ static void get_user_input(struct in_str *i)\n # ifdef CONFIG_RESET_TO_RETRY\n \t do_reset(NULL, 0, 0, NULL);\n # elif IS_ENABLED(CONFIG_RETRY_BOOTCMD)\n-\tstrcpy(console_buffer, \"run bootcmd\\n\");\n+\tconst_strcpy(console_buffer, \"run bootcmd\\n\");\n # else\n #\terror \"This only works with CONFIG_RESET_TO_RETRY or CONFIG_BOOT_RETRY_COMMAND enabled\"\n # endif\ndiff --git a/include/console.h b/include/console.h\nindex 8d0d7bb8a4c..97ccf5e5f6a 100644\n--- a/include/console.h\n+++ b/include/console.h\n@@ -10,8 +10,9 @@\n #include <stdbool.h>\n #include <stdio_dev.h>\n #include <linux/errno.h>\n+#include <config.h>\n \n-extern char console_buffer[];\n+extern char console_buffer[CONFIG_SYS_CBSIZE + 1];\n \n /* common/console.c */\n int console_init_f(void);\t/* Before relocation; uses the serial stuff */\ndiff --git a/include/linux/build_bug.h b/include/linux/build_bug.h\nindex 20c2dc7f4bd..93f9e50a1c6 100644\n--- a/include/linux/build_bug.h\n+++ b/include/linux/build_bug.h\n@@ -76,4 +76,28 @@\n #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)\n #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)\n \n+/**\n+ * const_strcpy - Copy a string literal to a char array with compile-time checks\n+ * @d: destination char array (must be a char array, not a pointer)\n+ * @s: source string literal\n+ *\n+ * Enforces at compile time that:\n+ * (a) @d is a char array, not a pointer\n+ * (b) @s is a string literal (adjacent string concatenation trick)\n+ * (c) @s fits in @d including the NUL terminator\n+ *\n+ * Uses __builtin_strcpy() so the compiler can optimize the copy into\n+ * immediate stores rather than emitting a function call.\n+ *\n+ * Note: @s is used twice in the macro expansion but this is intentional\n+ * and safe: the (\"\" s \"\") trick enforces at compile time that @s is a\n+ * string literal, and string literals have no side effects.\n+ */\n+#define const_strcpy(d, s) ({\t\t\t\t\t\t\\\n+\tBUILD_BUG_ON(__builtin_types_compatible_p(typeof(d), char *));\t\\\n+\tBUILD_BUG_ON(__builtin_types_compatible_p(typeof(d), const char *));\t\\\n+\tBUILD_BUG_ON(sizeof(d) < sizeof(\"\" s \"\"));\t\t\t\\\n+\t__builtin_strcpy(d, s);\t\t\t\t\t\t\\\n+})\n+\n #endif\t/* _LINUX_BUILD_BUG_H */\n", "prefixes": [] }