Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp904866pxv; Thu, 15 Jul 2021 19:31:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDBV3/UlQ556rmY8ibjRiEUvVbTW+86K0e5Gd/RrrCq84vvmCd82RK123PoMYThi2G/Xk5 X-Received: by 2002:a02:cc19:: with SMTP id n25mr6772772jap.140.1626402687968; Thu, 15 Jul 2021 19:31:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626402687; cv=none; d=google.com; s=arc-20160816; b=qWnXCyAwQj16GAEXrGEs94j87CbV/I1uz+rgSkelftFVkyjLaAA92Usw/SzZ2y/aRZ 3iZ4PWfQv/IUYklJsvR2XhvAje/vK/xG4BTIft/66NnCKjV5fqXYY9IwMOUJ0gn2Nls2 DFQLa1u34WXDh6CseRcwG/dKcxZoKwXjBFiw7xIA6qc8XxSdExuGo1LAJUskzmcugKGT ocpBvTao3tTEiXrH0W7ZspT3tMfuG9GPj+yPL8sByu54fsElHqb/9jCMhrW8Xtc6mj3q 7KRJP+hhZIBO+Q+gpPzqSDu6Ub26b2eUNwe1Mo28fxnXakNx7J46j5qDZsC9Wjp8ClzV 3O7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=c1BwLcdDZA0sgfYoCuYqXPC/NQSD0mcHqcRB/Iz9ef0=; b=BaIlyFebXWWxzMD0JwFUKnVbXM4HtPY8CiLiBjEGVY3PqlHEPIeKADdeWjaWA96UgF Fwo4LYiGkxS2GN/f81TqK6jHos5rBk++GXAkrlK/YwHkNvUuTaHiu5cqsMoUIyIOX12y NFSbY1pvqjZZkXeF4At9av6YucfxTDqx7E416DLo0qqBJj7T+wKeLuIQbSe07krDrvrU m/I/G7C6LDCGMlESoAWvY0t+/4Bad//wmbe3sTk826HepzTRm9iHnhWby0qbxB3sv+jK HEtuQ3r+kCbEbqtGiUL8RaNwapD+Z/4/109uoeFWQNmgtRr2fi0rFXgeZ0UM/lP6uZCx YCeA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t6si10379697iov.63.2021.07.15.19.31.15; Thu, 15 Jul 2021 19:31:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233257AbhGPCdf (ORCPT + 99 others); Thu, 15 Jul 2021 22:33:35 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:6941 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233114AbhGPCde (ORCPT ); Thu, 15 Jul 2021 22:33:34 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4GQw9b2HJ9z7vNh; Fri, 16 Jul 2021 10:26:59 +0800 (CST) Received: from dggpemm500005.china.huawei.com (7.185.36.74) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Fri, 16 Jul 2021 10:30:34 +0800 Received: from [10.69.30.204] (10.69.30.204) by dggpemm500005.china.huawei.com (7.185.36.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Fri, 16 Jul 2021 10:30:33 +0800 Subject: Re: [PATCH 1/1 v2] skbuff: Fix a potential race while recycling page_pool packets To: Ilias Apalodimas , Alexander Duyck CC: Netdev , Alexander Duyck , "David S. Miller" , Jakub Kicinski , Alexander Lobakin , Jonathan Lemon , Willem de Bruijn , Miaohe Lin , Guillaume Nault , Cong Wang , Jesper Dangaard Brouer , "Matteo Croce" , LKML References: <20210709062943.101532-1-ilias.apalodimas@linaro.org> From: Yunsheng Lin Message-ID: <57b08af5-8be2-56c7-981c-27ab7187fbdf@huawei.com> Date: Fri, 16 Jul 2021 10:30:33 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.69.30.204] X-ClientProxiedBy: dggeme718-chm.china.huawei.com (10.1.199.114) To dggpemm500005.china.huawei.com (7.185.36.74) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/7/15 23:02, Ilias Apalodimas wrote: > On Thu, Jul 15, 2021 at 07:57:57AM -0700, Alexander Duyck wrote: >> On Thu, Jul 15, 2021 at 7:45 AM Ilias Apalodimas >> wrote: >>> >>>>>> atomic_sub_return(skb->nohdr ? (1 << SKB_DATAREF_SHIFT) + 1 : 1, >>> >>> [...] >>> >>>>>> &shinfo->dataref)) >>>>>> - return; >>>>>> + goto exit; >>>>> >>>>> Is it possible this patch may break the head frag page for the original skb, >>>>> supposing it's head frag page is from the page pool and below change clears >>>>> the pp_recycle for original skb, causing a page leaking for the page pool? >>>> >>>> I don't see how. The assumption here is that when atomic_sub_return >>>> gets down to 0 we will still have an skb with skb->pp_recycle set and >>>> it will flow down and encounter skb_free_head below. All we are doing >>>> is skipping those steps and clearing skb->pp_recycle for all but the >>>> last buffer and the last one to free it will trigger the recycling. >>> >>> I think the assumption here is that >>> 1. We clone an skb >>> 2. The original skb goes into pskb_expand_head() >>> 3. skb_release_data() will be called for the original skb >>> >>> But with the dataref bumped, we'll skip the recycling for it but we'll also >>> skip recycling or unmapping the current head (which is a page_pool mapped >>> buffer) >> >> Right, but in that case it is the clone that is left holding the >> original head and the skb->pp_recycle flag is set on the clone as it >> was copied from the original when we cloned it. > > Ah yes, that's what I missed > >> What we have >> essentially done is transferred the responsibility for freeing it from >> the original to the clone. >> >> If you think about it the result is the same as if step 2 was to go >> into kfree_skb. We would still be calling skb_release_data and the >> dataref would be decremented without the original freeing the page. We >> have to wait until all the clones are freed and dataref reaches 0 >> before the head can be recycled. > > Yep sounds correct Ok, I suppose the fraglist skb is handled similar as the regular skb, right? Also, this patch might need respinning as the state of this patch is "Changes Requested" in patchwork. > > Thanks > /Ilias > . >