Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp884806pxb; Wed, 27 Oct 2021 14:27:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8E4G/rt5RDzvd1fJ7EX8H8T6doBnyKxud5LQcYgG8Wx6GU8ClAhqjwOCVEqeuOV54khyc X-Received: by 2002:a50:9b4b:: with SMTP id a11mr490548edj.316.1635370030313; Wed, 27 Oct 2021 14:27:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635370030; cv=none; d=google.com; s=arc-20160816; b=htIDrgluZroTicxWHkUg20GNMvXlNxqWPwSWqK5e2TO1J1CvdiCagFN3CtfYhI8WDp x4d+dPgkOLJfeIxEFer8eIC5aciYRXF2ERBe4uHJ1l2JdRT32P3sdoj9fd0oEeZdOSlL UgG6Xy/0IXt2CpQi3TepvxA3XdUJ6d/3rKl0DDEqhoapRqavXLFlIq8dNcfl2qaTcY82 5zAyd5YUm42WHv3OTONUZR3xE3shg4p8U9r93LOvkGj2c0Kc+1QLtSroXdIKOQMOhyYO 10PPSsKiBIT471p9V/uTJG+LdWBqUJ52gDzXdjTvVSN+m6QWWgNScABWDRByemJj241i 4z2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=NpjjYq+i+w+/T84lJ4rWde13BLSANx5QtAmlVDtp0/w=; b=R29c8zHm4H8fLRRoxpilBezYhEy7VaUELnt+VB3e3fUQgXT7q/PulH4CaC9wd4jS4e 4YIDClr9hCndan7uiILwuX9Vl6zQX9wws2+WRg4S3Jhw74f9RwgxywqhJ/n+VkyWXuwo ad3Bs9Mm//vEaJOM9VfsupNiOOLa3lqzpFE45LVqS200bzTupS8L4Taiuo+eXDCo6yk+ 6X0DlzOCkMqj0qWk/HCLW2lvVOHLS/gOlz5ZY9l+5Ulo1uiC8t1QTwfD7KUdbS2LdQ/g TmGdoDth3mEA95SiRcxqcxpS/M7/4mFYj/rNAKvVjIu+U0IxJ49WF/1uFYc6W4ULqj6n h8Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KIk682iO; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id di22si1560396ejc.333.2021.10.27.14.26.46; Wed, 27 Oct 2021 14:27:10 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KIk682iO; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242340AbhJ0OAm (ORCPT + 97 others); Wed, 27 Oct 2021 10:00:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242301AbhJ0OAm (ORCPT ); Wed, 27 Oct 2021 10:00:42 -0400 Received: from mail-ot1-x32d.google.com (mail-ot1-x32d.google.com [IPv6:2607:f8b0:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBA3BC061570; Wed, 27 Oct 2021 06:58:16 -0700 (PDT) Received: by mail-ot1-x32d.google.com with SMTP id b4-20020a9d7544000000b00552ab826e3aso3714385otl.4; Wed, 27 Oct 2021 06:58:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NpjjYq+i+w+/T84lJ4rWde13BLSANx5QtAmlVDtp0/w=; b=KIk682iOWFIRhCa79fS/XyH1smXdI0tMrxiVQN4Px9VwDRFcNtUUaRyFtpkDRCmEfo WSeSUQ6aVN6gFYMefnH/LEA7iEhe7oDSKqGPc3+hDLDFmoSinKiExRGBpEuj/1VLblYK 1m/Nx0wbttD1CfKAqtWpjg5Rt6/qngWG7aUaZLhvn3mvZ2/LQjYoeY7RiSZLuvyctPZs s/PgwWh5mNEbQ96pVd+Of/aw+FqYot+7CT8/Y7xCOwNQLwiN95n7pNRR7J3lb5eQNKu0 rfj9YqDH6DNDAQPcztjy3bTQM6SV36+xUIJu0yLqUBUXgrUtkRYlIvK3hkfeGgbvk40L z+fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NpjjYq+i+w+/T84lJ4rWde13BLSANx5QtAmlVDtp0/w=; b=FMdvO9LhqQGkfRb1FUL7Z94Mc6fp8wLuJDLG79L33GpjetNHxfLmFaimXBOGTU90gf d9MXX6cTl0/ZG93I2/2oI0si1SsBsJOrzTP+qNjfAgvm5wpmc7eih/2p8wLxPGDJTxjb h8nQpzDTp2VKATmYjQmTnBbNC3qliPvWR2za6HnjwJSxpf312nW8sq947689Z/s515tT pfXxHPSINDPiUS9fl6MWu7KdRYq8tqPsogz5VYiaA77k1+YN/d8Ga1WVejwE67qVAdKr ik0MKGAAKPXDBkfnkqm7Yw0nda4TJ3sqQjZ6dsAK+kHiTjdNe28hJA1ithVPApQ/1UlQ UogA== X-Gm-Message-State: AOAM532lK3d6iHATETF7eJjpvuznZWg6hMfE9DoMX+sA7snP4Ddyi6rQ 1oPtNpI1lGTGJZrGfkGVbVGcoQsltJXeCs0nJlM= X-Received: by 2002:a05:6830:2647:: with SMTP id f7mr24666156otu.124.1635343096198; Wed, 27 Oct 2021 06:58:16 -0700 (PDT) MIME-Version: 1.0 References: <20211026131859.59114-1-kerneljasonxing@gmail.com> <31e181c7-7268-877a-f061-cdea06c0459e@huawei.com> In-Reply-To: From: Jason Xing Date: Wed, 27 Oct 2021 21:57:40 +0800 Message-ID: Subject: Re: [PATCH net] net: gro: set the last skb->next to NULL when it get merged To: Yunsheng Lin Cc: David Miller , kuba@kernel.org, alobakin@pm.me, jonathan.lemon@gmail.com, Willem de Bruijn , pabeni@redhat.com, vvs@virtuozzo.com, cong.wang@bytedance.com, netdev , LKML , Jason Xing Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 27, 2021 at 8:54 PM Jason Xing wrote: > > On Wed, Oct 27, 2021 at 8:40 PM Yunsheng Lin wrote: > > > > On 2021/10/27 16:56, Jason Xing wrote: > > > On Wed, Oct 27, 2021 at 4:07 PM Jason Xing wrote: > > >> > > >> On Wed, Oct 27, 2021 at 3:23 PM Jason Xing wrote: > > >>> > > >>> On Tue, Oct 26, 2021 at 9:19 PM wrote: > > >>>> > > >>>> From: Jason Xing > > >>>> > > >>>> Setting the @next of the last skb to NULL to prevent the panic in future > > >>>> when someone does something to the last of the gro list but its @next is > > >>>> invalid. > > >>>> > > >>>> For example, without the fix (commit: ece23711dd95), a panic could happen > > >>>> with the clsact loaded when skb is redirected and then validated in > > >>>> validate_xmit_skb_list() which could access the error addr of the @next > > >>>> of the last skb. Thus, "general protection fault" would appear after that. > > >>>> > > >>>> Signed-off-by: Jason Xing > > >>>> --- > > >>>> net/core/skbuff.c | 1 + > > >>>> 1 file changed, 1 insertion(+) > > >>>> > > >>>> diff --git a/net/core/skbuff.c b/net/core/skbuff.c > > >>>> index 2170bea..7b248f1 100644 > > >>>> --- a/net/core/skbuff.c > > >>>> +++ b/net/core/skbuff.c > > >>>> @@ -4396,6 +4396,7 @@ int skb_gro_receive(struct sk_buff *p, struct sk_buff *skb) > > >>>> skb_shinfo(p)->frag_list = skb; > > >>>> else > > >>>> NAPI_GRO_CB(p)->last->next = skb; > > >>>> + skb->next = NULL; > > >>>> NAPI_GRO_CB(p)->last = skb; > > >>> > > >>> Besides, I'm a little bit confused that this operation inserts the > > >>> newest skb into the tail of the flow, so the tail of flow is the > > >>> newest, head oldest. The patch (commit: 600adc18) introduces the flush > > >>> of the oldest when the flow is full to lower the latency, but actually > > >>> it fetches the tail of the flow. Do I get something wrong here? I feel > > >> > > >> I have to update this part. The commit 600adc18 evicts and flushes the > > >> oldest flow. But for the current kernel, when > > >> "napi->gro_hash[hash].count >= MAX_GRO_SKBS" happens, the > > >> gro_flush_oldest() flushes the oldest skb of one certain flow, > > >> actually it is the newest skb because it is at the end of the list. > > > > it seems the below is more matched with the gro_flush_oldest() instead > > of the above code block: > > https://elixir.bootlin.com/linux/v5.15-rc3/source/net/core/dev.c#L6118 > > > > What you said is the @skb->list but not the list between skbs which is > connected by skb->next when the new incoming skb needs to get merged. > The @skb->list->next/prev is not the same as @skb->next. > > > > > > > I just submitted another patch to explain how it happens, please help > > > me review both patches. > > > > > > Link: https://lore.kernel.org/lkml/20211027084944.4508-1-kerneljasonxing@gmail.com/ > > > Emm, I think you're right, Yunsheng. The gro_flush_oldest() fetches the list of @skb->list. Do you think the tail of skb's next pointer should be set to NULL? Thanks, Jason > > > Thanks again, > > > Jason > > > > > >> > > >>> it is really odd. > > >>> > > >>> Thanks, > > >>> Jason > > >>> > > >>>> __skb_header_release(skb); > > >>>> lp = p; > > >>>> -- > > >>>> 1.8.3.1 > > >>>> > > > . > > >