Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2232201/?format=api
{ "id": 2232201, "url": "http://patchwork.ozlabs.org/api/patches/2232201/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-gpio/patch/20260503190016.13439-1-zxl434815272@gmail.com/", "project": { "id": 42, "url": "http://patchwork.ozlabs.org/api/projects/42/?format=api", "name": "Linux GPIO development", "link_name": "linux-gpio", "list_id": "linux-gpio.vger.kernel.org", "list_email": "linux-gpio@vger.kernel.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260503190016.13439-1-zxl434815272@gmail.com>", "list_archive_url": null, "date": "2026-05-03T19:00:16", "name": "tools: gpio: fix buffer overflow and add bounds check", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "e6119dd130417afd5558b2d8adc1bde93f3530dd", "submitter": { "id": 93314, "url": "http://patchwork.ozlabs.org/api/people/93314/?format=api", "name": "Zhang Xiaolei", "email": "zxl434815272@gmail.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linux-gpio/patch/20260503190016.13439-1-zxl434815272@gmail.com/mbox/", "series": [ { "id": 502584, "url": "http://patchwork.ozlabs.org/api/series/502584/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-gpio/list/?series=502584", "date": "2026-05-03T19:00:16", "name": "tools: gpio: fix buffer overflow and add bounds check", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/502584/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2232201/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2232201/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "\n <linux-gpio+bounces-36002-incoming=patchwork.ozlabs.org@vger.kernel.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "linux-gpio@vger.kernel.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=DsrCCPon;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.105.105.114; helo=tor.lore.kernel.org;\n envelope-from=linux-gpio+bounces-36002-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)", "smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com\n header.b=\"DsrCCPon\"", "smtp.subspace.kernel.org;\n arc=none smtp.client-ip=209.85.210.182", "smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com", "smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=gmail.com" ], "Received": [ "from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])\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 4g7vHH3gfPz1xvV\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 04 May 2026 05:00:27 +1000 (AEST)", "from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby tor.lore.kernel.org (Postfix) with ESMTP id 298473007979\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 3 May 2026 19:00:25 +0000 (UTC)", "from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id A4D0E372ED0;\n\tSun, 3 May 2026 19:00:23 +0000 (UTC)", "from mail-pf1-f182.google.com (mail-pf1-f182.google.com\n [209.85.210.182])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 2FA9E38BF72\n\tfor <linux-gpio@vger.kernel.org>; Sun, 3 May 2026 19:00:22 +0000 (UTC)", "by mail-pf1-f182.google.com with SMTP id\n d2e1a72fcca58-8296d553142so2309227b3a.3\n for <linux-gpio@vger.kernel.org>;\n Sun, 03 May 2026 12:00:22 -0700 (PDT)", "from localhost ([188.253.123.154])\n by smtp.gmail.com with ESMTPSA id\n d2e1a72fcca58-83515ad0183sm10229043b3a.31.2026.05.03.12.00.20\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Sun, 03 May 2026 12:00:20 -0700 (PDT)" ], "ARC-Seal": "i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777834823; cv=none;\n b=B9kPC4EIFftjPzhBOyWABSh+3r2zV2BCPT9xSE8bK4M2IIO/9sCCFrEInY73+hbHbe+kwWk5sHEW7l6+GWU9SWowS1xWBXyTQz7yT10mt0iozDKju4XhCPTAd/J8IzYeYIGISFKoxiV3hUMcP31Kizd+SX8X8lWHLN1kh4/4T3I=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777834823; c=relaxed/simple;\n\tbh=o6F3nF2O0oh1QqtBXJyM5pwHLTdevetrcOoH6c/SVrw=;\n\th=From:To:Cc:Subject:Date:Message-ID:MIME-Version;\n b=JTRgxN84kEAJcz1TapOHWGjzyqFoLZRF1sNv4KBeDdDQc60vgeEiHTi7xGCIOji5JJoIrnb702SJU/3JIeVIiXRu5wWyMSBV/aJfFRMax2j1Rxlcmq9X7Oj196JZ+Hv4ynxLsBoL6L8ROkl2egBcRf+dpT4GmZsK1l3a65rZnac=", "ARC-Authentication-Results": "i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com;\n spf=pass smtp.mailfrom=gmail.com;\n dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com\n header.b=DsrCCPon; arc=none smtp.client-ip=209.85.210.182", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1777834821; x=1778439621;\n darn=vger.kernel.org;\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=KjVAUyKukJeCfmaUj1rdh/OVSGApfRD+jJDm/U7qFBo=;\n b=DsrCCPonOxied9ANQ4e+E3Uc8D6GjFG/28vOAWLuqCQsfdbu3tXw6Vhw3ziYle57xc\n R4sO1K8KtVW4F/PlG6zfbqC2jOlwzYgduws4DcdHhdLiW2cIJpOjpGBs+gkGXz0Pl0EC\n 55/14EK47HMj0XHaMgC0G/JUvaGGScPv6aZS0fqIyFPNk2xBmht4uyZfOIheb94ajq01\n Amt5X5R6Is89X9GNM5li4sth7Fba7Km2SBv74Jq0Yl87QEe1QMAhh1NJS8ScB2A29QyV\n LsBOAu7n0y110kSTX/Xf698vhKGrY3HLtsQY+/yQQeeLMpH8Y4m+gtEermo+BX+hokDk\n +EpA==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1777834821; x=1778439621;\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=KjVAUyKukJeCfmaUj1rdh/OVSGApfRD+jJDm/U7qFBo=;\n b=Fy7rZ3O4vYg3MvQuvSaaSp+vmEo7y+edRHt25snsU3u/GCD4OZF5n5dYGMjvdW5avJ\n pLlLuctQwxAfd962UOZBY0I2V/z/szAIbytwmoO8W04TxBT4sd2JKw/izy0V+wkjgbj1\n eIW52LQjbUT1sZWdZv4UPMTdcxEqPK0gwFjRW0i2uPDDl11Hs0zxewiiddHXX/cNf5Q8\n 1JAACfCiKsG61dtrFQoYPy7gNLm/R6mjniIeQTqY8VePIkDShHThXyd/NTCugf8OfRgi\n uwTpN1M/5wDTFVN+Lz8sCg9M8uoXWVmnVUQ5sUjv1idtHSx2cMOmb0oLGYd2JF2cDXrx\n BkBw==", "X-Gm-Message-State": "AOJu0Yxc1ySu1mxQLe+8KpbBhyuyx0joE70v3UX314ZlOqZCB+nObS1N\n\tpNBqbUDR2yDtwyAxWSxXKL/POEYlPQK1gnZuz29ugaPgyiuUHIdfA2+mS1noVg==", "X-Gm-Gg": "AeBDieviLLc9Uo8TBwToG0sMNMH4dWnCzP7kC5GyrEMMaAOgC46XmTDoNzQlzTVs3ZW\n\t/dcanJHcAA1SeYv4Zy461sEdWiNarvbr1WNoBseAeBx1QjvX+Iu9CdrNaqsgMYC40RW2YufaG+V\n\tpBjMHtINmDoSmgkS9mAlalY814R1+AbS9IdsYBjErrDndmW/waMwPkt3j+hcWQY07uHrPD5v5Ja\n\tZePtYr3HaDtirLLnP1BYiWszbeW8szZ+jUmbN/K7m2M0rJDhxWLVmiUVRtaLAkdP7k/SdSWnzL3\n\tQLMy770aJig0Uil39WMOkRKb7NGGzET//G3BH0FGBUubqDd/ErSYT6UV8jVhqzqLvk0VJnqM+Vb\n\t+96IgFbWExkF+Ljosy5CEICCRZ8eqMA908tS+WywoCjaUPsKjqUc6i1zLkKxBhtDd3kQ2yxD8yU\n\tdeBkKfTpSXU8o9B3Q6crDkUXEZRN4DGDpEvKmb", "X-Received": "by 2002:a05:6a00:430a:b0:81f:852b:a925 with SMTP id\n d2e1a72fcca58-8352d03bf06mr5948036b3a.1.1777834821160;\n Sun, 03 May 2026 12:00:21 -0700 (PDT)", "From": "Zhang Xiaolei <zxl434815272@gmail.com>", "To": "linux-gpio@vger.kernel.org", "Cc": "brgl@kernel.org,\n\twarthog618@gmail.com,\n\tlinux-kernel@vger.kernel.org,\n\tZhang Xiaolei <zxl434815272@gmail.com>", "Subject": "[PATCH] tools: gpio: fix buffer overflow and add bounds check", "Date": "Mon, 4 May 2026 03:00:16 +0800", "Message-ID": "<20260503190016.13439-1-zxl434815272@gmail.com>", "X-Mailer": "git-send-email 2.54.0", "Precedence": "bulk", "X-Mailing-List": "linux-gpio@vger.kernel.org", "List-Id": "<linux-gpio.vger.kernel.org>", "List-Subscribe": "<mailto:linux-gpio+subscribe@vger.kernel.org>", "List-Unsubscribe": "<mailto:linux-gpio+unsubscribe@vger.kernel.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit" }, "content": "Replace strcpy() with strncpy() to avoid potential buffer overflow\nin req.consumer. Also add validation for num_lines to prevent\nout-of-bounds access to req.offsets.\n\nFix incorrect ioctl name in error message.\n\nSigned-off-by: Zhang Xiaolei <zxl434815272@gmail.com>\n---\n tools/gpio/gpio-utils.c | 14 ++++++++++----\n 1 file changed, 10 insertions(+), 4 deletions(-)", "diff": "diff --git a/tools/gpio/gpio-utils.c b/tools/gpio/gpio-utils.c\nindex 4096bcd511d1..1afd9dff2bed 100644\n--- a/tools/gpio/gpio-utils.c\n+++ b/tools/gpio/gpio-utils.c\n@@ -65,11 +65,15 @@ int gpiotools_request_line(const char *device_name, unsigned int *lines,\n \tint i;\n \tint ret;\n \n+\tif (!device_name || !lines || !config || !consumer ||\n+\t num_lines == 0 || num_lines > GPIO_V2_LINES_MAX)\n+\t\treturn -EINVAL;\n+\n \tret = asprintf(&chrdev_name, \"/dev/%s\", device_name);\n \tif (ret < 0)\n \t\treturn -ENOMEM;\n \n-\tfd = open(chrdev_name, 0);\n+\tfd = open(chrdev_name, O_RDONLY);\n \tif (fd == -1) {\n \t\tret = -errno;\n \t\tfprintf(stderr, \"Failed to open %s, %s\\n\",\n@@ -78,27 +82,29 @@ int gpiotools_request_line(const char *device_name, unsigned int *lines,\n \t}\n \n \tmemset(&req, 0, sizeof(req));\n+\n \tfor (i = 0; i < num_lines; i++)\n \t\treq.offsets[i] = lines[i];\n \n \treq.config = *config;\n-\tstrcpy(req.consumer, consumer);\n+\tstrncpy(req.consumer, consumer, sizeof(req.consumer) - 1);\n+\treq.consumer[sizeof(req.consumer) - 1] = '\\0';\n \treq.num_lines = num_lines;\n \n \tret = ioctl(fd, GPIO_V2_GET_LINE_IOCTL, &req);\n \tif (ret == -1) {\n \t\tret = -errno;\n \t\tfprintf(stderr, \"Failed to issue %s (%d), %s\\n\",\n-\t\t\t\"GPIO_GET_LINE_IOCTL\", ret, strerror(errno));\n+\t\t\t\"GPIO_V2_GET_LINE_IOCTL\", ret, strerror(errno));\n \t}\n \n \tif (close(fd) == -1)\n \t\tperror(\"Failed to close GPIO character device file\");\n+\n exit_free_name:\n \tfree(chrdev_name);\n \treturn ret < 0 ? ret : req.fd;\n }\n-\n /**\n * gpiotools_set_values() - Set the value of gpio(s)\n * @fd:\t\t\tThe fd returned by\n", "prefixes": [] }