get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/980255/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 980255,
    "url": "http://patchwork.ozlabs.org/api/patches/980255/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/20181008031644.15989-5-dsahern@kernel.org/",
    "project": {
        "id": 7,
        "url": "http://patchwork.ozlabs.org/api/projects/7/?format=api",
        "name": "Linux network development",
        "link_name": "netdev",
        "list_id": "netdev.vger.kernel.org",
        "list_email": "netdev@vger.kernel.org",
        "web_url": null,
        "scm_url": null,
        "webscm_url": null,
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20181008031644.15989-5-dsahern@kernel.org>",
    "list_archive_url": null,
    "date": "2018-10-08T03:16:25",
    "name": "[v2,net-next,04/23] netlink: Add strict version of nlmsg_parse and nla_parse",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "ba1e597e64f83ac4455bb4c948cedb68101479c6",
    "submitter": {
        "id": 74101,
        "url": "http://patchwork.ozlabs.org/api/people/74101/?format=api",
        "name": "David Ahern",
        "email": "dsahern@kernel.org"
    },
    "delegate": {
        "id": 34,
        "url": "http://patchwork.ozlabs.org/api/users/34/?format=api",
        "username": "davem",
        "first_name": "David",
        "last_name": "Miller",
        "email": "davem@davemloft.net"
    },
    "mbox": "http://patchwork.ozlabs.org/project/netdev/patch/20181008031644.15989-5-dsahern@kernel.org/mbox/",
    "series": [
        {
            "id": 69470,
            "url": "http://patchwork.ozlabs.org/api/series/69470/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/netdev/list/?series=69470",
            "date": "2018-10-08T03:16:21",
            "name": "rtnetlink: Add support for rigid checking of data in dump request",
            "version": 2,
            "mbox": "http://patchwork.ozlabs.org/series/69470/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/980255/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/980255/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<netdev-owner@vger.kernel.org>",
        "X-Original-To": "patchwork-incoming-netdev@ozlabs.org",
        "Delivered-To": "patchwork-incoming-netdev@ozlabs.org",
        "Authentication-Results": [
            "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)",
            "ozlabs.org;\n\tdmarc=pass (p=none dis=none) header.from=kernel.org",
            "ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=kernel.org header.i=@kernel.org\n\theader.b=\"yP/XLE4y\"; dkim-atps=neutral"
        ],
        "Received": [
            "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 42T5BC6pJPz9sCV\n\tfor <patchwork-incoming-netdev@ozlabs.org>;\n\tMon,  8 Oct 2018 14:16:51 +1100 (AEDT)",
            "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1726982AbeJHK0U (ORCPT\n\t<rfc822;patchwork-incoming-netdev@ozlabs.org>);\n\tMon, 8 Oct 2018 06:26:20 -0400",
            "from mail.kernel.org ([198.145.29.99]:42562 \"EHLO mail.kernel.org\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1725993AbeJHK0S (ORCPT <rfc822;netdev@vger.kernel.org>);\n\tMon, 8 Oct 2018 06:26:18 -0400",
            "from kenny.it.cumulusnetworks.com. (fw.cumulusnetworks.com\n\t[216.129.126.126])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128\n\tbits)) (No client certificate requested)\n\tby mail.kernel.org (Postfix) with ESMTPSA id DBCD82089C;\n\tMon,  8 Oct 2018 03:16:47 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=default; t=1538968608;\n\tbh=cSvYERyd+gzy1I9s1FAB0lhg4YDy6H+sP33g1AKiuFU=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=yP/XLE4yzKJ3i6S1cxu0FtttGDAUZnbyML6UbDCGT1sdyO7uPdBt/qI6h88zmYc+o\n\t1VYJ/7H7UWJpIzCG4Xpma/bBia9HsTJdAnIso8FjhN4zFcjzina4gWsDHdpg7Ia/u4\n\tkSxRJ+jdhqZa87+EHnZWjQQOdpkGl+fslZvKphXQ=",
        "From": "David Ahern <dsahern@kernel.org>",
        "To": "netdev@vger.kernel.org, davem@davemloft.net",
        "Cc": "christian@brauner.io, jbenc@redhat.com, stephen@networkplumber.org,\n\tDavid Ahern <dsahern@gmail.com>",
        "Subject": "[PATCH v2 net-next 04/23] netlink: Add strict version of\n\tnlmsg_parse and nla_parse",
        "Date": "Sun,  7 Oct 2018 20:16:25 -0700",
        "Message-Id": "<20181008031644.15989-5-dsahern@kernel.org>",
        "X-Mailer": "git-send-email 2.11.0",
        "In-Reply-To": "<20181008031644.15989-1-dsahern@kernel.org>",
        "References": "<20181008031644.15989-1-dsahern@kernel.org>",
        "Sender": "netdev-owner@vger.kernel.org",
        "Precedence": "bulk",
        "List-ID": "<netdev.vger.kernel.org>",
        "X-Mailing-List": "netdev@vger.kernel.org"
    },
    "content": "From: David Ahern <dsahern@gmail.com>\n\nnla_parse is currently lenient on message parsing, allowing type to be 0\nor greater than max expected and only logging a message\n\n    \"netlink: %d bytes leftover after parsing attributes in process `%s'.\"\n\nif the netlink message has unknown data at the end after parsing. What this\ncould mean is that the header at the front of the attributes is actually\nwrong and the parsing is shifted from what is expected.\n\nAdd a new strict version that actually fails with EINVAL if there are any\nbytes remaining after the parsing loop completes, if the atttrbitue type\nis 0 or greater than max expected.\n\nSigned-off-by: David Ahern <dsahern@gmail.com>\n---\n include/net/netlink.h | 17 +++++++++++++++++\n lib/nlattr.c          | 48 ++++++++++++++++++++++++++++++++++++------------\n 2 files changed, 53 insertions(+), 12 deletions(-)",
    "diff": "diff --git a/include/net/netlink.h b/include/net/netlink.h\nindex 9522a0bf1f3a..f1db8e594847 100644\n--- a/include/net/netlink.h\n+++ b/include/net/netlink.h\n@@ -373,6 +373,9 @@ int nla_validate(const struct nlattr *head, int len, int maxtype,\n int nla_parse(struct nlattr **tb, int maxtype, const struct nlattr *head,\n \t      int len, const struct nla_policy *policy,\n \t      struct netlink_ext_ack *extack);\n+int nla_parse_strict(struct nlattr **tb, int maxtype, const struct nlattr *head,\n+\t\t     int len, const struct nla_policy *policy,\n+\t\t     struct netlink_ext_ack *extack);\n int nla_policy_len(const struct nla_policy *, int);\n struct nlattr *nla_find(const struct nlattr *head, int len, int attrtype);\n size_t nla_strlcpy(char *dst, const struct nlattr *nla, size_t dstsize);\n@@ -525,6 +528,20 @@ static inline int nlmsg_parse(const struct nlmsghdr *nlh, int hdrlen,\n \t\t\t nlmsg_attrlen(nlh, hdrlen), policy, extack);\n }\n \n+static inline int nlmsg_parse_strict(const struct nlmsghdr *nlh, int hdrlen,\n+\t\t\t\t     struct nlattr *tb[], int maxtype,\n+\t\t\t\t     const struct nla_policy *policy,\n+\t\t\t\t     struct netlink_ext_ack *extack)\n+{\n+\tif (nlh->nlmsg_len < nlmsg_msg_size(hdrlen)) {\n+\t\tNL_SET_ERR_MSG(extack, \"Invalid header length\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\treturn nla_parse_strict(tb, maxtype, nlmsg_attrdata(nlh, hdrlen),\n+\t\t\t\tnlmsg_attrlen(nlh, hdrlen), policy, extack);\n+}\n+\n /**\n  * nlmsg_find_attr - find a specific attribute in a netlink message\n  * @nlh: netlink message header\ndiff --git a/lib/nlattr.c b/lib/nlattr.c\nindex 1e900bb414ef..d26de6156b97 100644\n--- a/lib/nlattr.c\n+++ b/lib/nlattr.c\n@@ -391,9 +391,10 @@ EXPORT_SYMBOL(nla_policy_len);\n  *\n  * Returns 0 on success or a negative error code.\n  */\n-int nla_parse(struct nlattr **tb, int maxtype, const struct nlattr *head,\n-\t      int len, const struct nla_policy *policy,\n-\t      struct netlink_ext_ack *extack)\n+static int __nla_parse(struct nlattr **tb, int maxtype,\n+\t\t       const struct nlattr *head, int len,\n+\t\t       bool strict, const struct nla_policy *policy,\n+\t\t       struct netlink_ext_ack *extack)\n {\n \tconst struct nlattr *nla;\n \tint rem;\n@@ -403,27 +404,50 @@ int nla_parse(struct nlattr **tb, int maxtype, const struct nlattr *head,\n \tnla_for_each_attr(nla, head, len, rem) {\n \t\tu16 type = nla_type(nla);\n \n-\t\tif (type > 0 && type <= maxtype) {\n-\t\t\tif (policy) {\n-\t\t\t\tint err = validate_nla(nla, maxtype, policy,\n-\t\t\t\t\t\t       extack);\n-\n-\t\t\t\tif (err < 0)\n-\t\t\t\t\treturn err;\n+\t\tif (type == 0 || type > maxtype) {\n+\t\t\tif (strict) {\n+\t\t\t\tNL_SET_ERR_MSG(extack, \"Unknown attribute type\");\n+\t\t\t\treturn -EINVAL;\n \t\t\t}\n+\t\t\tcontinue;\n+\t\t}\n+\t\tif (policy) {\n+\t\t\tint err = validate_nla(nla, maxtype, policy, extack);\n \n-\t\t\ttb[type] = (struct nlattr *)nla;\n+\t\t\tif (err < 0)\n+\t\t\t\treturn err;\n \t\t}\n+\n+\t\ttb[type] = (struct nlattr *)nla;\n \t}\n \n-\tif (unlikely(rem > 0))\n+\tif (unlikely(rem > 0)) {\n \t\tpr_warn_ratelimited(\"netlink: %d bytes leftover after parsing attributes in process `%s'.\\n\",\n \t\t\t\t    rem, current->comm);\n+\t\tNL_SET_ERR_MSG(extack, \"bytes leftover after parsing attributes\");\n+\t\tif (strict)\n+\t\t\treturn -EINVAL;\n+\t}\n \n \treturn 0;\n }\n+\n+int nla_parse(struct nlattr **tb, int maxtype, const struct nlattr *head,\n+\t      int len, const struct nla_policy *policy,\n+\t      struct netlink_ext_ack *extack)\n+{\n+\treturn __nla_parse(tb, maxtype, head, len, false, policy, extack);\n+}\n EXPORT_SYMBOL(nla_parse);\n \n+int nla_parse_strict(struct nlattr **tb, int maxtype, const struct nlattr *head,\n+\t\t     int len, const struct nla_policy *policy,\n+\t\t     struct netlink_ext_ack *extack)\n+{\n+\treturn __nla_parse(tb, maxtype, head, len, true, policy, extack);\n+}\n+EXPORT_SYMBOL(nla_parse_strict);\n+\n /**\n  * nla_find - Find a specific attribute in a stream of attributes\n  * @head: head of attribute stream\n",
    "prefixes": [
        "v2",
        "net-next",
        "04/23"
    ]
}