From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A748CC04AB1 for ; Thu, 9 May 2019 12:55:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 780C221773 for ; Thu, 9 May 2019 12:55:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726563AbfEIMzh (ORCPT ); Thu, 9 May 2019 08:55:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34502 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726438AbfEIMzh (ORCPT ); Thu, 9 May 2019 08:55:37 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EE8E1306D332; Thu, 9 May 2019 12:55:36 +0000 (UTC) Received: from [10.72.12.183] (ovpn-12-183.pek2.redhat.com [10.72.12.183]) by smtp.corp.redhat.com (Postfix) with ESMTP id B16715C226; Thu, 9 May 2019 12:55:30 +0000 (UTC) Subject: Re: [PATCH net V2] tuntap: synchronize through tfiles array instead of tun->numqueues To: Cong Wang Cc: Linux Kernel Network Developers , "Michael S. Tsirkin" , YueHaibing , "weiyongjun (A)" , Eric Dumazet References: <1557201816-19945-1-git-send-email-jasowang@redhat.com> From: Jason Wang Message-ID: <79cefeef-f7b9-e97f-2e81-cdb2c73b5767@redhat.com> Date: Thu, 9 May 2019 20:55:28 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Thu, 09 May 2019 12:55:37 +0000 (UTC) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 2019/5/9 下午1:34, Cong Wang wrote: > On Tue, May 7, 2019 at 7:54 PM Jason Wang wrote: >> This is only true if you can make sure tfile[tun->numqueues] is not >> freed. Either my patch or SOCK_RCU_FREE can solve this, but for >> SOCK_RCU_FREE we need do extra careful audit to make sure it doesn't >> break someting. So synchronize through pointers in tfiles[] which is >> already protected by RCU is much more easier. It can make sure no >> dereference from xmit path after synchornize_net(). And this matches the >> assumptions of the codes after synchronize_net(). >> > It is hard to tell which sock_put() matches with this synchronize_net() > given the call path is complicated. > > With SOCK_RCU_FREE, no such a problem, all sock_put() will be safe. > So to me SOCK_RCU_FREE is much easier to understand and audit. The problem is not tfile itself but the data structure associated. As I mentioned earlier, the xdp_rxq_info_unreg() looks racy if tun_net_xmit() can read stale value of numqueues. It's just one example, we may meet similar issues in the future when adding more features. Thanks > > Thanks.