Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/808477/?format=api
{ "id": 808477, "url": "http://patchwork.ozlabs.org/api/patches/808477/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/20170831234822.26612-3-edumazet@google.com/", "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": "<20170831234822.26612-3-edumazet@google.com>", "list_archive_url": null, "date": "2017-08-31T23:48:22", "name": "[v2,net-next,2/2] net: convert (struct ubuf_info)->refcnt to refcount_t", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "f2de8a9d2f49963f55b8c2616130482e9cbe739e", "submitter": { "id": 13357, "url": "http://patchwork.ozlabs.org/api/people/13357/?format=api", "name": "Eric Dumazet", "email": "edumazet@google.com" }, "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/20170831234822.26612-3-edumazet@google.com/mbox/", "series": [ { "id": 927, "url": "http://patchwork.ozlabs.org/api/series/927/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/list/?series=927", "date": "2017-08-31T23:48:20", "name": "net: ubuf_info.refcnt conversion", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/927/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/808477/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/808477/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<netdev-owner@vger.kernel.org>", "X-Original-To": "patchwork-incoming@ozlabs.org", "Delivered-To": "patchwork-incoming@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; dkim=pass (2048-bit key;\n\tunprotected) header.d=google.com header.i=@google.com\n\theader.b=\"nW3TlKa6\"; dkim-atps=neutral" ], "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xjzbV1t9Nz9s7p\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri, 1 Sep 2017 09:48:38 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1752188AbdHaXsg (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tThu, 31 Aug 2017 19:48:36 -0400", "from mail-pg0-f52.google.com ([74.125.83.52]:34601 \"EHLO\n\tmail-pg0-f52.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1752175AbdHaXsb (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Thu, 31 Aug 2017 19:48:31 -0400", "by mail-pg0-f52.google.com with SMTP id t193so3302214pgc.1\n\tfor <netdev@vger.kernel.org>; Thu, 31 Aug 2017 16:48:31 -0700 (PDT)", "from localhost ([2620:15c:2cb:201:df6:9252:fc0d:50b2])\n\tby smtp.gmail.com with ESMTPSA id\n\t188sm840179pfe.171.2017.08.31.16.48.30\n\t(version=TLS1_2 cipher=AES128-SHA bits=128/128);\n\tThu, 31 Aug 2017 16:48:30 -0700 (PDT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=google.com; s=20161025;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=31whvFlf4Im9A3poegahHNFKnM0ho21D1OgC4NB4lVw=;\n\tb=nW3TlKa6uUEv9EgRIgaFtPmB1cKW3OfpIU2YF1KLSmGJLbSi1MqJTHOqboZjxoaVNs\n\tAbxJJkPnxQA/vOT5YyvVE+diZE+m03+CibEhU7DSMA8KSCctETMmb+mMwexT4JpRYO5d\n\t3196t0em2Fw3Evq4u3WYJC3xF3/Heqjj2RfVG1U4UzFemXOA78F71aE6yve6Sy0Z5toH\n\ttwvWQyf9GgwOrsjXh+gmNmMOIjdDhNIycMe/nKpBmwJude2Ayzcr60vtqNtd0n1Cx4rF\n\tVKvqO/P63zW5ygcmRrDS6UCYgIZ7QC+GPiOYGfuQeY/N9+SKZpSLcBiSZlbmOOXINwYe\n\tLomg==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=31whvFlf4Im9A3poegahHNFKnM0ho21D1OgC4NB4lVw=;\n\tb=PDNo+GR6988isXlXaG6u0krY0Wy0lO5n2HajggKGb9IBL3iDXgTCrZ+Ml9j/57wh/O\n\tLXZ1rKHU6CVNX8I6dqYUHsZCViInlcJNNrtHLWSRhMLbEs3Bl3owg4VRZ/QUjxDiSd2I\n\tv9mLMmDARj2yn+Oc9orUPGugZAJ2ZJwTScg+yIVcvKBTr/Cfs3o4UaN57DArGy6XrtZG\n\tS6/0VUTR7+xrp+xcPeU1sTYwRU2HUOaW+GqE2YMzgTqFayFEFnQ/KlkCQWSXeNMoDUVP\n\tu+/MVr/amsC23Lkdk2vuNltNPBFnWPjwQBoH63trwiExIbx1b0+EbCfVsqD8Q2JhedPX\n\tXg4Q==", "X-Gm-Message-State": "AHPjjUik8yFZxTsithcCPLscA4lp3wRwNjpmwMF2uXWaeVF1js5MT/Oq\n\tYsbGuQFSYHa+Pa/VrGGkuw==", "X-Google-Smtp-Source": "ADKCNb46w+x53phiTdkKYiw9+270rwLnNGhcUg9Ls/tC5bO5Of9OMSTT9R1ajudZQBUbL65b7Mkk/w==", "X-Received": "by 10.84.131.36 with SMTP id 33mr178517pld.322.1504223311249;\n\tThu, 31 Aug 2017 16:48:31 -0700 (PDT)", "From": "Eric Dumazet <edumazet@google.com>", "To": "\"David S . Miller\" <davem@davemloft.net>", "Cc": "netdev <netdev@vger.kernel.org>, Willem de Bruijn <willemb@google.com>,\n\tEric Dumazet <edumazet@google.com>, Eric Dumazet <eric.dumazet@gmail.com>", "Subject": "[PATCH v2 net-next 2/2] net: convert (struct ubuf_info)->refcnt to\n\trefcount_t", "Date": "Thu, 31 Aug 2017 16:48:22 -0700", "Message-Id": "<20170831234822.26612-3-edumazet@google.com>", "X-Mailer": "git-send-email 2.14.1.581.gf28d330327-goog", "In-Reply-To": "<20170831234822.26612-1-edumazet@google.com>", "References": "<20170831234822.26612-1-edumazet@google.com>", "Sender": "netdev-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<netdev.vger.kernel.org>", "X-Mailing-List": "netdev@vger.kernel.org" }, "content": "refcount_t type and corresponding API should be\nused instead of atomic_t when the variable is used as\na reference counter. This allows to avoid accidental\nrefcounter overflows that might lead to use-after-free\nsituations.\n\nv2: added the change in drivers/vhost/net.c as spotted\nby Willem.\n\nSigned-off-by: Eric Dumazet <edumazet@google.com>\n---\n drivers/vhost/net.c | 2 +-\n include/linux/skbuff.h | 5 +++--\n net/core/skbuff.c | 6 +++---\n 3 files changed, 7 insertions(+), 6 deletions(-)", "diff": "diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c\nindex ba08b78ed630c429ccf415af69bf27f2433af4f0..8d2bcae53a2ec9ea1c876625e581bcd429abe365 100644\n--- a/drivers/vhost/net.c\n+++ b/drivers/vhost/net.c\n@@ -533,7 +533,7 @@ static void handle_tx(struct vhost_net *net)\n \t\t\tubuf->callback = vhost_zerocopy_callback;\n \t\t\tubuf->ctx = nvq->ubufs;\n \t\t\tubuf->desc = nvq->upend_idx;\n-\t\t\tatomic_set(&ubuf->refcnt, 1);\n+\t\t\trefcount_set(&ubuf->refcnt, 1);\n \t\t\tmsg.msg_control = ubuf;\n \t\t\tmsg.msg_controllen = sizeof(ubuf);\n \t\t\tubufs = nvq->ubufs;\ndiff --git a/include/linux/skbuff.h b/include/linux/skbuff.h\nindex 7594e19bce622a38dc39c054093c3da15b99b67b..316a92b45351f53709886ee0099cbc83b66f1b15 100644\n--- a/include/linux/skbuff.h\n+++ b/include/linux/skbuff.h\n@@ -22,6 +22,7 @@\n #include <linux/cache.h>\n #include <linux/rbtree.h>\n #include <linux/socket.h>\n+#include <linux/refcount.h>\n \n #include <linux/atomic.h>\n #include <asm/types.h>\n@@ -456,7 +457,7 @@ struct ubuf_info {\n \t\t\tu32 bytelen;\n \t\t};\n \t};\n-\tatomic_t refcnt;\n+\trefcount_t refcnt;\n \n \tstruct mmpin {\n \t\tstruct user_struct *user;\n@@ -472,7 +473,7 @@ struct ubuf_info *sock_zerocopy_realloc(struct sock *sk, size_t size,\n \n static inline void sock_zerocopy_get(struct ubuf_info *uarg)\n {\n-\tatomic_inc(&uarg->refcnt);\n+\trefcount_inc(&uarg->refcnt);\n }\n \n void sock_zerocopy_put(struct ubuf_info *uarg);\ndiff --git a/net/core/skbuff.c b/net/core/skbuff.c\nindex 1a754d7896ceac1eb85e3b13c1422b4d6a88fedf..06b9ddca3188442d1d1d2052fc060cf5b1e2a6f4 100644\n--- a/net/core/skbuff.c\n+++ b/net/core/skbuff.c\n@@ -963,7 +963,7 @@ struct ubuf_info *sock_zerocopy_alloc(struct sock *sk, size_t size)\n \tuarg->len = 1;\n \tuarg->bytelen = size;\n \tuarg->zerocopy = 1;\n-\tatomic_set(&uarg->refcnt, 1);\n+\trefcount_set(&uarg->refcnt, 1);\n \tsock_hold(sk);\n \n \treturn uarg;\n@@ -1086,7 +1086,7 @@ EXPORT_SYMBOL_GPL(sock_zerocopy_callback);\n \n void sock_zerocopy_put(struct ubuf_info *uarg)\n {\n-\tif (uarg && atomic_dec_and_test(&uarg->refcnt)) {\n+\tif (uarg && refcount_dec_and_test(&uarg->refcnt)) {\n \t\tif (uarg->callback)\n \t\t\tuarg->callback(uarg, uarg->zerocopy);\n \t\telse\n@@ -1483,7 +1483,7 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,\n \t\tif (skb_orphan_frags(skb, gfp_mask))\n \t\t\tgoto nofrags;\n \t\tif (skb_zcopy(skb))\n-\t\t\tatomic_inc(&skb_uarg(skb)->refcnt);\n+\t\t\trefcount_inc(&skb_uarg(skb)->refcnt);\n \t\tfor (i = 0; i < skb_shinfo(skb)->nr_frags; i++)\n \t\t\tskb_frag_ref(skb, i);\n \n", "prefixes": [ "v2", "net-next", "2/2" ] }