Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/810385/?format=api
{ "id": 810385, "url": "http://patchwork.ozlabs.org/api/patches/810385/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/20170906050310.26474-1-xiyou.wangcong@gmail.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": "<20170906050310.26474-1-xiyou.wangcong@gmail.com>", "list_archive_url": null, "date": "2017-09-06T05:03:10", "name": "[net] net_sched: fix a memory leak of filter chain", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": true, "hash": "0e151b46bd5ba11b1539174139032a015a4c7d94", "submitter": { "id": 211, "url": "http://patchwork.ozlabs.org/api/people/211/?format=api", "name": "Cong Wang", "email": "xiyou.wangcong@gmail.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/20170906050310.26474-1-xiyou.wangcong@gmail.com/mbox/", "series": [ { "id": 1691, "url": "http://patchwork.ozlabs.org/api/series/1691/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/list/?series=1691", "date": "2017-09-06T05:03:10", "name": "[net] net_sched: fix a memory leak of filter chain", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/1691/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/810385/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/810385/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=gmail.com header.i=@gmail.com\n\theader.b=\"GaXVlv8W\"; dkim-atps=neutral" ], "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xnBLM3BCNz9sBZ\n\tfor <patchwork-incoming@ozlabs.org>;\n\tWed, 6 Sep 2017 15:03:23 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1750917AbdIFFDU (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tWed, 6 Sep 2017 01:03:20 -0400", "from mail-pg0-f68.google.com ([74.125.83.68]:36000 \"EHLO\n\tmail-pg0-f68.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1750819AbdIFFDS (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Wed, 6 Sep 2017 01:03:18 -0400", "by mail-pg0-f68.google.com with SMTP id d8so2974988pgt.3\n\tfor <netdev@vger.kernel.org>; Tue, 05 Sep 2017 22:03:18 -0700 (PDT)", "from tw-172-25-30-113.office.twttr.net ([8.25.197.25])\n\tby smtp.gmail.com with ESMTPSA id\n\ty79sm832447pfb.120.2017.09.05.22.03.16\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tTue, 05 Sep 2017 22:03:16 -0700 (PDT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id;\n\tbh=w8W2djACNA71prll/HRnTZRwpVBC1TtlkEf00T2adh4=;\n\tb=GaXVlv8Wo0Ddr87HxBMTh7z/ydGZNmqGw0UCjY0glAGwqedvXaWM4OSj+rkhbaGJEB\n\tCbxUVhX1Fm06jFZmGZrwhMPP4cEMOdq5MbDSiwKIiQW/FGGSSYHwnvXxjhg7rqhUZ3J/\n\tHPEUPLf/ESzY5twonqRPAbIyZ5JEP9J3nC44QmX4MBnRh26JJIK4J78QX6oIhTUPPeyk\n\t5Axry4bG2hv+v/Thb/l6On40fgER3vDEZr9cI7pzBUSjq+MGaRo2zSQRTb3gKxuefsP7\n\t+oBKVdyVUkIRSXgrUwjA8170jjk3GyudxIP74uEGqs3pTCB/sILh/QCSmMdOnyCT28lz\n\tML8g==", "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;\n\tbh=w8W2djACNA71prll/HRnTZRwpVBC1TtlkEf00T2adh4=;\n\tb=uX1aUn1U+2kqpmkCDMPpKDeSvMv/JNin6jbDgLNj9+mrsBgDpSYixZtDSrrs0k96lv\n\tfykfHuywyx1Uoay2VFz8IE60XXMORmaiNWe0rNoVGBImNYJ7oXH7QnXDMG8TNORwuvpb\n\th//ZT4rj0l66KqrlVgcl6aAaBTKe+65HVBbMK9OhEqV6K2mNnbEDCz3wZodzlldimOn2\n\txo7zxfWVV8z77UXV3Tixmsi3j3Yny/uK2kEvYrhSupQKgaj53pZOIll3S5HytYGua1Ru\n\tf2sL2IrLaQ6Wexl+UDSF/lVhJvw08I0Hs8eGdA/fvjmQ2LWqRiYJdnil5EbjCnEpZFGy\n\tBQfA==", "X-Gm-Message-State": "AHPjjUinPtSO7Nlp7cRABYrxCEAP1Fp1Xe3omPkXWv/e2ppcpIhzB75U\n\tGbOGEfAjE3RBl1JYLr8=", "X-Google-Smtp-Source": "ADKCNb6htPamQUQDD4FVVZrU7e+DthHWFEePyU81MQgmtap9zwVuRJJRVadaWbg0ZShzw4xqi+BCsA==", "X-Received": "by 10.84.132.2 with SMTP id 2mr6926932ple.381.1504674197584;\n\tTue, 05 Sep 2017 22:03:17 -0700 (PDT)", "From": "Cong Wang <xiyou.wangcong@gmail.com>", "To": "netdev@vger.kernel.org", "Cc": "jakub.kicinski@netronome.com, Cong Wang <xiyou.wangcong@gmail.com>,\n\tJiri Pirko <jiri@mellanox.com>", "Subject": "[Patch net] net_sched: fix a memory leak of filter chain", "Date": "Tue, 5 Sep 2017 22:03:10 -0700", "Message-Id": "<20170906050310.26474-1-xiyou.wangcong@gmail.com>", "X-Mailer": "git-send-email 2.9.4", "Sender": "netdev-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<netdev.vger.kernel.org>", "X-Mailing-List": "netdev@vger.kernel.org" }, "content": "tcf_chain_destroy() is called by tcf_block_put() and tcf_chain_put().\ntcf_chain_put() is refcn'ed and paired with tcf_chain_get(),\nbut tcf_block_put() is not, it should be paired with tcf_block_get()\nand we still need to decrease the refcnt. However, tcf_block_put()\nis special, it stores the chains too, we have to detach them if\nit is not the last user.\n\nWhat's more, index 0 is not special at all, it should be treated\nlike other chains. This also makes the code more readable.\n\nFixes: 744a4cf63e52 (\"net: sched: fix use after free when tcf_chain_destroy is called multiple times\")\nReported-by: Jakub Kicinski <jakub.kicinski@netronome.com>\nCc: Jiri Pirko <jiri@mellanox.com>\nSigned-off-by: Cong Wang <xiyou.wangcong@gmail.com>\n---\n net/sched/cls_api.c | 22 +++++++++++-----------\n 1 file changed, 11 insertions(+), 11 deletions(-)", "diff": "diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c\nindex 6c5ea84d2682..c6d25b29bcd4 100644\n--- a/net/sched/cls_api.c\n+++ b/net/sched/cls_api.c\n@@ -213,17 +213,17 @@ static void tcf_chain_flush(struct tcf_chain *chain)\n \t}\n }\n \n-static void tcf_chain_destroy(struct tcf_chain *chain)\n+static void tcf_chain_detach(struct tcf_chain *chain)\n {\n \t/* May be already removed from the list by the previous call. */\n \tif (!list_empty(&chain->list))\n \t\tlist_del_init(&chain->list);\n+}\n \n-\t/* There might still be a reference held when we got here from\n-\t * tcf_block_put. Wait for the user to drop reference before free.\n-\t */\n-\tif (!chain->refcnt)\n-\t\tkfree(chain);\n+static void tcf_chain_destroy(struct tcf_chain *chain)\n+{\n+\ttcf_chain_detach(chain);\n+\tkfree(chain);\n }\n \n struct tcf_chain *tcf_chain_get(struct tcf_block *block, u32 chain_index,\n@@ -246,10 +246,7 @@ EXPORT_SYMBOL(tcf_chain_get);\n \n void tcf_chain_put(struct tcf_chain *chain)\n {\n-\t/* Destroy unused chain, with exception of chain 0, which is the\n-\t * default one and has to be always present.\n-\t */\n-\tif (--chain->refcnt == 0 && !chain->filter_chain && chain->index != 0)\n+\tif (--chain->refcnt == 0)\n \t\ttcf_chain_destroy(chain);\n }\n EXPORT_SYMBOL(tcf_chain_put);\n@@ -296,8 +293,11 @@ void tcf_block_put(struct tcf_block *block)\n \n \tlist_for_each_entry_safe(chain, tmp, &block->chain_list, list) {\n \t\ttcf_chain_flush(chain);\n-\t\ttcf_chain_destroy(chain);\n+\t\ttcf_chain_put(chain);\n \t}\n+\t/* If tc actions still hold the chain, just detach it. */\n+\tlist_for_each_entry_safe(chain, tmp, &block->chain_list, list)\n+\t\ttcf_chain_detach(chain);\n \tkfree(block);\n }\n EXPORT_SYMBOL(tcf_block_put);\n", "prefixes": [ "net" ] }