get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 34965,
    "url": "http://patches.dpdk.org/api/patches/34965/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20180205121642.26428-5-stefanha@redhat.com/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20180205121642.26428-5-stefanha@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20180205121642.26428-5-stefanha@redhat.com",
    "date": "2018-02-05T12:16:38",
    "name": "[dpdk-dev,4/8] vhost: clear out unused SCM_RIGHTS file descriptors",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "bd1a007959993221574b795fd1c0ffcfeafee324",
    "submitter": {
        "id": 933,
        "url": "http://patches.dpdk.org/api/people/933/?format=api",
        "name": "Stefan Hajnoczi",
        "email": "stefanha@redhat.com"
    },
    "delegate": {
        "id": 2642,
        "url": "http://patches.dpdk.org/api/users/2642/?format=api",
        "username": "mcoquelin",
        "first_name": "Maxime",
        "last_name": "Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20180205121642.26428-5-stefanha@redhat.com/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/34965/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/34965/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id AFBBA1B35A;\n\tMon,  5 Feb 2018 13:17:14 +0100 (CET)",
            "from mx1.redhat.com (mx1.redhat.com [209.132.183.28])\n\tby dpdk.org (Postfix) with ESMTP id 27F7B1B34C\n\tfor <dev@dpdk.org>; Mon,  5 Feb 2018 13:17:13 +0100 (CET)",
            "from smtp.corp.redhat.com\n\t(int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 8C36F49016;\n\tMon,  5 Feb 2018 12:17:12 +0000 (UTC)",
            "from localhost (ovpn-117-200.ams2.redhat.com [10.36.117.200])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 205365D726;\n\tMon,  5 Feb 2018 12:17:06 +0000 (UTC)"
        ],
        "From": "Stefan Hajnoczi <stefanha@redhat.com>",
        "To": "dev@dpdk.org",
        "Cc": "Maxime Coquelin <maxime.coquelin@redhat.com>,\n\tYuanhan Liu <yliu@fridaylinux.org>, Stefan Hajnoczi <stefanha@redhat.com>",
        "Date": "Mon,  5 Feb 2018 12:16:38 +0000",
        "Message-Id": "<20180205121642.26428-5-stefanha@redhat.com>",
        "In-Reply-To": "<20180205121642.26428-1-stefanha@redhat.com>",
        "References": "<20180205121642.26428-1-stefanha@redhat.com>",
        "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.14",
        "X-Greylist": "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.38]); Mon, 05 Feb 2018 12:17:12 +0000 (UTC)",
        "Subject": "[dpdk-dev] [PATCH 4/8] vhost: clear out unused SCM_RIGHTS file\n\tdescriptors",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "The number of file descriptors received is not stored by vhost_user.c.\nvhost_user_set_mem_table() assumes that memory.nregions matches the\nnumber of file descriptors received, but nothing guarantees this:\n\n  for (i = 0; i < memory.nregions; i++)\n      close(pmsg->fds[i]);\n\nAnother questionable code snippet is:\n\n  case VHOST_USER_SET_LOG_FD:\n      close(msg.fds[0]);\n\nIf not enough file descriptors were received then fds[] contains\nuninitialized data from the stack (see read_fd_message()).  This might\ncause non-vhost file descriptors to be closed if the uninitialized data\nhappens to match.\n\nRefactoring vhost_user.c to pass around and check the number of file\ndescriptors everywhere would make the code more complex.  It is simpler\nfor read_fd_message() to set unused elements in fds[] to -1.  This way\nclose(-1) is called and no harm is done.\n\nSigned-off-by: Stefan Hajnoczi <stefanha@redhat.com>\n---\n lib/librte_vhost/socket.c | 8 +++++++-\n 1 file changed, 7 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c\nindex 6e3857e7a..4e3f8abb9 100644\n--- a/lib/librte_vhost/socket.c\n+++ b/lib/librte_vhost/socket.c\n@@ -96,6 +96,7 @@ read_fd_message(int sockfd, char *buf, int buflen, int *fds, int fd_num)\n \tsize_t fdsize = fd_num * sizeof(int);\n \tchar control[CMSG_SPACE(fdsize)];\n \tstruct cmsghdr *cmsg;\n+\tint got_fds = 0;\n \tint ret;\n \n \tmemset(&msgh, 0, sizeof(msgh));\n@@ -122,11 +123,16 @@ read_fd_message(int sockfd, char *buf, int buflen, int *fds, int fd_num)\n \t\tcmsg = CMSG_NXTHDR(&msgh, cmsg)) {\n \t\tif ((cmsg->cmsg_level == SOL_SOCKET) &&\n \t\t\t(cmsg->cmsg_type == SCM_RIGHTS)) {\n-\t\t\tmemcpy(fds, CMSG_DATA(cmsg), fdsize);\n+\t\t\tgot_fds = (cmsg->cmsg_len - CMSG_LEN(0)) / sizeof(int);\n+\t\t\tmemcpy(fds, CMSG_DATA(cmsg), got_fds * sizeof(int));\n \t\t\tbreak;\n \t\t}\n \t}\n \n+\t/* Clear out unused file descriptors */\n+\twhile (got_fds < fd_num)\n+\t\tfds[got_fds++] = -1;\n+\n \treturn ret;\n }\n \n",
    "prefixes": [
        "dpdk-dev",
        "4/8"
    ]
}