Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2074173/?format=api
{ "id": 2074173, "url": "http://patchwork.ozlabs.org/api/patches/2074173/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/20250417132718.2023555-5-jerome.forissier@linaro.org/", "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": "<20250417132718.2023555-5-jerome.forissier@linaro.org>", "list_archive_url": null, "date": "2025-04-17T13:27:00", "name": "[v5,4/4] net-lwip: tftp: add LMB and buffer checks", "commit_ref": "1bc91fa98c020c1f737680cc43a4c7584e17db15", "pull_url": null, "state": "accepted", "archived": false, "hash": "273ad3f13a12d3fa728d97e5689abf673673aef3", "submitter": { "id": 69192, "url": "http://patchwork.ozlabs.org/api/people/69192/?format=api", "name": "Jerome Forissier", "email": "jerome.forissier@linaro.org" }, "delegate": { "id": 157425, "url": "http://patchwork.ozlabs.org/api/users/157425/?format=api", "username": "jforissier", "first_name": "Jerome", "last_name": "Forissier", "email": "jerome.forissier@linaro.org" }, "mbox": "http://patchwork.ozlabs.org/project/uboot/patch/20250417132718.2023555-5-jerome.forissier@linaro.org/mbox/", "series": [ { "id": 453241, "url": "http://patchwork.ozlabs.org/api/series/453241/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/list/?series=453241", "date": "2025-04-17T13:26:56", "name": "NET_LWIP LMB fixes", "version": 5, "mbox": "http://patchwork.ozlabs.org/series/453241/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2074173/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2074173/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=linaro.org header.i=@linaro.org header.a=rsa-sha256\n header.s=google header.b=YJbfr9GX;\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=linaro.org", "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=linaro.org header.i=@linaro.org header.b=\"YJbfr9GX\";\n\tdkim-atps=neutral", "phobos.denx.de;\n dmarc=pass (p=none dis=none) header.from=linaro.org", "phobos.denx.de;\n spf=pass smtp.mailfrom=jerome.forissier@linaro.org" ], "Received": [ "from phobos.denx.de (phobos.denx.de\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))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4ZddxK5rYbz1yJL\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 17 Apr 2025 23:27:49 +1000 (AEST)", "from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 07C608303B;\n\tThu, 17 Apr 2025 15:27:38 +0200 (CEST)", "by phobos.denx.de (Postfix, from userid 109)\n id D9C3782CA8; Thu, 17 Apr 2025 15:27:34 +0200 (CEST)", "from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com\n [IPv6:2a00:1450:4864:20::42d])\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 D3EE28303B\n for <u-boot@lists.denx.de>; Thu, 17 Apr 2025 15:27:32 +0200 (CEST)", "by mail-wr1-x42d.google.com with SMTP id\n ffacd0b85a97d-39c266c1389so565665f8f.1\n for <u-boot@lists.denx.de>; Thu, 17 Apr 2025 06:27:32 -0700 (PDT)", "from builder.. ([2a01:e0a:3cb:7bb0:a07e:3f08:7eef:b036])\n by smtp.gmail.com with ESMTPSA id\n ffacd0b85a97d-39eae977513sm19951605f8f.42.2025.04.17.06.27.31\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Thu, 17 Apr 2025 06:27:31 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,\n DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED,\n SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=linaro.org; s=google; t=1744896452; x=1745501252; darn=lists.denx.de;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=fAuMqpH5iZGzS2bdQo+tUVHECNwVltITZ8VKenT7qZw=;\n b=YJbfr9GXkDBW0Fsew3UADo7Nit6C3suY27wip4ahULWM+8ZrqB7WAXUH/IgEVYEYqj\n S02IaDZDDMHkjxGX+40d5XGLAqXT19nhScLjYr8EsTBXRolwerY5Vg6lQIT+GaLSCRDR\n IHm9JCk/W2hhXlr+kA5d2f4IE3/dXNhtEUJK0XmphbbfR4xX20nqy/zA1tilpyivuLB1\n Q2e9SduOUcwJ4egVPiVeb78CaA9dL/SsJRinmGo4eUuld6RqUeuTgp86Yl41P4dKnxCB\n OxnbLZ+nalQ525JhgWMOYAKNOnlAHlyNqTf9BrutxuMQmVKF3+qpcF4GfClP4muBAeXb\n 7tCA==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1744896452; x=1745501252;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n :subject:date:message-id:reply-to;\n bh=fAuMqpH5iZGzS2bdQo+tUVHECNwVltITZ8VKenT7qZw=;\n b=cSGWS692N30SeWd/Ld8qy65JC04CO660xdFqdbG/c/ekq4J4gmzVqj7X83eN2W9eXZ\n yGID/eaCKcGBA7D2sFKu2IBOBbpfQ4PEyDfpcRCrQYSa9LxYQ3JxIObQebiySQK4QmHY\n bJvLmbV1tGObjrpqkMNo37rLMa0XOMUvf0VaLXFTYVx9nTyhZR7Cr7Rbon953nnV6/0V\n 0NBL2gvGNWhw/84UN3omOG6/Yyx6tdc4c4z90aM+V63GD9y3cBXxnD7gqqKr9qPXcGki\n vBmqus7b6SCiODp+bjVpsRt5XFinYz94WlPT1OE6dnp32cACIUbxLSnDJkFQueMqtroT\n t0Rg==", "X-Gm-Message-State": "AOJu0Yz8lHjxK7VsBWtEw+cno+F0/vUaazceL0VIombHNn+m8GGRPtkH\n 2QmNpGFj1y1OmC8FxadT/UIy8e8P2a20LN8CdiZCjsm9DPTf0yW8KuljaZfiRN9mOJYjuhiQl2M\n gX3Q=", "X-Gm-Gg": "ASbGnctvtUo1T1SLMtngAuvVP7QLILQSPwy/shfJu0kVpPfBLJdUfBxIAnQEdPq8Z3d\n Ydk6gwLj9+qzICMzCrsWFria/o7bMXVoWhQpCV2Ir8Lun6mQ0SZ17pLUISrA2gQHDBgsdmUx/Hw\n ciaSCX+JqVAjKYTwrIHqNlwOHqaGYovqydgXYLztev9jfTaLZnSGZHvldrbOBC+j8d24+NbFmn/\n oA8z0DE6Udj/wRRSPpjv4CvbuHQ7vUO/SRngfvKGYfqOy03fk5mIkTo0kqZmhUBhf0yEIwP8kni\n k3uj7YJHVrTXDN7toY5JR3o1a1xEvjFfVO8oKBlHbOIc6CNrYXd9RpRSJ6Fx", "X-Google-Smtp-Source": "\n AGHT+IGNWSGhAx0arhlTigw2TW/RyHg4t5xhAj+GmJSxq+d2r1ipCI9kKqa6nJFOgz9aWKQHKpnqBQ==", "X-Received": "by 2002:a05:6000:2209:b0:391:39bd:a361 with SMTP id\n ffacd0b85a97d-39ee5b19f89mr4975308f8f.18.1744896452156;\n Thu, 17 Apr 2025 06:27:32 -0700 (PDT)", "From": "Jerome Forissier <jerome.forissier@linaro.org>", "To": "U-Boot mailing list <u-boot@lists.denx.de>", "Cc": "Jerome Forissier <jerome.forissier@linaro.org>,\n Sughosh Ganu <sughosh.ganu@linaro.org>,\n Ilias Apalodimas <ilias.apalodimas@linaro.org>,\n Joe Hershberger <joe.hershberger@ni.com>,\n Ramon Fried <rfried.dev@gmail.com>, Tom Rini <trini@konsulko.com>", "Subject": "[PATCH v5 4/4] net-lwip: tftp: add LMB and buffer checks", "Date": "Thu, 17 Apr 2025 15:27:00 +0200", "Message-ID": "<20250417132718.2023555-5-jerome.forissier@linaro.org>", "X-Mailer": "git-send-email 2.43.0", "In-Reply-To": "<20250417132718.2023555-1-jerome.forissier@linaro.org>", "References": "<20250417132718.2023555-1-jerome.forissier@linaro.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "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": "Legacy NET tftp invokes a store_block() function which performs buffer\nvalidation (LMB, address wrapping). Do the same with NET_LWIP.\n\nSigned-off-by: Jerome Forissier <jerome.forissier@linaro.org>\nSuggested-by: Sughosh Ganu <sughosh.ganu@linaro.org>\nAcked-by: Sughosh Ganu <sughosh.ganu@linaro.org>\n---\n\n(no changes since v3)\n\nChanges in v3:\n- store_block(): add Sphinx-like documentation\n\n net/lwip/tftp.c | 56 +++++++++++++++++++++++++++++++++++++++----------\n 1 file changed, 45 insertions(+), 11 deletions(-)", "diff": "diff --git a/net/lwip/tftp.c b/net/lwip/tftp.c\nindex 123d66b5dba..c7f1420ca0f 100644\n--- a/net/lwip/tftp.c\n+++ b/net/lwip/tftp.c\n@@ -8,6 +8,7 @@\n #include <efi_loader.h>\n #include <image.h>\n #include <linux/delay.h>\n+#include <linux/kconfig.h>\n #include <lwip/apps/tftp_client.h>\n #include <lwip/timeouts.h>\n #include <mapmem.h>\n@@ -31,6 +32,47 @@ struct tftp_ctx {\n \tenum done_state done;\n };\n \n+/**\n+ * store_block() - copy received data\n+ *\n+ * This function is called by the receive callback to copy a block of data\n+ * into its final location (ctx->daddr). Before doing so, it checks if the copy\n+ * is allowed.\n+ *\n+ * @ctx: the context for the current transfer\n+ * @src: the data received from the TCP stack\n+ * @len: the length of the data\n+ */\n+static int store_block(struct tftp_ctx *ctx, void *src, u16_t len)\n+{\n+\tulong store_addr = ctx->daddr;\n+\tvoid *ptr;\n+\n+\tif (CONFIG_IS_ENABLED(LMB)) {\n+\t\tif (store_addr + len < store_addr ||\n+\t\t lmb_read_check(store_addr, len)) {\n+\t\t\tputs(\"\\nTFTP error: \");\n+\t\t\tputs(\"trying to overwrite reserved memory...\\n\");\n+\t\t\treturn -1;\n+\t\t}\n+\t}\n+\n+\tptr = map_sysmem(store_addr, len);\n+\tmemcpy(ptr, src, len);\n+\tunmap_sysmem(ptr);\n+\n+\tctx->daddr += len;\n+\tctx->size += len;\n+\tctx->block_count++;\n+\tif (ctx->block_count % 10 == 0) {\n+\t\tputc('#');\n+\t\tif (ctx->block_count % (65 * 10) == 0)\n+\t\t\tputs(\"\\n\\t \");\n+\t}\n+\n+\treturn 0;\n+}\n+\n static void *tftp_open(const char *fname, const char *mode, u8_t is_write)\n {\n \treturn NULL;\n@@ -71,17 +113,9 @@ static int tftp_write(void *handle, struct pbuf *p)\n \tstruct tftp_ctx *ctx = handle;\n \tstruct pbuf *q;\n \n-\tfor (q = p; q; q = q->next) {\n-\t\tmemcpy((void *)ctx->daddr, q->payload, q->len);\n-\t\tctx->daddr += q->len;\n-\t\tctx->size += q->len;\n-\t\tctx->block_count++;\n-\t\tif (ctx->block_count % 10 == 0) {\n-\t\t\tputc('#');\n-\t\t\tif (ctx->block_count % (65 * 10) == 0)\n-\t\t\t\tputs(\"\\n\\t \");\n-\t\t}\n-\t}\n+\tfor (q = p; q; q = q->next)\n+\t\tif (store_block(ctx, q->payload, q->len) < 0)\n+\t\t\treturn -1;\n \n \treturn 0;\n }\n", "prefixes": [ "v5", "4/4" ] }