[{"id":1766867,"web_url":"http://patchwork.ozlabs.org/comment/1766867/","msgid":"<20170912104358.GG2036@nanopsycho>","list_archive_url":null,"date":"2017-09-12T10:43:58","subject":"Re: [Patch net v3 3/3] net_sched: carefully handle tcf_block_put()","submitter":{"id":15321,"url":"http://patchwork.ozlabs.org/api/people/15321/","name":"Jiri Pirko","email":"jiri@resnulli.us"},"content":"Tue, Sep 12, 2017 at 01:33:32AM CEST, xiyou.wangcong@gmail.com wrote:\n>As pointed out by Jiri, there is still a race condition between\n>tcf_block_put() and tcf_chain_destroy() in a RCU callback. There\n>is no way to make it correct without proper locking or synchronization,\n>because both operate on a shared list.\n>\n>Locking is hard, because the only lock we can pick here is a spinlock,\n>however, in tc_dump_tfilter() we iterate this list with a sleeping\n>function called (tcf_chain_dump()), which makes using a lock to protect\n>chain_list almost impossible.\n>\n>Jiri suggested the idea of holding a refcnt before flushing, this works\n>because it guarantees us there would be no parallel tcf_chain_destroy()\n>during the loop, therefore the race condition is gone. But we have to\n>be very careful with proper synchronization with RCU callbacks.\n>\n>Suggested-by: Jiri Pirko <jiri@mellanox.com>\n>Cc: Jamal Hadi Salim <jhs@mojatatu.com>\n>Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>\n\nAcked-by: Jiri Pirko <jiri@mellanox.com>\n\nThanks!","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=resnulli-us.20150623.gappssmtp.com\n\theader.i=@resnulli-us.20150623.gappssmtp.com\n\theader.b=\"PqjBTWda\"; dkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xs1ch4qmwz9s7g\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 12 Sep 2017 20:44:04 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751410AbdILKoC (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tTue, 12 Sep 2017 06:44:02 -0400","from mail-wr0-f195.google.com ([209.85.128.195]:34926 \"EHLO\n\tmail-wr0-f195.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751370AbdILKoB (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Tue, 12 Sep 2017 06:44:01 -0400","by mail-wr0-f195.google.com with SMTP id n64so5815161wrb.2\n\tfor <netdev@vger.kernel.org>; Tue, 12 Sep 2017 03:44:00 -0700 (PDT)","from localhost (ip-89-177-125-82.net.upcbroadband.cz.\n\t[89.177.125.82]) by smtp.gmail.com with ESMTPSA id\n\t188sm3201093wmg.45.2017.09.12.03.43.59\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tTue, 12 Sep 2017 03:43:59 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=resnulli-us.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:in-reply-to:user-agent;\n\tbh=OybtAleYePlcQFCKgyuNdsSqF8L/Gujv7H6q77L+w+I=;\n\tb=PqjBTWdaWVzeBSTOB7iKhxChUUO4n9b9S/NfkufzFRMYgSCV2xT3DzLDYg/ySxLgKG\n\tTLfjl98cEoN4p0KszMyX2AEDji+i4XbeEo/0XafIWBkSOJQzsEHiPEKBWarwZmMcfIy0\n\trcwRy95VYwoq1rE9wQlAE57e+wQLzKhPwu6M57gJp2VJdmxTQFX2vjKiMV2vh0NUHTQe\n\tMeChKinPaE+jU/E5cVHXHPa/n+mRyA+pzqAtrmySf/VnTq8S/i1seMHTThWtObWLii2u\n\tXKXtxs66/CK4PLVRckM5RHqn7rbRXwVlTZi7VPvbO90Tvkyx+G3SZrKd2mB7ajZcy0Qr\n\tIfbQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:in-reply-to:user-agent;\n\tbh=OybtAleYePlcQFCKgyuNdsSqF8L/Gujv7H6q77L+w+I=;\n\tb=uQPvYhdhYpEo7uDxREQ/XbY4Z26m0ixVrqPIBjBSAZokAQsUUGMQ3nNtrG2htfwdRc\n\tGijMnmIKkVvpw+RX5dJ/3MBWzheYSCeRhSv8eS1K2pJAMP8qXoT0bLfsN4WFYVlLvKUI\n\t/zH7WcqY1oNStuAgHeUvstExFVyrNeUeTG11qMftwq55a3ujYsd9ayiXxgHEzh1eeZJt\n\t6fo0u6q1UbsxikzS1MRG5hrZt7s81jj9HvRBNuxcVJ1THsPNrdpIASkoobG/K0V5ldU6\n\tyfsp33n6DFByEmBszmJ5i3LhL1FWpoQ7XakMiGqpQwz7S+fQuI1kyEgw7vDbN+NIMlDP\n\temvA==","X-Gm-Message-State":"AHPjjUjcqAnsDrZcdXEZqoSxjjEBDYOsnQ7IVO6ZIApKzsKZq/4DAO8m\n\tnE0TEMb8dBmP9MQ8","X-Google-Smtp-Source":"ADKCNb6WRgfLFrhN8315Bm8K44zfIYMEd0apzJczH6681UpVmZKNqLWJnXbSV52MN66AfcP7rNQlbg==","X-Received":"by 10.223.182.80 with SMTP id i16mr11914659wre.131.1505213040279;\n\tTue, 12 Sep 2017 03:44:00 -0700 (PDT)","Date":"Tue, 12 Sep 2017 12:43:58 +0200","From":"Jiri Pirko <jiri@resnulli.us>","To":"Cong Wang <xiyou.wangcong@gmail.com>","Cc":"netdev@vger.kernel.org, jiri@mellanox.com,\n\tjakub.kicinski@netronome.com, jhs@mojatatu.com","Subject":"Re: [Patch net v3 3/3] net_sched: carefully handle tcf_block_put()","Message-ID":"<20170912104358.GG2036@nanopsycho>","References":"<20170911233332.7594-1-xiyou.wangcong@gmail.com>\n\t<20170911233332.7594-4-xiyou.wangcong@gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20170911233332.7594-4-xiyou.wangcong@gmail.com>","User-Agent":"Mutt/1.8.3 (2017-05-23)","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"}}]